Commit b8896c4f authored by Benjamin Eberlei's avatar Benjamin Eberlei

Fix DBAL tests to make testsuite run on SQL Azure

parent 3fd222f7
...@@ -20,6 +20,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -20,6 +20,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table->addColumn('test_int', 'integer'); $table->addColumn('test_int', 'integer');
$table->addColumn('test_string', 'string'); $table->addColumn('test_string', 'string');
$table->addColumn('test_datetime', 'datetime', array('notnull' => false)); $table->addColumn('test_datetime', 'datetime', array('notnull' => false));
$table->setPrimaryKey(array('test_int'));
$sm = $this->_conn->getSchemaManager(); $sm = $this->_conn->getSchemaManager();
$sm->createTable($table); $sm->createTable($table);
...@@ -121,6 +122,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -121,6 +122,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$stmt->execute(array($paramInt, $paramStr)); $stmt->execute(array($paramInt, $paramStr));
$row = $stmt->fetch(\PDO::FETCH_ASSOC); $row = $stmt->fetch(\PDO::FETCH_ASSOC);
$this->assertTrue($row !== false);
$row = array_change_key_case($row, \CASE_LOWER); $row = array_change_key_case($row, \CASE_LOWER);
$this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row); $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row);
} }
...@@ -145,6 +147,8 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -145,6 +147,8 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$row = $this->_conn->fetchAssoc($sql, array(1, 'foo')); $row = $this->_conn->fetchAssoc($sql, array(1, 'foo'));
$this->assertTrue($row !== false);
$row = array_change_key_case($row, \CASE_LOWER); $row = array_change_key_case($row, \CASE_LOWER);
$this->assertEquals(1, $row['test_int']); $this->assertEquals(1, $row['test_int']);
...@@ -196,7 +200,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -196,7 +200,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$sql = 'INSERT INTO fetch_table (test_int, test_string, test_datetime) VALUES (?, ?, ?)'; $sql = 'INSERT INTO fetch_table (test_int, test_string, test_datetime) VALUES (?, ?, ?)';
$affectedRows = $this->_conn->executeUpdate($sql, $affectedRows = $this->_conn->executeUpdate($sql,
array(1 => 1, 2 => 'foo', 3 => $datetime), array(1 => 50, 2 => 'foo', 3 => $datetime),
array(1 => PDO::PARAM_INT, 2 => PDO::PARAM_STR, 3 => Type::DATETIME) array(1 => PDO::PARAM_INT, 2 => PDO::PARAM_STR, 3 => Type::DATETIME)
); );
......
...@@ -114,6 +114,7 @@ class NamedParametersTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -114,6 +114,7 @@ class NamedParametersTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table->addColumn('id', 'integer'); $table->addColumn('id', 'integer');
$table->addColumn('foo','string'); $table->addColumn('foo','string');
$table->addColumn('bar','string'); $table->addColumn('bar','string');
$table->setPrimaryKey(array('id'));
$sm = $this->_conn->getSchemaManager(); $sm = $this->_conn->getSchemaManager();
......
...@@ -40,12 +40,13 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -40,12 +40,13 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table->addColumn('Test_Int', 'integer'); $table->addColumn('Test_Int', 'integer');
$table->addColumn('Test_String', 'string', array('fixed' => true, 'length' => 32)); $table->addColumn('Test_String', 'string', array('fixed' => true, 'length' => 32));
$table->addColumn('Test_Null', 'string', array('notnull' => false)); $table->addColumn('Test_Null', 'string', array('notnull' => false));
$table->setPrimaryKey(array('Test_Int'));
$sm = $this->portableConnection->getSchemaManager(); $sm = $this->portableConnection->getSchemaManager();
$sm->createTable($table); $sm->createTable($table);
$this->portableConnection->insert('portability_table', array('Test_Int' => 1, 'Test_String' => 'foo', 'Test_Null' => '')); $this->portableConnection->insert('portability_table', array('Test_Int' => 1, 'Test_String' => 'foo', 'Test_Null' => ''));
$this->portableConnection->insert('portability_table', array('Test_Int' => 1, 'Test_String' => 'foo ', 'Test_Null' => null)); $this->portableConnection->insert('portability_table', array('Test_Int' => 2, 'Test_String' => 'foo ', 'Test_Null' => null));
} catch(\Exception $e) { } catch(\Exception $e) {
} }
...@@ -82,7 +83,7 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -82,7 +83,7 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function assertFetchResultRow($row) public function assertFetchResultRow($row)
{ {
$this->assertEquals(1, $row['test_int']); $this->assertTrue(in_array($row['test_int'], array(1, 2)), "Primary key test_int should either be 1 or 2.");
$this->assertArrayHasKey('test_string', $row, "Case should be lowered."); $this->assertArrayHasKey('test_string', $row, "Case should be lowered.");
$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']);
......
...@@ -24,6 +24,7 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -24,6 +24,7 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table = new \Doctrine\DBAL\Schema\Table("caching"); $table = new \Doctrine\DBAL\Schema\Table("caching");
$table->addColumn('test_int', 'integer'); $table->addColumn('test_int', 'integer');
$table->addColumn('test_string', 'string', array('notnull' => false)); $table->addColumn('test_string', 'string', array('notnull' => false));
$table->setPrimaryKey(array('test_int'));
$sm = $this->_conn->getSchemaManager(); $sm = $this->_conn->getSchemaManager();
$sm->createTable($table); $sm->createTable($table);
......
...@@ -33,6 +33,7 @@ class TemporaryTableTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -33,6 +33,7 @@ class TemporaryTableTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table = new Table("non_temporary"); $table = new Table("non_temporary");
$table->addColumn("id", "integer"); $table->addColumn("id", "integer");
$table->setPrimaryKey(array('id'));
$this->_conn->getSchemaManager()->createTable($table); $this->_conn->getSchemaManager()->createTable($table);
$this->_conn->beginTransaction(); $this->_conn->beginTransaction();
...@@ -64,6 +65,7 @@ class TemporaryTableTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -64,6 +65,7 @@ class TemporaryTableTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table = new Table("non_temporary"); $table = new Table("non_temporary");
$table->addColumn("id", "integer"); $table->addColumn("id", "integer");
$table->setPrimaryKey(array('id'));
$this->_conn->getSchemaManager()->createTable($table); $this->_conn->getSchemaManager()->createTable($table);
$this->_conn->beginTransaction(); $this->_conn->beginTransaction();
......
...@@ -24,7 +24,7 @@ class DateTimeTest extends \Doctrine\Tests\DbalTestCase ...@@ -24,7 +24,7 @@ class DateTimeTest extends \Doctrine\Tests\DbalTestCase
$date = new \DateTime('1985-09-01 10:10:10'); $date = new \DateTime('1985-09-01 10:10:10');
$expected = $date->format($this->_platform->getDateTimeTzFormatString()); $expected = $date->format($this->_platform->getDateTimeTzFormatString());
$actual = is_string($this->_type->convertToDatabaseValue($date, $this->_platform)); $actual = $this->_type->convertToDatabaseValue($date, $this->_platform);
$this->assertEquals($expected, $actual); $this->assertEquals($expected, $actual);
} }
......
...@@ -24,7 +24,7 @@ class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase ...@@ -24,7 +24,7 @@ class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase
$date = new \DateTime('1985-09-01 10:10:10'); $date = new \DateTime('1985-09-01 10:10:10');
$expected = $date->format($this->_platform->getDateTimeTzFormatString()); $expected = $date->format($this->_platform->getDateTimeTzFormatString());
$actual = is_string($this->_type->convertToDatabaseValue($date, $this->_platform)); $actual = $this->_type->convertToDatabaseValue($date, $this->_platform);
$this->assertEquals($expected, $actual); $this->assertEquals($expected, $actual);
} }
......
...@@ -27,7 +27,7 @@ class VarDateTimeTest extends \Doctrine\Tests\DbalTestCase ...@@ -27,7 +27,7 @@ class VarDateTimeTest extends \Doctrine\Tests\DbalTestCase
$date = new \DateTime('1985-09-01 10:10:10'); $date = new \DateTime('1985-09-01 10:10:10');
$expected = $date->format($this->_platform->getDateTimeTzFormatString()); $expected = $date->format($this->_platform->getDateTimeTzFormatString());
$actual = is_string($this->_type->convertToDatabaseValue($date, $this->_platform)); $actual = $this->_type->convertToDatabaseValue($date, $this->_platform);
$this->assertEquals($expected, $actual); $this->assertEquals($expected, $actual);
} }
......
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