diff --git a/tests/Doctrine/Tests/DBAL/AllTests.php b/tests/Doctrine/Tests/DBAL/AllTests.php index 5d00bdd51..479bb7159 100644 --- a/tests/Doctrine/Tests/DBAL/AllTests.php +++ b/tests/Doctrine/Tests/DBAL/AllTests.php @@ -24,9 +24,10 @@ class AllTests public static function suite() { - $suite = new \Doctrine\Tests\DbalTestSuite('Doctrine Dbal'); + $suite = new \Doctrine\Tests\DbalTestSuite('Doctrine DBAL'); + + $suite->addTestSuite('Doctrine\Tests\DBAL\Platforms\AbstractPlatformTest'); - $suite->addTest(Component\AllTests::suite()); $suite->addTest(Ticket\AllTests::suite()); return $suite; diff --git a/tests/Doctrine/Tests/DBAL/Component/AllTests.php b/tests/Doctrine/Tests/DBAL/Component/AllTests.php deleted file mode 100644 index 3580bad81..000000000 --- a/tests/Doctrine/Tests/DBAL/Component/AllTests.php +++ /dev/null @@ -1,33 +0,0 @@ -addTestSuite('Doctrine\Tests\DBAL\Component\TestTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Dbal_Component_AllTests::main') { - AllTests::main(); -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Component/TestTest.php b/tests/Doctrine/Tests/DBAL/Component/TestTest.php deleted file mode 100644 index bcf69aa91..000000000 --- a/tests/Doctrine/Tests/DBAL/Component/TestTest.php +++ /dev/null @@ -1,13 +0,0 @@ -assertEquals(0, 0); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTest.php new file mode 100644 index 000000000..9dbe3075a --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTest.php @@ -0,0 +1,62 @@ +_config = new \Doctrine\DBAL\Configuration; + $this->_eventManager = new \Doctrine\Common\EventManager; + $options = array( + 'driver' => 'pdo_sqlite', + 'memory' => true + ); + $this->_conn = \Doctrine\DBAL\DriverManager::getConnection($options, $this->_config, $this->_eventManager); + $this->_platform = $this->_conn->getDatabasePlatform(); + $this->_sm = $this->_conn->getSchemaManager(); + } + + public function testGetCreateTableSql() + { + $columns = array( + 'id' => array( + 'type' => new \Doctrine\DBAL\Types\IntegerType, + 'autoincrement' => true + ), + 'test' => array( + 'type' => new \Doctrine\DBAL\Types\VarcharType, + 'length' => 255 + ) + ); + + $options = array( + 'primary' => array('id') + ); + + $sql = $this->_platform->getCreateTableSql('test', $columns, $options); + $this->assertEquals($sql[0], 'CREATE TABLE test (id INTEGER AUTOINCREMENT, test VARCHAR(255))'); + } + + public function testGetCreateConstraintSql() + { + $sql = $this->_platform->getCreateConstraintSql('test', 'constraint_name', array('fields' => array('test' => array()))); + $this->assertEquals($sql, 'ALTER TABLE test ADD CONSTRAINT constraint_name (test)'); + } + + public function testGetCreateIndexSql() + { + $sql = $this->_platform->getCreateIndexSql('test', 'index_name', array('type' => 'unique', 'fields' => array('test', 'test2'))); + $this->assertEquals($sql, 'CREATE UNIQUE INDEX index_name ON test (test, test2)'); + } + + public function testGetCreateForeignKeySql() + { + $sql = $this->_platform->getCreateForeignKeySql('test', array('foreignTable' => 'other_table', 'local' => 'fk_name_id', 'foreign' => 'id')); + $this->assertEquals($sql, 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table(id)'); + } +} \ No newline at end of file