From a307b86ecbffa9e6e472d53aa1a6f0062237a901 Mon Sep 17 00:00:00 2001 From: beberlei Date: Mon, 2 Nov 2009 16:50:48 +0000 Subject: [PATCH] [2.0] DDC-84 - Added increment alter table / update schema tests for Oracle Platform - Fixed a simple bug in Postgres Tests. --- .../Tests/ORM/Tools/SchemaTool/AllTests.php | 1 + .../SchemaTool/OracleUpdateSchemaTest.php | 136 ++++++++++++++++++ .../SchemaTool/PostgresUpdateSchemaTest.php | 8 +- 3 files changed, 140 insertions(+), 5 deletions(-) create mode 100644 tests/Doctrine/Tests/ORM/Tools/SchemaTool/OracleUpdateSchemaTest.php diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaTool/AllTests.php b/tests/Doctrine/Tests/ORM/Tools/SchemaTool/AllTests.php index e5bc676ec..496ce4710 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaTool/AllTests.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaTool/AllTests.php @@ -21,6 +21,7 @@ class AllTests $suite->addTestSuite('Doctrine\Tests\ORM\Tools\SchemaTool\MysqlUpdateSchemaTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Tools\SchemaTool\PostgresUpdateSchemaTest'); + $suite->addTestSuite('Doctrine\Tests\ORM\Tools\SchemaTool\OracleUpdateSchemaTest'); return $suite; diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaTool/OracleUpdateSchemaTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaTool/OracleUpdateSchemaTest.php new file mode 100644 index 000000000..b44aa95c0 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaTool/OracleUpdateSchemaTest.php @@ -0,0 +1,136 @@ +_doTestAddField(); + + $this->assertEquals(1, count($sql)); + $this->assertEquals( + "ALTER TABLE cms_addresses ADD (street VARCHAR2(255) NOT NULL)", + $sql[0] + ); + } + + public function testChangeColumnName() + { + $sql = $this->_doTestChangeColumnName(); + + $this->assertEquals(2, count($sql)); + $this->assertEquals("ALTER TABLE cms_addresses ADD (the_city VARCHAR2(50) NOT NULL)", $sql[0]); + $this->assertEquals("ALTER TABLE cms_addresses DROP COLUMN city", $sql[1]); + } + + public function testChangeNullability() + { + $sql = $this->_doTestChangeNullability(); + + $this->assertEquals(1, count($sql)); + $this->assertEquals("ALTER TABLE cms_addresses MODIFY (city VARCHAR2(50) DEFAULT NULL)", $sql[0]); + } + + /** + * @group DDC-102 + */ + public function testChangeNullabilityToNull() + { + $sql = $this->_doTestChangeNullabilityToNull(); + + $this->assertEquals(0, count($sql)); + } + + public function testChangeType() + { + $sql = $this->_doTestChangeType(); + + $this->assertEquals(1, count($sql)); + $this->assertEquals("ALTER TABLE cms_addresses MODIFY (city CLOB NOT NULL)", $sql[0]); + } + + public function testChangeUniqueness() + { + $this->markTestSkipped('Not supported on Postgres-Sql yet.'); + + $sql = $this->_doTestChangeUniqueness(); + + $this->assertEquals(2, count($sql)); + $this->assertEquals("ALTER TABLE cms_addresses ALTER city TYPE VARCHAR(50)", $sql[0]); + $this->assertEquals("ALTER TABLE cms_addresses ALTER city SET NOT NULL", $sql[1]); + } + + public function testChangeLength() + { + $sql = $this->_doTestChangeLength(); + + $this->assertEquals(1, count($sql)); + $this->assertEquals('ALTER TABLE cms_addresses MODIFY (city VARCHAR2(200) NOT NULL)', $sql[0]); + } + + /** + * @group DDC-101 + */ + public function testChangeLengthToNull() + { + $sql = $this->_doTestChangeLengthToNull(); + + $this->assertEquals(1, count($sql)); + $this->assertEquals('ALTER TABLE cms_addresses MODIFY (city VARCHAR2(255) NOT NULL)', $sql[0]); + } + + public function testChangeDecimalLengthPrecision() + { + $sql = $this->_doTestChangeDecimalLengthPrecision(); + + $this->assertEquals(2, count($sql)); + // invalid sql, because not escaped + $this->assertEquals('ALTER TABLE decimal_model CHANGE decimal decimal NUMERIC(10, 2) NOT NULL', $sql[0]); + $this->assertEquals('ALTER TABLE decimal_model CHANGE decimal decimal NUMERIC(10, 2) NOT NULL', $sql[1]); + } + + public function testChangeDecimalLengthScale() + { + $sql = $this->_doTestChangeDecimalLengthScale(); + + $this->assertEquals(2, count($sql)); + // invalid sql, because not escaped + $this->assertEquals('ALTER TABLE decimal_model CHANGE decimal decimal NUMERIC(5, 3) NOT NULL', $sql[0]); + $this->assertEquals('ALTER TABLE decimal_model CHANGE decimal decimal NUMERIC(5, 3) NOT NULL', $sql[1]); + } + + public function testChangeFixed() + { + $sql = $this->_doTestChangeFixed(); + + $this->assertEquals(1, count($sql)); + $this->assertEquals("ALTER TABLE cms_addresses MODIFY (city CHAR(50) NOT NULL)", $sql[0]); + } + + public function testAddIndex() + { + $sql = $this->_doTestAddIndex(); + + $this->assertEquals(1, count($sql)); + $this->assertEquals( + "CREATE INDEX searchCity (city)", + $sql[0] + ); + } + + public function testRemoveField() + { + $sql = $this->_doTestRemoveField(); + + $this->assertEquals(1, count($sql)); + $this->assertEquals("ALTER TABLE cms_addresses DROP COLUMN city", $sql[0]); + } +} \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaTool/PostgresUpdateSchemaTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaTool/PostgresUpdateSchemaTest.php index 6c40e76f5..2c2d40793 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaTool/PostgresUpdateSchemaTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaTool/PostgresUpdateSchemaTest.php @@ -115,11 +115,9 @@ class PostgresUpdateSchemaTest extends UpdateSchemaTestCase { $sql = $this->_doTestChangeFixed(); - $this->assertEquals(1, count($sql)); - $this->assertEquals( - "ALTER TABLE cms_addresses CHANGE city city CHAR(50) NOT NULL", - $sql[0] - ); + $this->assertEquals(2, count($sql)); + $this->assertEquals("ALTER TABLE cms_addresses ALTER city TYPE CHAR(50)", $sql[0]); + $this->assertEquals("ALTER TABLE cms_addresses ALTER city SET NOT NULL", $sql[1]); } public function testAddIndex()