61 lines
1.8 KiB
PHP
61 lines
1.8 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Doctrine\Models\DBAL\Functional;
|
||
|
|
||
|
class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
|
||
|
{
|
||
|
public function setUp()
|
||
|
{
|
||
|
parent::setUp();
|
||
|
|
||
|
try {
|
||
|
/* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
|
||
|
$table = new \Doctrine\DBAL\Schema\Table("fetch_table");
|
||
|
$table->addColumn('test_int', 'integer');
|
||
|
$table->addColumn('test_string', 'string');
|
||
|
|
||
|
$sm = $this->_conn->getSchemaManager();
|
||
|
$sm->createTable($table);
|
||
|
|
||
|
$this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo'));
|
||
|
} catch(\Exception $e) {
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function testFetchAll()
|
||
|
{
|
||
|
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
|
||
|
$data = $this->_conn->fetchAll($sql, array(1, 'foo'));
|
||
|
|
||
|
$this->assertEquals(1, count($data));
|
||
|
|
||
|
$row = $data[0];
|
||
|
$this->assertEquals(2, count($row));
|
||
|
|
||
|
$row = array_change_key_case($row, \CASE_LOWER);
|
||
|
$this->assertEquals(1, $row['test_int']);
|
||
|
$this->assertEquals('foo', $row['test_string']);
|
||
|
}
|
||
|
|
||
|
public function testFetchRow()
|
||
|
{
|
||
|
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
|
||
|
$row = $this->_conn->fetchRow($sql, array(1, 'foo'));
|
||
|
|
||
|
$row = array_change_key_case($row, \CASE_LOWER);
|
||
|
|
||
|
$this->assertEquals(1, $row['test_int']);
|
||
|
$this->assertEquals('foo', $row['test_string']);
|
||
|
}
|
||
|
|
||
|
public function testFetchArray()
|
||
|
{
|
||
|
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
|
||
|
$row = $this->_conn->fetchArray($sql, array(1, 'foo'));
|
||
|
|
||
|
$this->assertEquals(1, $row[0]);
|
||
|
$this->assertEquals('foo', $row[1]);
|
||
|
}
|
||
|
|
||
|
}
|