Commit f0686b39 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Fix all failing tests on MySQL, PostgreSQL and Oracle

parent 4c5317e0
...@@ -252,4 +252,4 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement ...@@ -252,4 +252,4 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
{ {
return $this->statement->rowCount(); return $this->statement->rowCount();
} }
} }
\ No newline at end of file
<?php <?php
/* /*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...@@ -37,8 +35,7 @@ use Doctrine\Common\EventSubscriber; ...@@ -37,8 +35,7 @@ use Doctrine\Common\EventSubscriber;
* *
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com * @link www.doctrine-project.com
* @since 1.0 * @since 2.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de> * @author Benjamin Eberlei <kontakt@beberlei.de>
*/ */
class OracleSessionInit implements EventSubscriber class OracleSessionInit implements EventSubscriber
......
...@@ -37,12 +37,12 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement ...@@ -37,12 +37,12 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
* @var int * @var int
*/ */
private $portability; private $portability;
/** /**
* @var Doctrine\DBAL\Driver\Statement * @var Doctrine\DBAL\Driver\Statement
*/ */
private $stmt; private $stmt;
/** /**
* @var int * @var int
*/ */
...@@ -115,12 +115,12 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement ...@@ -115,12 +115,12 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
public function fetch($fetchStyle = PDO::FETCH_BOTH) public function fetch($fetchStyle = PDO::FETCH_BOTH)
{ {
$row = $this->stmt->fetch($fetchStyle); $row = $this->stmt->fetch($fetchStyle);
$row = $this->fixRow($row, $row = $this->fixRow($row,
$this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM), $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM),
!is_null($this->case) && ($fetchStyle == PDO::FETCH_ASSOC || $fetchStyle == PDO::FETCH_BOTH) && ($this->portability & Connection::PORTABILITY_FIX_CASE) !is_null($this->case) && ($fetchStyle == PDO::FETCH_ASSOC || $fetchStyle == PDO::FETCH_BOTH) && ($this->portability & Connection::PORTABILITY_FIX_CASE)
); );
return $row; return $row;
} }
...@@ -131,7 +131,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement ...@@ -131,7 +131,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
} else { } else {
$rows = $this->stmt->fetchAll($fetchStyle); $rows = $this->stmt->fetchAll($fetchStyle);
} }
$iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM); $iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM);
$fixCase = !is_null($this->case) && ($fetchStyle == PDO::FETCH_ASSOC || $fetchStyle == PDO::FETCH_BOTH) && ($this->portability & Connection::PORTABILITY_FIX_CASE); $fixCase = !is_null($this->case) && ($fetchStyle == PDO::FETCH_ASSOC || $fetchStyle == PDO::FETCH_BOTH) && ($this->portability & Connection::PORTABILITY_FIX_CASE);
if (!$iterateRow && !$fixCase) { if (!$iterateRow && !$fixCase) {
...@@ -141,16 +141,16 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement ...@@ -141,16 +141,16 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
foreach ($rows AS $num => $row) { foreach ($rows AS $num => $row) {
$rows[$num] = $this->fixRow($row, $iterateRow, $fixCase); $rows[$num] = $this->fixRow($row, $iterateRow, $fixCase);
} }
return $rows; return $rows;
} }
protected function fixRow($row, $iterateRow, $fixCase) protected function fixRow($row, $iterateRow, $fixCase)
{ {
if (!$row) { if (!$row) {
return $row; return $row;
} }
if ($fixCase) { if ($fixCase) {
$row = array_change_key_case($row, $this->case); $row = array_change_key_case($row, $this->case);
} }
...@@ -170,7 +170,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement ...@@ -170,7 +170,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
public function fetchColumn($columnIndex = 0) public function fetchColumn($columnIndex = 0)
{ {
$value = $this->stmt->fetchColumn($columnIndex); $value = $this->stmt->fetchColumn($columnIndex);
if ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM)) { if ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM)) {
if (($this->portability & Connection::PORTABILITY_EMPTY_TO_NULL) && $value === '') { if (($this->portability & Connection::PORTABILITY_EMPTY_TO_NULL) && $value === '') {
$value = null; $value = null;
...@@ -178,7 +178,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement ...@@ -178,7 +178,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
$value = rtrim($value); $value = rtrim($value);
} }
} }
return $value; return $value;
} }
...@@ -187,4 +187,4 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement ...@@ -187,4 +187,4 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
return $this->stmt->rowCount(); return $this->stmt->rowCount();
} }
} }
\ No newline at end of file
...@@ -21,13 +21,12 @@ ...@@ -21,13 +21,12 @@
namespace Doctrine\DBAL\Schema; namespace Doctrine\DBAL\Schema;
/** /**
* xxx * PostgreSQL Schema Manager
* *
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library) * @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @author Benjamin Eberlei <kontakt@beberlei.de> * @author Benjamin Eberlei <kontakt@beberlei.de>
* @version $Revision$
* @since 2.0 * @since 2.0
*/ */
class PostgreSqlSchemaManager extends AbstractSchemaManager class PostgreSqlSchemaManager extends AbstractSchemaManager
...@@ -338,6 +337,10 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -338,6 +337,10 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
break; break;
} }
if ($tableColumn['default'] && preg_match("('([^']+)'::)", $tableColumn['default'], $match)) {
$tableColumn['default'] = $match[1];
}
$options = array( $options = array(
'length' => $length, 'length' => $length,
'notnull' => (bool) $tableColumn['isnotnull'], 'notnull' => (bool) $tableColumn['isnotnull'],
...@@ -354,4 +357,4 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -354,4 +357,4 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
return new Column($tableColumn['field'], \Doctrine\DBAL\Types\Type::getType($type), $options); return new Column($tableColumn['field'], \Doctrine\DBAL\Types\Type::getType($type), $options);
} }
} }
\ No newline at end of file
...@@ -10,11 +10,13 @@ require_once __DIR__ . '/../../TestInit.php'; ...@@ -10,11 +10,13 @@ require_once __DIR__ . '/../../TestInit.php';
class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
{ {
static private $generated = false;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
try { if (self::$generated === false) {
/* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */ /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
$table = new \Doctrine\DBAL\Schema\Table("fetch_table"); $table = new \Doctrine\DBAL\Schema\Table("fetch_table");
$table->addColumn('test_int', 'integer'); $table->addColumn('test_int', 'integer');
...@@ -26,8 +28,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -26,8 +28,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$sm->createTable($table); $sm->createTable($table);
$this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo', 'test_datetime' => '2010-01-01 10:10:10')); $this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo', 'test_datetime' => '2010-01-01 10:10:10'));
} catch(\Exception $e) { self::$generated = true;
} }
} }
...@@ -318,7 +319,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -318,7 +319,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->assertEquals(0, count($rows), "no result should be returned, otherwise SQL injection is possible"); $this->assertEquals(0, count($rows), "no result should be returned, otherwise SQL injection is possible");
} }
/** /**
* @group DDC-1213 * @group DDC-1213
*/ */
...@@ -327,19 +328,19 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -327,19 +328,19 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->_conn->executeQuery('DELETE FROM fetch_table')->execute(); $this->_conn->executeQuery('DELETE FROM fetch_table')->execute();
$platform = $this->_conn->getDatabasePlatform(); $platform = $this->_conn->getDatabasePlatform();
$bitmap = array(); $bitmap = array();
for ($i = 2; $i < 9; $i = $i + 2) { for ($i = 2; $i < 9; $i = $i + 2) {
$bitmap[$i] = array( $bitmap[$i] = array(
'bit_or' => ($i | 2), 'bit_or' => ($i | 2),
'bit_and' => ($i & 2) 'bit_and' => ($i & 2)
); );
$this->_conn->insert('fetch_table', array( $this->_conn->insert('fetch_table', array(
'test_int' => $i, 'test_int' => $i,
'test_string' => json_encode($bitmap[$i]), 'test_string' => json_encode($bitmap[$i]),
'test_datetime' => '2010-01-01 10:10:10' 'test_datetime' => '2010-01-01 10:10:10'
)); ));
} }
$sql[] = 'SELECT '; $sql[] = 'SELECT ';
$sql[] = 'test_int, '; $sql[] = 'test_int, ';
$sql[] = 'test_string, '; $sql[] = 'test_string, ';
...@@ -349,22 +350,23 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -349,22 +350,23 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$stmt = $this->_conn->executeQuery(implode(PHP_EOL, $sql)); $stmt = $this->_conn->executeQuery(implode(PHP_EOL, $sql));
$data = $stmt->fetchAll(PDO::FETCH_ASSOC); $data = $stmt->fetchAll(PDO::FETCH_ASSOC);
$this->assertEquals(4, count($data)); $this->assertEquals(4, count($data));
$this->assertEquals(count($bitmap), count($data)); $this->assertEquals(count($bitmap), count($data));
foreach ($data as $row) { foreach ($data as $row) {
$row = array_change_key_case($row, CASE_LOWER);
$this->assertArrayHasKey('test_int', $row); $this->assertArrayHasKey('test_int', $row);
$id = $row['test_int']; $id = $row['test_int'];
$this->assertArrayHasKey($id, $bitmap); $this->assertArrayHasKey($id, $bitmap);
$this->assertArrayHasKey($id, $bitmap); $this->assertArrayHasKey($id, $bitmap);
$this->assertArrayHasKey('bit_or', $row); $this->assertArrayHasKey('bit_or', $row);
$this->assertArrayHasKey('bit_and', $row); $this->assertArrayHasKey('bit_and', $row);
$this->assertEquals($row['bit_or'], $bitmap[$id]['bit_or']); $this->assertEquals($row['bit_or'], $bitmap[$id]['bit_or']);
$this->assertEquals($row['bit_and'], $bitmap[$id]['bit_and']); $this->assertEquals($row['bit_and'], $bitmap[$id]['bit_and']);
} }
...@@ -378,4 +380,4 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -378,4 +380,4 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$row = array_keys($stmt->fetch()); $row = array_keys($stmt->fetch());
$this->assertEquals(0, count( array_filter($row, function($v) { return ! is_numeric($v); })), "should be no non-numerical elements in the result."); $this->assertEquals(0, count( array_filter($row, function($v) { return ! is_numeric($v); })), "should be no non-numerical elements in the result.");
} }
} }
\ No newline at end of file
...@@ -156,7 +156,11 @@ class NamedParametersTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -156,7 +156,11 @@ class NamedParametersTest extends \Doctrine\Tests\DbalFunctionalTestCase
$stmt = $this->_conn->executeQuery($query, $params, $types); $stmt = $this->_conn->executeQuery($query, $params, $types);
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC); $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
foreach ($result as $k => $v) {
$result[$k] = array_change_key_case($v, CASE_LOWER);
}
$this->assertEquals($result, $expected); $this->assertEquals($result, $expected);
} }
} }
\ No newline at end of file
...@@ -61,6 +61,7 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -61,6 +61,7 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->assertFetchResultRows($rows); $this->assertFetchResultRows($rows);
$stmt = $this->getPortableConnection()->query('SELECT * FROM portability_table'); $stmt = $this->getPortableConnection()->query('SELECT * FROM portability_table');
$stmt->setFetchMode(\PDO::FETCH_ASSOC);
foreach ($stmt as $row) { foreach ($stmt as $row) {
$this->assertFetchResultRow($row); $this->assertFetchResultRow($row);
} }
...@@ -93,4 +94,4 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -93,4 +94,4 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->assertEquals(3, strlen($row['test_string']), "test_string should be rtrimed to length of three for CHAR(32) column."); $this->assertEquals(3, strlen($row['test_string']), "test_string should be rtrimed to length of three for CHAR(32) column.");
$this->assertNull($row['test_null']); $this->assertNull($row['test_null']);
} }
} }
\ No newline at end of file
...@@ -72,13 +72,13 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -72,13 +72,13 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
foreach ($this->expectedResult AS $v) { foreach ($this->expectedResult AS $v) {
$numExpectedResult[] = array_values($v); $numExpectedResult[] = array_values($v);
} }
$stmt = $this->_conn->executeQuery("SELECT * FROM caching", array(), array(), new QueryCacheProfile(10, "testcachekey")); $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
$data = $this->hydrateStmt($stmt, \PDO::FETCH_ASSOC); $data = $this->hydrateStmt($stmt, \PDO::FETCH_ASSOC);
$this->assertEquals($this->expectedResult, $data); $this->assertEquals($this->expectedResult, $data);
$stmt = $this->_conn->executeQuery("SELECT * FROM caching", array(), array(), new QueryCacheProfile(10, "testcachekey")); $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
$data = $this->hydrateStmt($stmt, \PDO::FETCH_NUM); $data = $this->hydrateStmt($stmt, \PDO::FETCH_NUM);
...@@ -94,10 +94,10 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -94,10 +94,10 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function assertStandardAndIteratorFetchAreEqual($fetchStyle) public function assertStandardAndIteratorFetchAreEqual($fetchStyle)
{ {
$stmt = $this->_conn->executeQuery("SELECT * FROM caching", array(), array(), new QueryCacheProfile(10, "testcachekey")); $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
$data = $this->hydrateStmt($stmt, $fetchStyle); $data = $this->hydrateStmt($stmt, $fetchStyle);
$stmt = $this->_conn->executeQuery("SELECT * FROM caching", array(), array(), new QueryCacheProfile(10, "testcachekey")); $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
$data_iterator = $this->hydrateStmtIterator($stmt, $fetchStyle); $data_iterator = $this->hydrateStmtIterator($stmt, $fetchStyle);
$this->assertEquals($data, $data_iterator); $this->assertEquals($data, $data_iterator);
...@@ -105,14 +105,14 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -105,14 +105,14 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testDontCloseNoCache() public function testDontCloseNoCache()
{ {
$stmt = $this->_conn->executeQuery("SELECT * FROM caching", array(), array(), new QueryCacheProfile(10, "testcachekey")); $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
$data = array(); $data = array();
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$data[] = $row; $data[] = $row;
} }
$stmt = $this->_conn->executeQuery("SELECT * FROM caching", array(), array(), new QueryCacheProfile(10, "testcachekey")); $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
$data = array(); $data = array();
while ($row = $stmt->fetch(\PDO::FETCH_NUM)) { while ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
...@@ -124,12 +124,12 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -124,12 +124,12 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testDontFinishNoCache() public function testDontFinishNoCache()
{ {
$stmt = $this->_conn->executeQuery("SELECT * FROM caching", array(), array(), new QueryCacheProfile(10, "testcachekey")); $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
$row = $stmt->fetch(\PDO::FETCH_ASSOC); $row = $stmt->fetch(\PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$stmt = $this->_conn->executeQuery("SELECT * FROM caching", array(), array(), new QueryCacheProfile(10, "testcachekey")); $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
$data = $this->hydrateStmt($stmt, \PDO::FETCH_NUM); $data = $this->hydrateStmt($stmt, \PDO::FETCH_NUM);
...@@ -138,13 +138,13 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -138,13 +138,13 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, $fetchStyle) public function assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, $fetchStyle)
{ {
$stmt = $this->_conn->executeQuery("SELECT * FROM caching", array(), array(), new QueryCacheProfile(10, "testcachekey")); $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
$this->assertEquals(2, $stmt->columnCount()); $this->assertEquals(2, $stmt->columnCount());
$data = $this->hydrateStmt($stmt, $fetchStyle); $data = $this->hydrateStmt($stmt, $fetchStyle);
$this->assertEquals($expectedResult, $data); $this->assertEquals($expectedResult, $data);
$stmt = $this->_conn->executeQuery("SELECT * FROM caching", array(), array(), new QueryCacheProfile(10, "testcachekey")); $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
$this->assertEquals(2, $stmt->columnCount()); $this->assertEquals(2, $stmt->columnCount());
$data = $this->hydrateStmt($stmt, $fetchStyle); $data = $this->hydrateStmt($stmt, $fetchStyle);
...@@ -180,7 +180,7 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -180,7 +180,7 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
{ {
$data = array(); $data = array();
while ($row = $stmt->fetch($fetchStyle)) { while ($row = $stmt->fetch($fetchStyle)) {
$data[] = $row; $data[] = array_change_key_case($row, CASE_LOWER);
} }
$stmt->closeCursor(); $stmt->closeCursor();
return $data; return $data;
...@@ -191,9 +191,9 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -191,9 +191,9 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
$data = array(); $data = array();
$stmt->setFetchMode($fetchStyle); $stmt->setFetchMode($fetchStyle);
foreach ($stmt as $row) { foreach ($stmt as $row) {
$data[] = $row; $data[] = array_change_key_case($row, CASE_LOWER);
} }
$stmt->closeCursor(); $stmt->closeCursor();
return $data; return $data;
} }
} }
\ No newline at end of file
...@@ -98,8 +98,8 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -98,8 +98,8 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
{ {
$table = new \Doctrine\DBAL\Schema\Table('list_table_columns'); $table = new \Doctrine\DBAL\Schema\Table('list_table_columns');
$table->addColumn('id', 'integer', array('notnull' => true)); $table->addColumn('id', 'integer', array('notnull' => true));
$table->addColumn('test', 'string', array('length' => 255, 'notnull' => false)); $table->addColumn('test', 'string', array('length' => 255, 'notnull' => false, 'default' => 'expected default'));
$table->addColumn('foo', 'text', array('notnull' => true, 'default' => 'expected default')); $table->addColumn('foo', 'text', array('notnull' => true));
$table->addColumn('bar', 'decimal', array('precision' => 10, 'scale' => 4, 'notnull' => false)); $table->addColumn('bar', 'decimal', array('precision' => 10, 'scale' => 4, 'notnull' => false));
$table->addColumn('baz1', 'datetime'); $table->addColumn('baz1', 'datetime');
$table->addColumn('baz2', 'time'); $table->addColumn('baz2', 'time');
...@@ -130,7 +130,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -130,7 +130,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertEquals(255, $columns['test']->getlength()); $this->assertEquals(255, $columns['test']->getlength());
$this->assertEquals(false, $columns['test']->getfixed()); $this->assertEquals(false, $columns['test']->getfixed());
$this->assertEquals(false, $columns['test']->getnotnull()); $this->assertEquals(false, $columns['test']->getnotnull());
$this->assertEquals(null, $columns['test']->getdefault()); $this->assertEquals('expected default', $columns['test']->getdefault());
$this->assertInternalType('array', $columns['test']->getPlatformOptions()); $this->assertInternalType('array', $columns['test']->getPlatformOptions());
$this->assertEquals('foo', strtolower($columns['foo']->getname())); $this->assertEquals('foo', strtolower($columns['foo']->getname()));
...@@ -138,7 +138,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -138,7 +138,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertEquals(false, $columns['foo']->getunsigned()); $this->assertEquals(false, $columns['foo']->getunsigned());
$this->assertEquals(false, $columns['foo']->getfixed()); $this->assertEquals(false, $columns['foo']->getfixed());
$this->assertEquals(true, $columns['foo']->getnotnull()); $this->assertEquals(true, $columns['foo']->getnotnull());
$this->assertEquals('expected default', $columns['foo']->getdefault()); $this->assertEquals(null, $columns['foo']->getdefault());
$this->assertInternalType('array', $columns['foo']->getPlatformOptions()); $this->assertInternalType('array', $columns['foo']->getPlatformOptions());
$this->assertEquals('bar', strtolower($columns['bar']->getname())); $this->assertEquals('bar', strtolower($columns['bar']->getname()));
...@@ -188,7 +188,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -188,7 +188,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
public function testListTableIndexes() public function testListTableIndexes()
{ {
$table = $this->getTestTable('list_table_indexes_test'); $table = $this->getTestCompositeTable('list_table_indexes_test');
$table->addUniqueIndex(array('test'), 'test_index_name'); $table->addUniqueIndex(array('test'), 'test_index_name');
$table->addIndex(array('id', 'test'), 'test_composite_idx'); $table->addIndex(array('id', 'test'), 'test_composite_idx');
...@@ -505,10 +505,20 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -505,10 +505,20 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$table = new \Doctrine\DBAL\Schema\Table($name, array(), array(), array(), false, $options); $table = new \Doctrine\DBAL\Schema\Table($name, array(), array(), array(), false, $options);
$table->setSchemaConfig($this->_sm->createSchemaConfig()); $table->setSchemaConfig($this->_sm->createSchemaConfig());
$table->addColumn('id', 'integer', array('notnull' => true)); $table->addColumn('id', 'integer', array('notnull' => true));
$table->setPrimaryKey(array('id'));
$table->addColumn('test', 'string', array('length' => 255));
$table->addColumn('foreign_key_test', 'integer');
return $table;
}
protected function getTestCompositeTable($name)
{
$table = new \Doctrine\DBAL\Schema\Table($name, array(), array(), array(), false, array());
$table->setSchemaConfig($this->_sm->createSchemaConfig());
$table->addColumn('id', 'integer', array('notnull' => true));
$table->addColumn('other_id', 'integer', array('notnull' => true)); $table->addColumn('other_id', 'integer', array('notnull' => true));
$table->setPrimaryKey(array('id', 'other_id')); $table->setPrimaryKey(array('id', 'other_id'));
$table->addColumn('test', 'string', array('length' => 255)); $table->addColumn('test', 'string', array('length' => 255));
$table->addColumn('foreign_key_test', 'integer');
return $table; return $table;
} }
...@@ -523,4 +533,4 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -523,4 +533,4 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
} }
$this->assertTrue($foundTable, "Could not find new table"); $this->assertTrue($foundTable, "Could not find new table");
} }
} }
\ No newline at end of file
...@@ -100,6 +100,14 @@ class TestUtil ...@@ -100,6 +100,14 @@ class TestUtil
$conn = \Doctrine\DBAL\DriverManager::getConnection($params); $conn = \Doctrine\DBAL\DriverManager::getConnection($params);
} }
if (isset($GLOBALS['db_event_subscribers'])) {
$evm = $conn->getEventManager();
foreach (explode(",", $GLOBALS['db_event_subscribers']) AS $subscriberClass) {
$subscriberInstance = new $subscriberClass();
$evm->addEventSubscriber($subscriberInstance);
}
}
return $conn; return $conn;
} }
...@@ -120,4 +128,4 @@ class TestUtil ...@@ -120,4 +128,4 @@ class TestUtil
// Connect to tmpdb in order to drop and create the real test db. // Connect to tmpdb in order to drop and create the real test db.
return \Doctrine\DBAL\DriverManager::getConnection($tmpDbParams); return \Doctrine\DBAL\DriverManager::getConnection($tmpDbParams);
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment