From e4c7fa961e334e0b834efbd0e99ad843c00a256a Mon Sep 17 00:00:00 2001 From: beberlei Date: Sun, 23 May 2010 19:17:42 +0200 Subject: [PATCH] Removed Common and DBAL tests from repository, they are now in their respective projects Removed Common and DBAL tests from repository, they are now in their respective projects --- tests/Doctrine/Tests/AllTests.php | 3 - tests/Doctrine/Tests/Common/AllTests.php | 39 -- .../Tests/Common/Annotations/AllTests.php | 32 - .../Annotations/AnnotationReaderTest.php | 188 ------ .../Tests/Common/Annotations/LexerTest.php | 29 - .../Tests/Common/Annotations/ParserTest.php | 187 ------ .../Doctrine/Tests/Common/Cache/AllTests.php | 34 - .../Tests/Common/Cache/ApcCacheTest.php | 22 - .../Tests/Common/Cache/ArrayCacheTest.php | 15 - .../Doctrine/Tests/Common/Cache/CacheTest.php | 95 --- .../Tests/Common/Cache/MemcacheCacheTest.php | 32 - .../Tests/Common/Cache/XcacheCacheTest.php | 22 - .../Doctrine/Tests/Common/ClassLoaderTest.php | 22 - .../Common/ClassLoaderTest/ClassA.class.php | 6 - .../Common/ClassLoaderTest/ClassB.class.php | 6 - .../Common/ClassLoaderTest/ClassC.class.php | 6 - .../Tests/Common/Collections/AllTests.php | 30 - .../Common/Collections/CollectionTest.php | 172 ----- .../Tests/Common/DoctrineExceptionTest.php | 0 .../Tests/Common/EventManagerTest.php | 90 --- tests/Doctrine/Tests/DBAL/AllTests.php | 73 --- tests/Doctrine/Tests/DBAL/ConnectionTest.php | 118 ---- .../Doctrine/Tests/DBAL/DriverManagerTest.php | 102 --- .../DBAL/Events/MysqlSessionInitTest.php | 33 - .../DBAL/Events/OracleSessionInitTest.php | 33 - .../Tests/DBAL/Functional/AllTests.php | 39 -- .../Tests/DBAL/Functional/ConnectionTest.php | 105 --- .../Tests/DBAL/Functional/DataAccessTest.php | 170 ----- .../Schema/Db2SchemaManagerTest.php | 12 - .../Schema/MySqlSchemaManagerTest.php | 12 - .../Schema/OracleSchemaManagerTest.php | 39 -- .../Schema/PostgreSqlSchemaManagerTest.php | 12 - .../SchemaManagerFunctionalTestCase.php | 397 ------------ .../Schema/SqliteSchemaManagerTest.php | 60 -- .../Tests/DBAL/Functional/WriteTest.php | 122 ---- .../Tests/DBAL/Mocks/MockPlatform.php | 35 - .../Platforms/AbstractPlatformTestCase.php | 145 ----- .../DBAL/Platforms/MsSqlPlatformTest.php | 160 ----- .../DBAL/Platforms/MySqlPlatformTest.php | 169 ----- .../DBAL/Platforms/OraclePlatformTest.php | 189 ------ .../DBAL/Platforms/PostgreSqlPlatformTest.php | 193 ------ .../DBAL/Platforms/SqlitePlatformTest.php | 129 ---- .../Doctrine/Tests/DBAL/Schema/ColumnTest.php | 73 --- .../Tests/DBAL/Schema/ComparatorTest.php | 600 ------------------ .../Doctrine/Tests/DBAL/Schema/IndexTest.php | 43 -- .../Tests/DBAL/Schema/SchemaDiffTest.php | 97 --- .../Doctrine/Tests/DBAL/Schema/SchemaTest.php | 243 ------- .../Doctrine/Tests/DBAL/Schema/TableTest.php | 362 ----------- .../Schema/Visitor/SchemaSqlCollectorTest.php | 81 --- tests/Doctrine/Tests/DBAL/Types/ArrayTest.php | 35 - .../Doctrine/Tests/DBAL/Types/BooleanTest.php | 35 - tests/Doctrine/Tests/DBAL/Types/DateTest.php | 64 -- .../Tests/DBAL/Types/DateTimeTest.php | 37 -- .../Doctrine/Tests/DBAL/Types/DecimalTest.php | 28 - .../Doctrine/Tests/DBAL/Types/IntegerTest.php | 32 - .../Doctrine/Tests/DBAL/Types/ObjectTest.php | 35 - .../Tests/DBAL/Types/SmallIntTest.php | 28 - .../Doctrine/Tests/DBAL/Types/StringTest.php | 31 - tests/Doctrine/Tests/DBAL/Types/TimeTest.php | 36 -- 59 files changed, 5237 deletions(-) delete mode 100644 tests/Doctrine/Tests/Common/AllTests.php delete mode 100644 tests/Doctrine/Tests/Common/Annotations/AllTests.php delete mode 100644 tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php delete mode 100644 tests/Doctrine/Tests/Common/Annotations/LexerTest.php delete mode 100644 tests/Doctrine/Tests/Common/Annotations/ParserTest.php delete mode 100644 tests/Doctrine/Tests/Common/Cache/AllTests.php delete mode 100644 tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php delete mode 100644 tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php delete mode 100644 tests/Doctrine/Tests/Common/Cache/CacheTest.php delete mode 100644 tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php delete mode 100644 tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php delete mode 100644 tests/Doctrine/Tests/Common/ClassLoaderTest.php delete mode 100644 tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php delete mode 100644 tests/Doctrine/Tests/Common/ClassLoaderTest/ClassB.class.php delete mode 100644 tests/Doctrine/Tests/Common/ClassLoaderTest/ClassC.class.php delete mode 100644 tests/Doctrine/Tests/Common/Collections/AllTests.php delete mode 100644 tests/Doctrine/Tests/Common/Collections/CollectionTest.php delete mode 100644 tests/Doctrine/Tests/Common/DoctrineExceptionTest.php delete mode 100644 tests/Doctrine/Tests/Common/EventManagerTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/AllTests.php delete mode 100644 tests/Doctrine/Tests/DBAL/ConnectionTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/DriverManagerTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Functional/AllTests.php delete mode 100644 tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php delete mode 100644 tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Functional/WriteTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php delete mode 100644 tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php delete mode 100644 tests/Doctrine/Tests/DBAL/Platforms/MsSqlPlatformTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Schema/IndexTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Schema/TableTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Types/ArrayTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Types/BooleanTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Types/DateTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Types/DecimalTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Types/IntegerTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Types/ObjectTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Types/StringTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Types/TimeTest.php diff --git a/tests/Doctrine/Tests/AllTests.php b/tests/Doctrine/Tests/AllTests.php index c326c7dd6..032366d04 100644 --- a/tests/Doctrine/Tests/AllTests.php +++ b/tests/Doctrine/Tests/AllTests.php @@ -22,9 +22,6 @@ class AllTests public static function suite() { $suite = new DoctrineTestSuite('Doctrine Tests'); - - $suite->addTest(Common\AllTests::suite()); - $suite->addTest(DBAL\AllTests::suite()); $suite->addTest(ORM\AllTests::suite()); return $suite; diff --git a/tests/Doctrine/Tests/Common/AllTests.php b/tests/Doctrine/Tests/Common/AllTests.php deleted file mode 100644 index db6e81ffa..000000000 --- a/tests/Doctrine/Tests/Common/AllTests.php +++ /dev/null @@ -1,39 +0,0 @@ -addTestSuite('Doctrine\Tests\Common\ClassLoaderTest'); - $suite->addTestSuite('Doctrine\Tests\Common\EventManagerTest'); - - $suite->addTest(Collections\AllTests::suite()); - $suite->addTest(Annotations\AllTests::suite()); - $suite->addTest(Cache\AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Common_AllTests::main') { - AllTests::main(); -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Common/Annotations/AllTests.php b/tests/Doctrine/Tests/Common/Annotations/AllTests.php deleted file mode 100644 index f7dcfbb9e..000000000 --- a/tests/Doctrine/Tests/Common/Annotations/AllTests.php +++ /dev/null @@ -1,32 +0,0 @@ -addTestSuite('Doctrine\Tests\Common\Annotations\LexerTest'); - $suite->addTestSuite('Doctrine\Tests\Common\Annotations\ParserTest'); - $suite->addTestSuite('Doctrine\Tests\Common\Annotations\AnnotationReaderTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Common_Annotations_AllTests::main') { - AllTests::main(); -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php deleted file mode 100644 index 3f3ece930..000000000 --- a/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php +++ /dev/null @@ -1,188 +0,0 @@ -setDefaultAnnotationNamespace('Doctrine\Tests\Common\Annotations\\'); - - $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\DummyClass'); - $classAnnots = $reader->getClassAnnotations($class); - - $annotName = 'Doctrine\Tests\Common\Annotations\DummyAnnotation'; - $this->assertEquals(1, count($classAnnots)); - $this->assertTrue($classAnnots[$annotName] instanceof DummyAnnotation); - $this->assertEquals("hello", $classAnnots[$annotName]->dummyValue); - - $field1Prop = $class->getProperty('field1'); - $propAnnots = $reader->getPropertyAnnotations($field1Prop); - $this->assertEquals(1, count($propAnnots)); - $this->assertTrue($propAnnots[$annotName] instanceof DummyAnnotation); - $this->assertEquals("fieldHello", $propAnnots[$annotName]->dummyValue); - - $getField1Method = $class->getMethod('getField1'); - $methodAnnots = $reader->getMethodAnnotations($getField1Method); - $this->assertEquals(1, count($methodAnnots)); - $this->assertTrue($methodAnnots[$annotName] instanceof DummyAnnotation); - $this->assertEquals(array(1, 2, "three"), $methodAnnots[$annotName]->value); - - $field2Prop = $class->getProperty('field2'); - $propAnnots = $reader->getPropertyAnnotations($field2Prop); - $this->assertEquals(1, count($propAnnots)); - $this->assertTrue(isset($propAnnots['Doctrine\Tests\Common\Annotations\DummyJoinTable'])); - $joinTableAnnot = $propAnnots['Doctrine\Tests\Common\Annotations\DummyJoinTable']; - $this->assertEquals(1, count($joinTableAnnot->joinColumns)); - $this->assertEquals(1, count($joinTableAnnot->inverseJoinColumns)); - $this->assertTrue($joinTableAnnot->joinColumns[0] instanceof DummyJoinColumn); - $this->assertTrue($joinTableAnnot->inverseJoinColumns[0] instanceof DummyJoinColumn); - $this->assertEquals('col1', $joinTableAnnot->joinColumns[0]->name); - $this->assertEquals('col2', $joinTableAnnot->joinColumns[0]->referencedColumnName); - $this->assertEquals('col3', $joinTableAnnot->inverseJoinColumns[0]->name); - $this->assertEquals('col4', $joinTableAnnot->inverseJoinColumns[0]->referencedColumnName); - - $dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation'); - $this->assertEquals('', $dummyAnnot->dummyValue); - $this->assertEquals(array(1, 2, 'three'), $dummyAnnot->value); - - $dummyAnnot = $reader->getPropertyAnnotation($class->getProperty('field1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation'); - $this->assertEquals('fieldHello', $dummyAnnot->dummyValue); - - $classAnnot = $reader->getClassAnnotation($class, 'Doctrine\Tests\Common\Annotations\DummyAnnotation'); - $this->assertEquals('hello', $classAnnot->dummyValue); - } - - public function testClassSyntaxErrorContext() - { - $this->setExpectedException( - "Doctrine\Common\Annotations\AnnotationException", - "[Syntax Error] Expected Doctrine\Common\Annotations\Lexer::T_IDENTIFIER, got ')' at position 18 in class ". - "Doctrine\Tests\Common\Annotations\DummyClassSyntaxError." - ); - - $class = new \ReflectionClass('\Doctrine\Tests\Common\Annotations\DummyClassSyntaxError'); - - $reader = $this->createAnnotationReader(); - $reader->getClassAnnotations($class); - } - - public function testMethodSyntaxErrorContext() - { - $this->setExpectedException( - "Doctrine\Common\Annotations\AnnotationException", - "[Syntax Error] Expected Doctrine\Common\Annotations\Lexer::T_IDENTIFIER, got ')' at position 18 in ". - "method Doctrine\Tests\Common\Annotations\DummyClassMethodSyntaxError::foo()." - ); - - $class = new \ReflectionClass('\Doctrine\Tests\Common\Annotations\DummyClassMethodSyntaxError'); - $method = $class->getMethod('foo'); - - $reader = $this->createAnnotationReader(); - $reader->getMethodAnnotations($method); - } - - public function testPropertySyntaxErrorContext() - { - $this->setExpectedException( - "Doctrine\Common\Annotations\AnnotationException", - "[Syntax Error] Expected Doctrine\Common\Annotations\Lexer::T_IDENTIFIER, got ')' at position 18 in ". - "property Doctrine\Tests\Common\Annotations\DummyClassPropertySyntaxError::\$foo." - ); - - $class = new \ReflectionClass('\Doctrine\Tests\Common\Annotations\DummyClassPropertySyntaxError'); - $property = $class->getProperty('foo'); - - $reader = $this->createAnnotationReader(); - $reader->getPropertyAnnotations($property); - } - - public function createAnnotationReader() - { - $reader = new AnnotationReader(new \Doctrine\Common\Cache\ArrayCache); - $reader->setDefaultAnnotationNamespace('Doctrine\Tests\Common\Annotations\\'); - return $reader; - } -} - -/** - * A description of this class. - * - * @author robo - * @since 2.0 - * @DummyAnnotation(dummyValue="hello") - */ -class DummyClass { - /** - * A nice property. - * - * @var mixed - * @DummyAnnotation(dummyValue="fieldHello") - */ - private $field1; - - /** - * @DummyJoinTable(name="join_table", - * joinColumns={ - * @DummyJoinColumn(name="col1", referencedColumnName="col2") - * }, - * inverseJoinColumns={ - * @DummyJoinColumn(name="col3", referencedColumnName="col4") - * }) - */ - private $field2; - - /** - * Gets the value of field1. - * - * @return mixed - * @DummyAnnotation({1,2,"three"}) - */ - public function getField1() { - } -} - -class DummyAnnotation extends \Doctrine\Common\Annotations\Annotation { - public $dummyValue; -} -class DummyJoinColumn extends \Doctrine\Common\Annotations\Annotation { - public $name; - public $referencedColumnName; -} -class DummyJoinTable extends \Doctrine\Common\Annotations\Annotation { - public $name; - public $joinColumns; - public $inverseJoinColumns; -} - -/** - * @DummyAnnotation(@) - */ -class DummyClassSyntaxError -{ - -} - -class DummyClassMethodSyntaxError -{ - /** - * @DummyAnnotation(@) - */ - public function foo() - { - - } -} - -class DummyClassPropertySyntaxError -{ - /** - * @DummyAnnotation(@) - */ - public $foo; -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Common/Annotations/LexerTest.php b/tests/Doctrine/Tests/Common/Annotations/LexerTest.php deleted file mode 100644 index 01acc8dc5..000000000 --- a/tests/Doctrine/Tests/Common/Annotations/LexerTest.php +++ /dev/null @@ -1,29 +0,0 @@ -setInput("@Name"); - $this->assertNull($lexer->token); - $this->assertNull($lexer->lookahead); - - $this->assertTrue($lexer->moveNext()); - $this->assertNull($lexer->token); - $this->assertEquals('@', $lexer->lookahead['value']); - - $this->assertTrue($lexer->moveNext()); - $this->assertEquals('@', $lexer->token['value']); - $this->assertEquals('Name', $lexer->lookahead['value']); - - $this->assertFalse($lexer->moveNext()); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Common/Annotations/ParserTest.php b/tests/Doctrine/Tests/Common/Annotations/ParserTest.php deleted file mode 100644 index db043f35b..000000000 --- a/tests/Doctrine/Tests/Common/Annotations/ParserTest.php +++ /dev/null @@ -1,187 +0,0 @@ -createTestParser(); - - // Marker annotation - $result = $parser->parse("@Name"); - $annot = $result['Doctrine\Tests\Common\Annotations\Name']; - $this->assertTrue($annot instanceof Name); - $this->assertNull($annot->value); - $this->assertNull($annot->foo); - - // Associative arrays - $result = $parser->parse('@Name(foo={"key1" = "value1"})'); - $annot = $result['Doctrine\Tests\Common\Annotations\Name']; - $this->assertNull($annot->value); - $this->assertTrue(is_array($annot->foo)); - $this->assertTrue(isset($annot->foo['key1'])); - - // Numerical arrays - $result = $parser->parse('@Name({2="foo", 4="bar"})'); - $annot = $result['Doctrine\Tests\Common\Annotations\Name']; - $this->assertTrue(is_array($annot->value)); - $this->assertEquals('foo', $annot->value[2]); - $this->assertEquals('bar', $annot->value[4]); - $this->assertFalse(isset($annot->value[0])); - $this->assertFalse(isset($annot->value[1])); - $this->assertFalse(isset($annot->value[3])); - - // Nested arrays with nested annotations - $result = $parser->parse('@Name(foo={1,2, {"key"=@Name}})'); - $annot = $result['Doctrine\Tests\Common\Annotations\Name']; - - $this->assertTrue($annot instanceof Name); - $this->assertNull($annot->value); - $this->assertEquals(3, count($annot->foo)); - $this->assertEquals(1, $annot->foo[0]); - $this->assertEquals(2, $annot->foo[1]); - $this->assertTrue(is_array($annot->foo[2])); - - $nestedArray = $annot->foo[2]; - $this->assertTrue(isset($nestedArray['key'])); - $this->assertTrue($nestedArray['key'] instanceof Name); - - // Complete docblock - $docblock = <<parse($docblock); - $this->assertEquals(1, count($result)); - $annot = $result['Doctrine\Tests\Common\Annotations\Name']; - $this->assertTrue($annot instanceof Name); - $this->assertEquals("bar", $annot->foo); - $this->assertNull($annot->value); - } - - public function testNamespacedAnnotations() - { - $parser = new Parser; - - $docblock = <<parse($docblock); - $this->assertEquals(1, count($result)); - $annot = $result['Doctrine\Tests\Common\Annotations\Name']; - $this->assertTrue($annot instanceof Name); - $this->assertEquals("bar", $annot->foo); - } - - /** - * @group DDC-77 - */ - public function testAnnotationWithoutClassIsIgnoredWithoutWarning() - { - $parser = new Parser(); - $result = $parser->parse("@param"); - - $this->assertEquals(0, count($result)); - } - - public function testAnnotationDontAcceptSingleQuotes() - { - $this->setExpectedException( - 'Doctrine\Common\Annotations\AnnotationException', - "[Syntax Error] Expected PlainValue, got ''' at position 10." - ); - - $parser = $this->createTestParser(); - $parser->parse("@Name(foo='bar')"); - } - - /** - * @group parse - */ - public function testAnnotationNamespaceAlias() - { - $parser = $this->createTestParser(); - $parser->setAnnotationNamespaceAlias('Doctrine\Tests\Common\Annotations\\', 'alias'); - $docblock = <<parse($docblock); - $this->assertEquals(1, count($result)); - $annot = $result['Doctrine\Tests\Common\Annotations\Name']; - $this->assertTrue($annot instanceof Name); - $this->assertEquals("stuff", $annot->foo); - } - - public function createTestParser() - { - $parser = new Parser(); - $parser->setDefaultAnnotationNamespace('Doctrine\Tests\Common\Annotations\\'); - return $parser; - } - - /** - * @group DDC-78 - */ - public function testSyntaxErrorWithContextDescription() - { - $this->setExpectedException( - 'Doctrine\Common\Annotations\AnnotationException', - "[Syntax Error] Expected PlainValue, got ''' at position 10 ". - "in class \Doctrine\Tests\Common\Annotations\Name" - ); - - $parser = $this->createTestParser(); - $parser->parse("@Name(foo='bar')", "class \Doctrine\Tests\Common\Annotations\Name"); - } - - /** - * @group DDC-183 - */ - public function testSyntaxErrorWithUnknownCharacters() - { - $docblock = <<setInput(trim($docblock, '/ *')); - //var_dump($lexer); - - try { - $parser = $this->createTestParser(); - $result = $parser->parse($docblock); - } catch (Exception $e) { - $this->fail($e->getMessage()); - } - } -} - -class Name extends \Doctrine\Common\Annotations\Annotation { - public $foo; -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Common/Cache/AllTests.php b/tests/Doctrine/Tests/Common/Cache/AllTests.php deleted file mode 100644 index d3e6f4d77..000000000 --- a/tests/Doctrine/Tests/Common/Cache/AllTests.php +++ /dev/null @@ -1,34 +0,0 @@ -addTestSuite('Doctrine\Tests\Common\Cache\CacheTest'); - $suite->addTestSuite('Doctrine\Tests\Common\Cache\ApcCacheTest'); - $suite->addTestSuite('Doctrine\Tests\Common\Cache\ArrayCacheTest'); - $suite->addTestSuite('Doctrine\Tests\Common\Cache\MemcacheCacheTest'); - $suite->addTestSuite('Doctrine\Tests\Common\Cache\XcacheCacheTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Common_Cache_AllTests::main') { - AllTests::main(); -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php b/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php deleted file mode 100644 index f52f5410f..000000000 --- a/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php +++ /dev/null @@ -1,22 +0,0 @@ -markTestSkipped('The ' . __CLASS__ .' requires the use of APC'); - } - } - - protected function _getCacheDriver() - { - return new ApcCache(); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php b/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php deleted file mode 100644 index 1bb2cb4f2..000000000 --- a/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php +++ /dev/null @@ -1,15 +0,0 @@ -_getCacheDriver(); - - // Test save - $cache->save('test_key', 'testing this out'); - - // Test contains to test that save() worked - $this->assertTrue($cache->contains('test_key')); - - // Test fetch - $this->assertEquals('testing this out', $cache->fetch('test_key')); - - // Test delete - $cache->save('test_key2', 'test2'); - $cache->delete('test_key2'); - $this->assertFalse($cache->contains('test_key2')); - } - - public function testDeleteAll() - { - $cache = $this->_getCacheDriver(); - $cache->save('test_key1', '1'); - $cache->save('test_key2', '2'); - $cache->deleteAll(); - - $this->assertFalse($cache->contains('test_key1')); - $this->assertFalse($cache->contains('test_key2')); - } - - public function testDeleteByRegex() - { - $cache = $this->_getCacheDriver(); - $cache->save('test_key1', '1'); - $cache->save('test_key2', '2'); - $cache->deleteByRegex('/test_key[0-9]/'); - - $this->assertFalse($cache->contains('test_key1')); - $this->assertFalse($cache->contains('test_key2')); - } - - public function testDeleteByPrefix() - { - $cache = $this->_getCacheDriver(); - $cache->save('test_key1', '1'); - $cache->save('test_key2', '2'); - $cache->deleteByPrefix('test_key'); - - $this->assertFalse($cache->contains('test_key1')); - $this->assertFalse($cache->contains('test_key2')); - } - - public function testDeleteBySuffix() - { - $cache = $this->_getCacheDriver(); - $cache->save('1test_key', '1'); - $cache->save('2test_key', '2'); - $cache->deleteBySuffix('test_key'); - - $this->assertFalse($cache->contains('1test_key')); - $this->assertFalse($cache->contains('2test_key')); - } - - public function testDeleteByWildcard() - { - $cache = $this->_getCacheDriver(); - $cache->save('test_key1', '1'); - $cache->save('test_key2', '2'); - $cache->delete('test_key*'); - - $this->assertFalse($cache->contains('test_key1')); - $this->assertFalse($cache->contains('test_key2')); - } - - public function testNamespace() - { - $cache = $this->_getCacheDriver(); - $cache->setNamespace('test_'); - $cache->save('key1', 'test'); - $this->assertTrue($cache->contains('key1')); - - $ids = $cache->getIds(); - $this->assertTrue(in_array('test_key1', $ids)); - } - - abstract protected function _getCacheDriver(); -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php b/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php deleted file mode 100644 index b176ce95a..000000000 --- a/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php +++ /dev/null @@ -1,32 +0,0 @@ -_memcache = new \Memcache; - $ok = @$this->_memcache->connect('localhost', 11211); - if (!$ok) { - $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); - } - } else { - $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); - } - } - - protected function _getCacheDriver() - { - $driver = new MemcacheCache(); - $driver->setMemcache($this->_memcache); - return $driver; - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php b/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php deleted file mode 100644 index d70882335..000000000 --- a/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php +++ /dev/null @@ -1,22 +0,0 @@ -markTestSkipped('The ' . __CLASS__ .' requires the use of xcache'); - } - } - - protected function _getCacheDriver() - { - return new XcacheCache(); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Common/ClassLoaderTest.php b/tests/Doctrine/Tests/Common/ClassLoaderTest.php deleted file mode 100644 index e18dff88d..000000000 --- a/tests/Doctrine/Tests/Common/ClassLoaderTest.php +++ /dev/null @@ -1,22 +0,0 @@ -setIncludePath(__DIR__); - $classLoader->setFileExtension('.class.php'); - $classLoader->setNamespaceSeparator('_'); - - $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassA'), true); - $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassB'), true); - $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassC'), true); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php b/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php deleted file mode 100644 index f1b499017..000000000 --- a/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php +++ /dev/null @@ -1,6 +0,0 @@ -addTestSuite('Doctrine\Tests\Common\Collections\CollectionTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Common_Collections_AllTests::main') { - AllTests::main(); -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Common/Collections/CollectionTest.php b/tests/Doctrine/Tests/Common/Collections/CollectionTest.php deleted file mode 100644 index 83bb842f5..000000000 --- a/tests/Doctrine/Tests/Common/Collections/CollectionTest.php +++ /dev/null @@ -1,172 +0,0 @@ -_coll = new \Doctrine\Common\Collections\ArrayCollection; - } - - public function testIssetAndUnset() - { - $this->assertFalse(isset($this->_coll[0])); - $this->_coll->add('testing'); - $this->assertTrue(isset($this->_coll[0])); - unset($this->_coll[0]); - $this->assertFalse(isset($this->_coll[0])); - } - - public function testToString() - { - $this->_coll->add('testing'); - $this->assertTrue(is_string((string) $this->_coll)); - } - - public function testRemovingNonExistentEntryReturnsNull() - { - $this->assertEquals(null, $this->_coll->remove('testing_does_not_exist')); - } - - public function testExists() - { - $this->_coll->add("one"); - $this->_coll->add("two"); - $exists = $this->_coll->exists(function($k, $e) { return $e == "one"; }); - $this->assertTrue($exists); - $exists = $this->_coll->exists(function($k, $e) { return $e == "other"; }); - $this->assertFalse($exists); - } - - public function testMap() - { - $this->_coll->add(1); - $this->_coll->add(2); - $res = $this->_coll->map(function($e) { return $e * 2; }); - $this->assertEquals(array(2, 4), $res->toArray()); - } - - public function testFilter() - { - $this->_coll->add(1); - $this->_coll->add("foo"); - $this->_coll->add(3); - $res = $this->_coll->filter(function($e) { return is_numeric($e); }); - $this->assertEquals(array(0 => 1, 2 => 3), $res->toArray()); - } - - public function testFirstAndLast() - { - $this->_coll->add('one'); - $this->_coll->add('two'); - - $this->assertEquals($this->_coll->first(), 'one'); - $this->assertEquals($this->_coll->last(), 'two'); - } - - public function testArrayAccess() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - - $this->assertEquals($this->_coll[0], 'one'); - $this->assertEquals($this->_coll[1], 'two'); - - unset($this->_coll[0]); - $this->assertEquals($this->_coll->count(), 1); - } - - public function testContainsKey() - { - $this->_coll[5] = 'five'; - $this->assertTrue($this->_coll->containsKey(5)); - } - - public function testContains() - { - $this->_coll[0] = 'test'; - $this->assertTrue($this->_coll->contains('test')); - } - - public function testSearch() - { - $this->_coll[0] = 'test'; - $this->assertEquals(0, $this->_coll->indexOf('test')); - } - - public function testGet() - { - $this->_coll[0] = 'test'; - $this->assertEquals('test', $this->_coll->get(0)); - } - - public function testGetKeys() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - $this->assertEquals(array(0, 1), $this->_coll->getKeys()); - } - - public function testGetValues() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - $this->assertEquals(array('one', 'two'), $this->_coll->getValues()); - } - - public function testCount() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - $this->assertEquals($this->_coll->count(), 2); - $this->assertEquals(count($this->_coll), 2); - } - - public function testForAll() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - $this->assertEquals($this->_coll->forAll(function($k, $e) { return is_string($e); }), true); - $this->assertEquals($this->_coll->forAll(function($k, $e) { return is_array($e); }), false); - } - - public function testPartition() - { - $this->_coll[] = true; - $this->_coll[] = false; - $partition = $this->_coll->partition(function($k, $e) { return $e == true; }); - $this->assertEquals($partition[0][0], true); - $this->assertEquals($partition[1][0], false); - } - - public function testClear() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - $this->_coll->clear(); - $this->assertEquals($this->_coll->isEmpty(), true); - } - - public function testRemove() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - $this->_coll->remove(0); - $this->assertEquals($this->_coll->contains('one'), false); - } - - public function testRemoveElement() - { - $this->_coll[] = 'one'; - $this->_coll[] = 'two'; - $this->_coll->removeElement('two'); - $this->assertEquals($this->_coll->contains('two'), false); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/Common/DoctrineExceptionTest.php b/tests/Doctrine/Tests/Common/DoctrineExceptionTest.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/Doctrine/Tests/Common/EventManagerTest.php b/tests/Doctrine/Tests/Common/EventManagerTest.php deleted file mode 100644 index 1106eeee5..000000000 --- a/tests/Doctrine/Tests/Common/EventManagerTest.php +++ /dev/null @@ -1,90 +0,0 @@ -_eventManager = new EventManager; - $this->_preFooInvoked = false; - $this->_postFooInvoked = false; - } - - public function testInitialState() - { - $this->assertEquals(array(), $this->_eventManager->getListeners()); - $this->assertFalse($this->_eventManager->hasListeners(self::preFoo)); - $this->assertFalse($this->_eventManager->hasListeners(self::postFoo)); - } - - public function testAddEventListener() - { - $this->_eventManager->addEventListener(array('preFoo', 'postFoo'), $this); - $this->assertTrue($this->_eventManager->hasListeners(self::preFoo)); - $this->assertTrue($this->_eventManager->hasListeners(self::postFoo)); - $this->assertEquals(1, count($this->_eventManager->getListeners(self::preFoo))); - $this->assertEquals(1, count($this->_eventManager->getListeners(self::postFoo))); - $this->assertEquals(2, count($this->_eventManager->getListeners())); - } - - public function testDispatchEvent() - { - $this->_eventManager->addEventListener(array('preFoo', 'postFoo'), $this); - $this->_eventManager->dispatchEvent(self::preFoo); - $this->assertTrue($this->_preFooInvoked); - $this->assertFalse($this->_postFooInvoked); - } - - public function testRemoveEventListener() - { - $this->_eventManager->addEventListener(array('preBar'), $this); - $this->assertTrue($this->_eventManager->hasListeners(self::preBar)); - $this->_eventManager->removeEventListener(array('preBar'), $this); - $this->assertFalse($this->_eventManager->hasListeners(self::preBar)); - } - - public function testAddEventSubscriber() - { - $eventSubscriber = new TestEventSubscriber(); - $this->_eventManager->addEventSubscriber($eventSubscriber); - $this->assertTrue($this->_eventManager->hasListeners(self::preFoo)); - $this->assertTrue($this->_eventManager->hasListeners(self::postFoo)); - } - - /* Listener methods */ - - public function preFoo(EventArgs $e) - { - $this->_preFooInvoked = true; - } - - public function postFoo(EventArgs $e) - { - $this->_postFooInvoked = true; - } -} - -class TestEventSubscriber implements \Doctrine\Common\EventSubscriber -{ - public function getSubscribedEvents() - { - return array('preFoo', 'postFoo'); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/AllTests.php b/tests/Doctrine/Tests/DBAL/AllTests.php deleted file mode 100644 index 3ced01e85..000000000 --- a/tests/Doctrine/Tests/DBAL/AllTests.php +++ /dev/null @@ -1,73 +0,0 @@ -addTestSuite('Doctrine\Tests\DBAL\Platforms\SqlitePlatformTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Platforms\MySqlPlatformTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Platforms\PostgreSqlPlatformTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Platforms\MsSqlPlatformTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Platforms\OraclePlatformTest'); - - // Type tests - $suite->addTestSuite('Doctrine\Tests\DBAL\Types\ArrayTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Types\ObjectTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Types\DateTimeTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Types\DateTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Types\TimeTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Types\BooleanTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Types\DecimalTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Types\IntegerTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Types\SmallIntTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Types\StringTest'); - - // Schema tests - $suite->addTestSuite('Doctrine\Tests\DBAL\Schema\ColumnTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Schema\IndexTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Schema\TableTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Schema\SchemaTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Schema\Visitor\SchemaSqlCollectorTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Schema\ComparatorTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Schema\SchemaDiffTest'); - - // Driver manager test - $suite->addTestSuite('Doctrine\Tests\DBAL\DriverManagerTest'); - - // Connection test - $suite->addTestSuite('Doctrine\Tests\DBAL\ConnectionTest'); - - // Events and Listeners - $suite->addTestSuite('Doctrine\Tests\DBAL\Events\OracleSessionInitTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Events\MysqlSessionInitTest'); - - // All Functional DBAL tests - $suite->addTest(Functional\AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Dbal_Platforms_AllTests::main') { - AllTests::main(); -} diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php deleted file mode 100644 index 88eb23286..000000000 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ /dev/null @@ -1,118 +0,0 @@ - 'pdo_mysql', - 'host' => 'localhost', - 'user' => 'root', - 'password' => 'password', - 'port' => '1234' - ); - $this->_conn = \Doctrine\DBAL\DriverManager::getConnection($params); - } - - public function testIsConnected() - { - $this->assertFalse($this->_conn->isConnected()); - } - - public function testNoTransactionActiveByDefault() - { - $this->assertFalse($this->_conn->isTransactionActive()); - } - - public function testCommitWithNoActiveTransaction_ThrowsException() - { - $this->setExpectedException('Doctrine\DBAL\ConnectionException'); - $this->_conn->commit(); - } - - public function testRollbackWithNoActiveTransaction_ThrowsException() - { - $this->setExpectedException('Doctrine\DBAL\ConnectionException'); - $this->_conn->rollback(); - } - - public function testSetRollbackOnlyNoActiveTransaction_ThrowsException() - { - $this->setExpectedException('Doctrine\DBAL\ConnectionException'); - $this->_conn->setRollbackOnly(); - } - - public function testIsRollbackOnlyNoActiveTransaction_ThrowsException() - { - $this->setExpectedException('Doctrine\DBAL\ConnectionException'); - $this->_conn->isRollbackOnly(); - } - - public function testGetConfiguration() - { - $config = $this->_conn->getConfiguration(); - - $this->assertType('Doctrine\DBAL\Configuration', $config); - } - - public function testGetHost() - { - $this->assertEquals('localhost', $this->_conn->getHost()); - } - - public function testGetPort() - { - $this->assertEquals('1234', $this->_conn->getPort()); - } - - public function testGetUsername() - { - $this->assertEquals('root', $this->_conn->getUsername()); - } - - public function testGetPassword() - { - $this->assertEquals('password', $this->_conn->getPassword()); - } - - public function testGetDriver() - { - $this->assertType('Doctrine\DBAL\Driver\PDOMySql\Driver', $this->_conn->getDriver()); - } - - public function testGetEventManager() - { - $this->assertType('Doctrine\Common\EventManager', $this->_conn->getEventManager()); - } - - public function testConnectDispatchEvent() - { - $listenerMock = $this->getMock('ConnectDispatchEventListener', array('postConnect')); - $listenerMock->expects($this->once())->method('postConnect'); - - $eventManager = new EventManager(); - $eventManager->addEventListener(array(Events::postConnect), $listenerMock); - - $driverMock = $this->getMock('Doctrine\DBAL\Driver'); - $driverMock->expects(($this->at(0))) - ->method('connect'); - $platform = new Mocks\MockPlatform(); - - $conn = new Connection(array('platform' => $platform), $driverMock, new Configuration(), $eventManager); - $conn->connect(); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php deleted file mode 100644 index a95c9ad67..000000000 --- a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php +++ /dev/null @@ -1,102 +0,0 @@ - 'test' - ); - $test = \Doctrine\DBAL\DriverManager::getConnection($options); - } - - public function testValidPdoInstance() - { - $options = array( - 'pdo' => new \PDO('sqlite::memory:') - ); - $conn = \Doctrine\DBAL\DriverManager::getConnection($options); - $this->assertEquals('sqlite', $conn->getDatabasePlatform()->getName()); - } - - /** - * @expectedException \Doctrine\DBAL\DBALException - */ - public function testCheckParams() - { - $conn = \Doctrine\DBAL\DriverManager::getConnection(array()); - } - - /** - * @expectedException \Doctrine\DBAL\DBALException - */ - public function testInvalidDriver() - { - $conn = \Doctrine\DBAL\DriverManager::getConnection(array('driver' => 'invalid_driver')); - } - - public function testCustomPlatform() - { - $mockPlatform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $options = array( - 'pdo' => new \PDO('sqlite::memory:'), - 'platform' => $mockPlatform - ); - - $conn = \Doctrine\DBAL\DriverManager::getConnection($options); - $this->assertSame($mockPlatform, $conn->getDatabasePlatform()); - } - - public function testCustomWrapper() - { - $wrapperClass = 'Doctrine\Tests\Mocks\ConnectionMock'; - - $options = array( - 'pdo' => new \PDO('sqlite::memory:'), - 'wrapperClass' => $wrapperClass, - ); - - $conn = \Doctrine\DBAL\DriverManager::getConnection($options); - $this->assertType($wrapperClass, $conn); - } - - public function testInvalidWrapperClass() - { - $this->setExpectedException('\Doctrine\DBAL\DBALException'); - - $options = array( - 'pdo' => new \PDO('sqlite::memory:'), - 'wrapperClass' => 'stdClass', - ); - - $conn = \Doctrine\DBAL\DriverManager::getConnection($options); - } - - public function testInvalidDriverClass() - { - $this->setExpectedException('\Doctrine\DBAL\DBALException'); - - $options = array( - 'driverClass' => 'stdClass' - ); - - $conn = \Doctrine\DBAL\DriverManager::getConnection($options); - } - - public function testValidDriverClass() - { - $options = array( - 'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver', - ); - - $conn = \Doctrine\DBAL\DriverManager::getConnection($options); - $this->assertType('Doctrine\DBAL\Driver\PDOMySql\Driver', $conn->getDriver()); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php deleted file mode 100644 index 1ef47dd53..000000000 --- a/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php +++ /dev/null @@ -1,33 +0,0 @@ -getMock('Doctrine\DBAL\Connection', array(), array(), '', false); - $connectionMock->expects($this->once()) - ->method('executeUpdate') - ->with($this->equalTo("SET NAMES foo COLLATE bar")); - - $eventArgs = new ConnectionEventArgs($connectionMock); - - - $listener = new MysqlSessionInit('foo', 'bar'); - $listener->postConnect($eventArgs); - } - - public function testGetSubscribedEvents() - { - $listener = new MysqlSessionInit(); - $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents()); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php deleted file mode 100644 index 847ed6b15..000000000 --- a/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php +++ /dev/null @@ -1,33 +0,0 @@ -getMock('Doctrine\DBAL\Connection', array(), array(), '', false); - $connectionMock->expects($this->once()) - ->method('executeUpdate') - ->with($this->isType('string')); - - $eventArgs = new ConnectionEventArgs($connectionMock); - - - $listener = new OracleSessionInit(); - $listener->postConnect($eventArgs); - } - - public function testGetSubscribedEvents() - { - $listener = new OracleSessionInit(); - $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents()); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Functional/AllTests.php b/tests/Doctrine/Tests/DBAL/Functional/AllTests.php deleted file mode 100644 index 573177070..000000000 --- a/tests/Doctrine/Tests/DBAL/Functional/AllTests.php +++ /dev/null @@ -1,39 +0,0 @@ -addTestSuite('Doctrine\Tests\DBAL\Functional\Schema\SqliteSchemaManagerTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Functional\Schema\MySqlSchemaManagerTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Functional\Schema\PostgreSqlSchemaManagerTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Functional\Schema\OracleSchemaManagerTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Functional\Schema\Db2SchemaManagerTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Functional\ConnectionTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Functional\DataAccessTest'); - $suite->addTestSuite('Doctrine\Tests\DBAL\Functional\WriteTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Dbal_Functional_AllTests::main') { - AllTests::main(); -} diff --git a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php deleted file mode 100644 index 5cb6d4167..000000000 --- a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php +++ /dev/null @@ -1,105 +0,0 @@ -resetSharedConn(); - parent::setUp(); - } - - public function testGetWrappedConnection() - { - $this->assertType('Doctrine\DBAL\Driver\Connection', $this->_conn->getWrappedConnection()); - } - - public function testCommitWithRollbackOnlyThrowsException() - { - $this->_conn->beginTransaction(); - $this->_conn->setRollbackOnly(); - $this->setExpectedException('Doctrine\DBAL\ConnectionException'); - $this->_conn->commit(); - } - - public function testTransactionNestingBehavior() - { - try { - $this->_conn->beginTransaction(); - $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); - - try { - $this->_conn->beginTransaction(); - $this->assertEquals(2, $this->_conn->getTransactionNestingLevel()); - throw new \Exception; - $this->_conn->commit(); // never reached - } catch (\Exception $e) { - $this->_conn->rollback(); - $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); - //no rethrow - } - $this->assertTrue($this->_conn->isRollbackOnly()); - - $this->_conn->commit(); // should throw exception - $this->fail('Transaction commit after failed nested transaction should fail.'); - } catch (ConnectionException $e) { - $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); - $this->_conn->rollback(); - $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); - } - } - - public function testTransactionBehaviorWithRollback() - { - try { - $this->_conn->beginTransaction(); - $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); - - throw new \Exception; - - $this->_connx->commit(); // never reached - } catch (\Exception $e) { - $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); - $this->_conn->rollback(); - $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); - } - } - - public function testTransactionBehaviour() - { - try { - $this->_conn->beginTransaction(); - $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); - $this->_conn->commit(); - } catch (\Exception $e) { - $this->_conn->rollback(); - $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); - } - - $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); - } - - public function testTransactionalWithException() - { - try { - $this->_conn->transactional(function($conn) { - $conn->executeQuery("select 1"); - throw new \RuntimeException("Ooops!"); - }); - } catch (\RuntimeException $expected) { - $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); - } - } - - public function testTransactional() - { - $this->_conn->transactional(function($conn) { - $conn->executeQuery("select 1"); - }); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php deleted file mode 100644 index 0e9693a14..000000000 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ /dev/null @@ -1,170 +0,0 @@ -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 testPrepareWithBindValue() - { - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $stmt = $this->_conn->prepare($sql); - $this->assertType('Doctrine\DBAL\Statement', $stmt); - - $stmt->bindValue(1, 1); - $stmt->bindValue(2, 'foo'); - $stmt->execute(); - - $row = $stmt->fetch(\PDO::FETCH_ASSOC); - $row = array_change_key_case($row, \CASE_LOWER); - $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row); - } - - public function testPrepareWithBindParam() - { - $paramInt = 1; - $paramStr = 'foo'; - - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $stmt = $this->_conn->prepare($sql); - $this->assertType('Doctrine\DBAL\Statement', $stmt); - - $stmt->bindParam(1, $paramInt); - $stmt->bindParam(2, $paramStr); - $stmt->execute(); - - $row = $stmt->fetch(\PDO::FETCH_ASSOC); - $row = array_change_key_case($row, \CASE_LOWER); - $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row); - } - - public function testPrepareWithFetchAll() - { - $paramInt = 1; - $paramStr = 'foo'; - - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $stmt = $this->_conn->prepare($sql); - $this->assertType('Doctrine\DBAL\Statement', $stmt); - - $stmt->bindParam(1, $paramInt); - $stmt->bindParam(2, $paramStr); - $stmt->execute(); - - $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC); - $rows[0] = array_change_key_case($rows[0], \CASE_LOWER); - $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $rows[0]); - } - - public function testPrepareWithFetchColumn() - { - $paramInt = 1; - $paramStr = 'foo'; - - $sql = "SELECT test_int FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $stmt = $this->_conn->prepare($sql); - $this->assertType('Doctrine\DBAL\Statement', $stmt); - - $stmt->bindParam(1, $paramInt); - $stmt->bindParam(2, $paramStr); - $stmt->execute(); - - $column = $stmt->fetchColumn(); - $this->assertEquals(1, $column); - } - - public function testPrepareWithQuoted() - { - $table = 'fetch_table'; - $paramInt = 1; - $paramStr = 'foo'; - - $sql = "SELECT test_int, test_string FROM " . $this->_conn->quoteIdentifier($table) . " ". - "WHERE test_int = " . $this->_conn->quote($paramInt) . " AND test_string = " . $this->_conn->quote($paramStr); - $stmt = $this->_conn->prepare($sql); - $this->assertType('Doctrine\DBAL\Statement', $stmt); - } - - public function testPrepareWithExecuteParams() - { - $paramInt = 1; - $paramStr = 'foo'; - - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $stmt = $this->_conn->prepare($sql); - $this->assertType('Doctrine\DBAL\Statement', $stmt); - $stmt->execute(array($paramInt, $paramStr)); - - $row = $stmt->fetch(\PDO::FETCH_ASSOC); - $row = array_change_key_case($row, \CASE_LOWER); - $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row); - } - - 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->fetchAssoc($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]); - } - - public function testFetchColumn() - { - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $testInt = $this->_conn->fetchColumn($sql, array(1, 'foo'), 0); - - $this->assertEquals(1, $testInt); - - $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; - $testString = $this->_conn->fetchColumn($sql, array(1, 'foo'), 1); - - $this->assertEquals('foo', $testString); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php deleted file mode 100644 index a567900c9..000000000 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php +++ /dev/null @@ -1,12 +0,0 @@ -markTestSkipped('Foo'); - } - - $username = $GLOBALS['db_username']; - - $query = "GRANT ALL PRIVILEGES TO ".$username; - - $conn = \Doctrine\Tests\TestUtil::getTempConnection(); - $conn->executeUpdate($query); - } - - public function testRenameTable() - { - $this->_sm->tryMethod('DropTable', 'list_tables_test'); - $this->_sm->tryMethod('DropTable', 'list_tables_test_new_name'); - - $this->createTestTable('list_tables_test'); - $this->_sm->renameTable('list_tables_test', 'list_tables_test_new_name'); - - $tables = $this->_sm->listTables(); - - $this->assertHasTable($tables, 'list_tables_test_new_name'); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php deleted file mode 100644 index 967b0ccdc..000000000 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php +++ /dev/null @@ -1,12 +0,0 @@ -_conn->getDatabasePlatform()->getName() !== $dbms) - { - $this->markTestSkipped('The ' . $testClass .' requires the use of ' . $dbms); - } - - #$this->_conn->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); - - $this->_sm = $this->_conn->getSchemaManager(); - } - - public function testListSequences() - { - if(!$this->_conn->getDatabasePlatform()->supportsSequences()) { - $this->markTestSkipped($this->_conn->getDriver()->getName().' does not support sequences.'); - } - - $sequence = new \Doctrine\DBAL\Schema\Sequence('list_sequences_test_seq', 20, 10); - $this->_sm->createSequence($sequence); - - $sequences = $this->_sm->listSequences(); - - $this->assertType('array', $sequences, 'listSequences() should return an array.'); - - $foundSequence = null; - foreach($sequences AS $sequence) { - $this->assertType('Doctrine\DBAL\Schema\Sequence', $sequence, 'Array elements of listSequences() should be Sequence instances.'); - if(strtolower($sequence->getName()) == 'list_sequences_test_seq') { - $foundSequence = $sequence; - } - } - - $this->assertNotNull($foundSequence, "Sequence with name 'list_sequences_test_seq' was not found."); - $this->assertEquals(20, $foundSequence->getAllocationSize(), "Allocation Size is expected to be 20."); - $this->assertEquals(10, $foundSequence->getInitialValue(), "Initial Value is expected to be 10."); - } - - public function testListDatabases() - { - if (!$this->_sm->getDatabasePlatform()->supportsCreateDropDatabase()) { - $this->markTestSkipped('Cannot drop Database client side with this Driver.'); - } - - $this->_sm->dropAndCreateDatabase('test_create_database'); - $databases = $this->_sm->listDatabases(); - - $databases = \array_map('strtolower', $databases); - - $this->assertEquals(true, \in_array('test_create_database', $databases)); - } - - public function testListTables() - { - $this->createTestTable('list_tables_test'); - $tables = $this->_sm->listTables(); - - $this->assertType('array', $tables); - $this->assertTrue(count($tables) > 0, "List Tables has to find at least one table named 'list_tables_test'."); - - $foundTable = false; - foreach ($tables AS $table) { - $this->assertType('Doctrine\DBAL\Schema\Table', $table); - if (strtolower($table->getName()) == 'list_tables_test') { - $foundTable = true; - - $this->assertTrue($table->hasColumn('id')); - $this->assertTrue($table->hasColumn('test')); - $this->assertTrue($table->hasColumn('foreign_key_test')); - } - } - - $this->assertTrue( $foundTable , "The 'list_tables_test' table has to be found."); - } - - public function testListTableColumns() - { - $table = new \Doctrine\DBAL\Schema\Table('list_table_columns'); - $table->addColumn('id', 'integer', array('notnull' => true)); - $table->addColumn('test', 'string', array('length' => 255, 'notnull' => false)); - $table->addColumn('foo', 'text', array('notnull' => true)); - $table->addColumn('bar', 'decimal', array('precision' => 10, 'scale' => 4, 'notnull' => false)); - $table->addColumn('baz1', 'datetime'); - $table->addColumn('baz2', 'time'); - $table->addColumn('baz3', 'date'); - - $this->_sm->dropAndCreateTable($table); - - $columns = $this->_sm->listTableColumns('list_table_columns'); - - $this->assertArrayHasKey('id', $columns); - $this->assertEquals('id', strtolower($columns['id']->getname())); - $this->assertType('Doctrine\DBAL\Types\IntegerType', $columns['id']->gettype()); - $this->assertEquals(false, $columns['id']->getunsigned()); - $this->assertEquals(true, $columns['id']->getnotnull()); - $this->assertEquals(null, $columns['id']->getdefault()); - $this->assertType('array', $columns['id']->getPlatformOptions()); - - $this->assertArrayHasKey('test', $columns); - $this->assertEquals('test', strtolower($columns['test']->getname())); - $this->assertType('Doctrine\DBAL\Types\StringType', $columns['test']->gettype()); - $this->assertEquals(255, $columns['test']->getlength()); - $this->assertEquals(false, $columns['test']->getfixed()); - $this->assertEquals(false, $columns['test']->getnotnull()); - $this->assertEquals(null, $columns['test']->getdefault()); - $this->assertType('array', $columns['test']->getPlatformOptions()); - - $this->assertEquals('foo', strtolower($columns['foo']->getname())); - $this->assertType('Doctrine\DBAL\Types\TextType', $columns['foo']->gettype()); - $this->assertEquals(false, $columns['foo']->getunsigned()); - $this->assertEquals(false, $columns['foo']->getfixed()); - $this->assertEquals(true, $columns['foo']->getnotnull()); - $this->assertEquals(null, $columns['foo']->getdefault()); - $this->assertType('array', $columns['foo']->getPlatformOptions()); - - $this->assertEquals('bar', strtolower($columns['bar']->getname())); - $this->assertType('Doctrine\DBAL\Types\DecimalType', $columns['bar']->gettype()); - $this->assertEquals(null, $columns['bar']->getlength()); - $this->assertEquals(10, $columns['bar']->getprecision()); - $this->assertEquals(4, $columns['bar']->getscale()); - $this->assertEquals(false, $columns['bar']->getunsigned()); - $this->assertEquals(false, $columns['bar']->getfixed()); - $this->assertEquals(false, $columns['bar']->getnotnull()); - $this->assertEquals(null, $columns['bar']->getdefault()); - $this->assertType('array', $columns['bar']->getPlatformOptions()); - - $this->assertEquals('baz1', strtolower($columns['baz1']->getname())); - $this->assertType('Doctrine\DBAL\Types\DateTimeType', $columns['baz1']->gettype()); - $this->assertEquals(true, $columns['baz1']->getnotnull()); - $this->assertEquals(null, $columns['baz1']->getdefault()); - $this->assertType('array', $columns['baz1']->getPlatformOptions()); - - $this->assertEquals('baz2', strtolower($columns['baz2']->getname())); - $this->assertContains($columns['baz2']->gettype()->getName(), array('time', 'date', 'datetime')); - $this->assertEquals(true, $columns['baz2']->getnotnull()); - $this->assertEquals(null, $columns['baz2']->getdefault()); - $this->assertType('array', $columns['baz2']->getPlatformOptions()); - - $this->assertEquals('baz3', strtolower($columns['baz3']->getname())); - $this->assertContains($columns['baz2']->gettype()->getName(), array('time', 'date', 'datetime')); - $this->assertEquals(true, $columns['baz3']->getnotnull()); - $this->assertEquals(null, $columns['baz3']->getdefault()); - $this->assertType('array', $columns['baz3']->getPlatformOptions()); - } - - public function testListTableIndexes() - { - $table = $this->getTestTable('list_table_indexes_test'); - $table->addUniqueIndex(array('test'), 'test_index_name'); - $table->addIndex(array('id', 'test'), 'test_composite_idx'); - - $this->_sm->createTable($table); - - $tableIndexes = $this->_sm->listTableIndexes('list_table_indexes_test'); - - $this->assertEquals(3, count($tableIndexes)); - - $this->assertArrayHasKey('primary', $tableIndexes, 'listTableIndexes() has to return a "primary" array key.'); - $this->assertEquals(array('id'), array_map('strtolower', $tableIndexes['primary']->getColumns())); - $this->assertTrue($tableIndexes['primary']->isUnique()); - $this->assertTrue($tableIndexes['primary']->isPrimary()); - - $this->assertEquals('test_index_name', $tableIndexes['test_index_name']->getName()); - $this->assertEquals(array('test'), array_map('strtolower', $tableIndexes['test_index_name']->getColumns())); - $this->assertTrue($tableIndexes['test_index_name']->isUnique()); - $this->assertFalse($tableIndexes['test_index_name']->isPrimary()); - - $this->assertEquals('test_composite_idx', $tableIndexes['test_composite_idx']->getName()); - $this->assertEquals(array('id', 'test'), array_map('strtolower', $tableIndexes['test_composite_idx']->getColumns())); - $this->assertFalse($tableIndexes['test_composite_idx']->isUnique()); - $this->assertFalse($tableIndexes['test_composite_idx']->isPrimary()); - } - - public function testDropAndCreateIndex() - { - $table = $this->getTestTable('test_create_index'); - $table->addUniqueIndex(array('test'), 'test'); - $this->_sm->dropAndCreateTable($table); - - $this->_sm->dropAndCreateIndex($table->getIndex('test'), $table); - $tableIndexes = $this->_sm->listTableIndexes('test_create_index'); - $this->assertType('array', $tableIndexes); - - $this->assertEquals('test', strtolower($tableIndexes['test']->getName())); - $this->assertEquals(array('test'), array_map('strtolower', $tableIndexes['test']->getColumns())); - $this->assertTrue($tableIndexes['test']->isUnique()); - $this->assertFalse($tableIndexes['test']->isPrimary()); - } - - public function testCreateTableWithForeignKeys() - { - if(!$this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Platform does not support foreign keys.'); - } - - $tableB = $this->getTestTable('test_foreign'); - - $this->_sm->dropAndCreateTable($tableB); - - $tableA = $this->getTestTable('test_create_fk'); - $tableA->addForeignKeyConstraint('test_foreign', array('foreign_key_test'), array('id')); - - $this->_sm->dropAndCreateTable($tableA); - - $fkConstraints = $this->_sm->listTableForeignKeys('test_create_fk'); - $this->assertEquals(1, count($fkConstraints), "Table 'test_create_fk1' has to have one foreign key."); - - $fkConstraint = current($fkConstraints); - $this->assertType('\Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkConstraint); - $this->assertEquals('test_foreign', strtolower($fkConstraint->getForeignTableName())); - $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkConstraint->getColumns())); - $this->assertEquals(array('id'), array_map('strtolower', $fkConstraint->getForeignColumns())); - } - - public function testListForeignKeys() - { - if(!$this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) { - $this->markTestSkipped('Does not support foreign key constraints.'); - } - - $this->createTestTable('test_create_fk1'); - $this->createTestTable('test_create_fk2'); - - $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint( - array('foreign_key_test'), 'test_create_fk2', array('id'), 'foreign_key_test_fk', array('onDelete' => 'CASCADE') - ); - - $this->_sm->createForeignKey($foreignKey, 'test_create_fk1'); - - $fkeys = $this->_sm->listTableForeignKeys('test_create_fk1'); - - $this->assertEquals(1, count($fkeys), "Table 'test_create_fk1' has to have one foreign key."); - - $this->assertType('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]); - $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns())); - $this->assertEquals(array('id'), array_map('strtolower', $fkeys[0]->getForeignColumns())); - $this->assertEquals('test_create_fk2', strtolower($fkeys[0]->getForeignTableName())); - - if($fkeys[0]->hasOption('onDelete')) { - $this->assertEquals('CASCADE', $fkeys[0]->getOption('onDelete')); - } - } - - protected function getCreateExampleViewSql() - { - $this->markTestSkipped('No Create Example View SQL was defined for this SchemaManager'); - } - - public function testCreateSchema() - { - $this->createTestTable('test_table'); - - $schema = $this->_sm->createSchema(); - - $this->assertTrue($schema->hasTable('test_table')); - } - - public function testAlterTableScenario() - { - if(!$this->_sm->getDatabasePlatform()->supportsAlterTable()) { - $this->markTestSkipped('Alter Table is not supported by this platform.'); - } - - $this->createTestTable('alter_table'); - $this->createTestTable('alter_table_foreign'); - - $table = $this->_sm->listTableDetails('alter_table'); - $this->assertTrue($table->hasColumn('id')); - $this->assertTrue($table->hasColumn('test')); - $this->assertTrue($table->hasColumn('foreign_key_test')); - $this->assertEquals(0, count($table->getForeignKeys())); - $this->assertEquals(1, count($table->getIndexes())); - - $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table"); - $tableDiff->addedColumns['foo'] = new \Doctrine\DBAL\Schema\Column('foo', Type::getType('integer')); - $tableDiff->removedColumns['test'] = $table->getColumn('test'); - - $this->_sm->alterTable($tableDiff); - - $table = $this->_sm->listTableDetails('alter_table'); - $this->assertFalse($table->hasColumn('test')); - $this->assertTrue($table->hasColumn('foo')); - - $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table"); - $tableDiff->addedIndexes[] = new \Doctrine\DBAL\Schema\Index('foo_idx', array('foo')); - - $this->_sm->alterTable($tableDiff); - - $table = $this->_sm->listTableDetails('alter_table'); - $this->assertEquals(2, count($table->getIndexes())); - $this->assertTrue($table->hasIndex('foo_idx')); - $this->assertEquals(array('foo'), array_map('strtolower', $table->getIndex('foo_idx')->getColumns())); - $this->assertFalse($table->getIndex('foo_idx')->isPrimary()); - $this->assertFalse($table->getIndex('foo_idx')->isUnique()); - - $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table"); - $tableDiff->changedIndexes[] = new \Doctrine\DBAL\Schema\Index('foo_idx', array('foo', 'foreign_key_test')); - - $this->_sm->alterTable($tableDiff); - - $table = $this->_sm->listTableDetails('alter_table'); - $this->assertEquals(2, count($table->getIndexes())); - $this->assertTrue($table->hasIndex('foo_idx')); - $this->assertEquals(array('foo', 'foreign_key_test'), array_map('strtolower', $table->getIndex('foo_idx')->getColumns())); - - $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table"); - $tableDiff->removedIndexes[] = new \Doctrine\DBAL\Schema\Index('foo_idx', array('foo', 'foreign_key_test')); - $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('foreign_key_test'), 'alter_table_foreign', array('id')); - $tableDiff->addedForeignKeys[] = $fk; - - $this->_sm->alterTable($tableDiff); - $table = $this->_sm->listTableDetails('alter_table'); - - // dont check for index size here, some platforms automatically add indexes for foreign keys. - $this->assertFalse($table->hasIndex('foo_idx')); - - $this->assertEquals(1, count($table->getForeignKeys())); - $fks = $table->getForeignKeys(); - $foreignKey = current($fks); - $this->assertEquals('alter_table_foreign', strtolower($foreignKey->getForeignTableName())); - $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $foreignKey->getColumns())); - $this->assertEquals(array('id'), array_map('strtolower', $foreignKey->getForeignColumns())); - } - - public function testCreateAndListViews() - { - $this->createTestTable('view_test_table'); - - $name = "doctrine_test_view"; - $sql = "SELECT * FROM view_test_table"; - - $view = new \Doctrine\DBAL\Schema\View($name, $sql); - - $this->_sm->dropAndCreateView($view); - - $views = $this->_sm->listViews(); - } - - protected function createTestTable($name = 'test_table', $data = array()) - { - $options = array(); - if (isset($data['options'])) { - $options = $data['options']; - } - - $table = $this->getTestTable($name, $options); - - $this->_sm->dropAndCreateTable($table); - } - - protected function getTestTable($name, $options=array()) - { - $table = new \Doctrine\DBAL\Schema\Table($name, array(), array(), array(), \Doctrine\DBAL\Schema\Table::ID_NONE, $options); - $table->setSchemaConfig($this->_sm->createSchemaConfig()); - $table->setIdGeneratorType(\Doctrine\DBAL\Schema\Table::ID_IDENTITY); - $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 assertHasTable($tables, $tableName) - { - $foundTable = false; - foreach ($tables AS $table) { - $this->assertType('Doctrine\DBAL\Schema\Table', $table, 'No Table instance was found in tables array.'); - if (strtolower($table->getName()) == 'list_tables_test_new_name') { - $foundTable = true; - } - } - $this->assertTrue($foundTable, "Could not find new table"); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php deleted file mode 100644 index d819ff1b7..000000000 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php +++ /dev/null @@ -1,60 +0,0 @@ -_sm->listDatabases(); - } - - public function testCreateAndDropDatabase() - { - $path = dirname(__FILE__).'/test_create_and_drop_sqlite_database.sqlite'; - - $this->_sm->createDatabase($path); - $this->assertEquals(true, file_exists($path)); - $this->_sm->dropDatabase($path); - $this->assertEquals(false, file_exists($path)); - } - - /** - * @expectedException \Exception - */ - // This test is not correct. createSequence expects an object. - // PHPUnit wrapping the PHP error in an exception hides this but it shows up - // when the tests are run in the build (phing). - /*public function testCreateSequence() - { - $this->_sm->createSequence('seqname', 1, 1); - }*/ - - /** - * @expectedException \Exception - */ - // This test is not correct. createForeignKey expects an object. - // PHPUnit wrapping the PHP error in an exception hides this but it shows up - // when the tests are run in the build (phing). - /*public function testCreateForeignKey() - { - $this->_sm->createForeignKey('table', array()); - }*/ - - /** - * @expectedException \Exception - */ - public function testRenameTable() - { - $this->_sm->renameTable('oldname', 'newname'); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php deleted file mode 100644 index 3b2538fee..000000000 --- a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php +++ /dev/null @@ -1,122 +0,0 @@ -addColumn('test_int', 'integer'); - $table->addColumn('test_string', 'string', array('notnull' => false)); - - $sm = $this->_conn->getSchemaManager(); - $sm->createTable($table); - } catch(\Exception $e) { - - } - $this->_conn->executeUpdate('DELETE FROM write_table'); - } - - public function testExecuteUpdate() - { - $sql = "INSERT INTO " . $this->_conn->quoteIdentifier('write_table') . " ( " . - $this->_conn->quoteIdentifier('test_int') . " ) VALUES ( " . $this->_conn->quote(1) . ")"; - $affected = $this->_conn->executeUpdate($sql); - - $this->assertEquals(1, $affected, "executeUpdate() should return the number of affected rows!"); - } - - public function testExecuteUpdateWithTypes() - { - $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; - $affected = $this->_conn->executeUpdate($sql, array(1, 'foo'), array(\PDO::PARAM_INT, \PDO::PARAM_STR)); - - $this->assertEquals(1, $affected, "executeUpdate() should return the number of affected rows!"); - } - - public function testPrepareRowCountReturnsAffectedRows() - { - $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; - $stmt = $this->_conn->prepare($sql); - - $stmt->bindValue(1, 1); - $stmt->bindValue(2, "foo"); - $stmt->execute(); - - $this->assertEquals(1, $stmt->rowCount()); - } - - public function testPrepareWithPdoTypes() - { - $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; - $stmt = $this->_conn->prepare($sql); - - $stmt->bindValue(1, 1, \PDO::PARAM_INT); - $stmt->bindValue(2, "foo", \PDO::PARAM_STR); - $stmt->execute(); - - $this->assertEquals(1, $stmt->rowCount()); - } - - public function testPrepareWithDbalTypes() - { - $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; - $stmt = $this->_conn->prepare($sql); - - $stmt->bindValue(1, 1, Type::getType('integer')); - $stmt->bindValue(2, "foo", Type::getType('string')); - $stmt->execute(); - - $this->assertEquals(1, $stmt->rowCount()); - } - - public function testPrepareWithDbalTypeNames() - { - $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; - $stmt = $this->_conn->prepare($sql); - - $stmt->bindValue(1, 1, 'integer'); - $stmt->bindValue(2, "foo", 'string'); - $stmt->execute(); - - $this->assertEquals(1, $stmt->rowCount()); - } - - public function insertRows() - { - $this->assertEquals(1, $this->_conn->insert('write_table', array('test_int' => 1))); - $this->assertEquals(1, $this->_conn->insert('write_table', array('test_int' => 2))); - } - - public function testInsert() - { - $this->insertRows(); - } - - public function testDelete() - { - $this->insertRows(); - - $this->assertEquals(1, $this->_conn->delete('write_table', array('test_int' => 2))); - $this->assertEquals(1, count($this->_conn->fetchAll('SELECT * FROM write_table'))); - - $this->assertEquals(1, $this->_conn->delete('write_table', array('test_int' => 1))); - $this->assertEquals(0, count($this->_conn->fetchAll('SELECT * FROM write_table'))); - } - - public function testUpdate() - { - $this->insertRows(); - - $this->assertEquals(1, $this->_conn->update('write_table', array('test_int' => 2), array('test_int' => 1))); - $this->assertEquals(2, $this->_conn->update('write_table', array('test_int' => 3), array('test_int' => 2))); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php b/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php deleted file mode 100644 index 95e6b55b4..000000000 --- a/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php +++ /dev/null @@ -1,35 +0,0 @@ -_platform = $this->createPlatform(); - } - - public function testCreateWithNoColumns() - { - $table = new \Doctrine\DBAL\Schema\Table('test'); - - $this->setExpectedException('Doctrine\DBAL\DBALException'); - $sql = $this->_platform->getCreateTableSQL($table); - } - - public function testGeneratesTableCreationSql() - { - $table = new \Doctrine\DBAL\Schema\Table('test'); - $table->addColumn('id', 'integer', array('notnull' => true)); - $table->addColumn('test', 'string', array('notnull' => false, 'length' => 255)); - $table->setPrimaryKey(array('id')); - $table->setIdGeneratorType(\Doctrine\DBAL\Schema\Table::ID_IDENTITY); - - $sql = $this->_platform->getCreateTableSQL($table); - $this->assertEquals($this->getGenerateTableSql(), $sql[0]); - } - - abstract public function getGenerateTableSql(); - - public function testGenerateTableWithMultiColumnUniqueIndex() - { - $table = new \Doctrine\DBAL\Schema\Table('test'); - $table->addColumn('foo', 'string', array('notnull' => false, 'length' => 255)); - $table->addColumn('bar', 'string', array('notnull' => false, 'length' => 255)); - $table->addUniqueIndex(array("foo", "bar")); - - $sql = $this->_platform->getCreateTableSQL($table); - $this->assertEquals($this->getGenerateTableWithMultiColumnUniqueIndexSql(), $sql); - } - - abstract public function getGenerateTableWithMultiColumnUniqueIndexSql(); - - public function testGeneratesIndexCreationSql() - { - $indexDef = new \Doctrine\DBAL\Schema\Index('my_idx', array('user_name', 'last_login')); - - $this->assertEquals( - $this->getGenerateIndexSql(), - $this->_platform->getCreateIndexSQL($indexDef, 'mytable') - ); - } - - abstract public function getGenerateIndexSql(); - - public function testGeneratesUniqueIndexCreationSql() - { - $indexDef = new \Doctrine\DBAL\Schema\Index('index_name', array('test', 'test2'), true); - - $sql = $this->_platform->getCreateIndexSQL($indexDef, 'test'); - $this->assertEquals($this->getGenerateUniqueIndexSql(), $sql); - } - - abstract public function getGenerateUniqueIndexSql(); - - public function testGeneratesForeignKeyCreationSql() - { - $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name_id'), 'other_table', array('id'), ''); - - $sql = $this->_platform->getCreateForeignKeySQL($fk, 'test'); - $this->assertEquals($sql, $this->getGenerateForeignKeySql()); - } - - abstract public function getGenerateForeignKeySql(); - - public function testGeneratesConstraintCreationSql() - { - $idx = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, false); - $sql = $this->_platform->getCreateConstraintSQL($idx, 'test'); - $this->assertEquals($this->getGenerateConstraintUniqueIndexSql(), $sql); - - $pk = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, true); - $sql = $this->_platform->getCreateConstraintSQL($pk, 'test'); - $this->assertEquals($this->getGenerateConstraintPrimaryIndexSql(), $sql); - - $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name'), 'foreign', array('id'), 'constraint_fk'); - $sql = $this->_platform->getCreateConstraintSQL($fk, 'test'); - $this->assertEquals($this->getGenerateConstraintForeignKeySql(), $sql); - } - - public function getGenerateConstraintUniqueIndexSql() - { - return 'ALTER TABLE test ADD CONSTRAINT constraint_name UNIQUE (test)'; - } - - public function getGenerateConstraintPrimaryIndexSql() - { - return 'ALTER TABLE test ADD CONSTRAINT constraint_name PRIMARY KEY (test)'; - } - - public function getGenerateConstraintForeignKeySql() - { - return 'ALTER TABLE test ADD CONSTRAINT constraint_fk FOREIGN KEY (fk_name) REFERENCES foreign (id)'; - } - - abstract public function getGenerateAlterTableSql(); - - public function testGeneratesTableAlterationSql() - { - $expectedSql = $this->getGenerateAlterTableSql(); - - $columnDiff = new \Doctrine\DBAL\Schema\ColumnDiff( - 'bar', new \Doctrine\DBAL\Schema\Column( - 'baz', \Doctrine\DBAL\Types\Type::getType('string'), array('default' => 'def') - ), - array('type', 'notnull', 'default') - ); - - $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('mytable'); - $tableDiff->newName = 'userlist'; - $tableDiff->addedColumns['quota'] = new \Doctrine\DBAL\Schema\Column('quota', \Doctrine\DBAL\Types\Type::getType('integer'), array('notnull' => false)); - $tableDiff->removedColumns['foo'] = new \Doctrine\DBAL\Schema\Column('foo', \Doctrine\DBAL\Types\Type::getType('integer')); - $tableDiff->changedColumns['bar'] = $columnDiff; - - $sql = $this->_platform->getAlterTableSQL($tableDiff); - - $this->assertEquals($expectedSql, $sql); - } - - public function testGetCustomColumnDeclarationSql() - { - $field = array('columnDefinition' => 'MEDIUMINT(6) UNSIGNED'); - $this->assertEquals('foo MEDIUMINT(6) UNSIGNED', $this->_platform->getColumnDeclarationSQL('foo', $field)); - } -} diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MsSqlPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MsSqlPlatformTest.php deleted file mode 100644 index 1302be035..000000000 --- a/tests/Doctrine/Tests/DBAL/Platforms/MsSqlPlatformTest.php +++ /dev/null @@ -1,160 +0,0 @@ -assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); - $this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct'); - $this->assertEquals('(column1 + column2 + column3)', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct'); - } - - public function testGeneratesTransactionsCommands() - { - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED) - ); - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) - ); - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) - ); - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) - ); - } - - public function testGeneratesDDLSnippets() - { - $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL()); - $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar')); - $this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar')); - $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar')); - } - - public function testGeneratesTypeDeclarationForIntegers() - { - $this->assertEquals( - 'INT', - $this->_platform->getIntegerTypeDeclarationSQL(array()) - ); - $this->assertEquals( - 'INT AUTO_INCREMENT', - $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true) - )); - $this->assertEquals( - 'INT AUTO_INCREMENT', - $this->_platform->getIntegerTypeDeclarationSQL( - array('autoincrement' => true, 'primary' => true) - )); - } - - public function testGeneratesTypeDeclarationsForStrings() - { - $this->assertEquals( - 'CHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( - array('length' => 10, 'fixed' => true) - )); - $this->assertEquals( - 'VARCHAR(50)', - $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), - 'Variable string declaration is not correct' - ); - $this->assertEquals( - 'TEXT', - $this->_platform->getVarcharTypeDeclarationSQL(array()), - 'Long string declaration is not correct' - ); - } - - public function testPrefersIdentityColumns() - { - $this->assertTrue($this->_platform->prefersIdentityColumns()); - } - - public function testSupportsIdentityColumns() - { - $this->assertTrue($this->_platform->supportsIdentityColumns()); - } - - public function testDoesNotSupportSavePoints() - { - $this->assertFalse($this->_platform->supportsSavepoints()); - } - - public function getGenerateIndexSql() - { - return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; - } - - public function getGenerateUniqueIndexSql() - { - return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; - } - - public function getGenerateForeignKeySql() - { - return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table(id)'; - } - - public function testModifyLimitQuery() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); - $this->assertEquals('SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 10 * FROM user) AS inner_tbl) AS outer_tbl', $sql); - } - - public function testModifyLimitQueryWithEmptyOffset() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); - $this->assertEquals('SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 10 * FROM user) AS inner_tbl) AS outer_tbl', $sql); - } - - public function testModifyLimitQueryWithAscOrderBy() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10); - $this->assertEquals('SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 10 * FROM user ORDER BY username ASC) AS inner_tbl ORDER BY inner_tbl.u DESC) AS outer_tbl ORDER BY outer_tbl.u ASC', $sql); - } - - public function testModifyLimitQueryWithDescOrderBy() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10); - $this->assertEquals('SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 10 * FROM user ORDER BY username DESC) AS inner_tbl ORDER BY inner_tbl.u ASC) AS outer_tbl ORDER BY outer_tbl.u DESC', $sql); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php deleted file mode 100644 index 8dbeac5db..000000000 --- a/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php +++ /dev/null @@ -1,169 +0,0 @@ -addColumn("Bar", "integer"); - - $sql = $this->_platform->getCreateTableSQL($table); - $this->assertEquals('CREATE TABLE Foo (Bar INT NOT NULL) ENGINE = InnoDB', array_shift($sql)); - } - - public function getGenerateTableSql() - { - return 'CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) ENGINE = InnoDB'; - } - - public function getGenerateTableWithMultiColumnUniqueIndexSql() - { - return array( - 'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL, UNIQUE INDEX test_foo_bar_uniq (foo, bar)) ENGINE = InnoDB' - ); - } - - public function getGenerateAlterTableSql() - { - return array( - "ALTER TABLE mytable RENAME TO userlist, ADD quota INT DEFAULT NULL, DROP foo, CHANGE bar baz VARCHAR(255) DEFAULT 'def' NOT NULL" - ); - } - - public function testGeneratesSqlSnippets() - { - $this->assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); - $this->assertEquals('`', $this->_platform->getIdentifierQuoteCharacter(), 'Quote character is not correct'); - $this->assertEquals('CONCAT(column1, column2, column3)', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation function is not correct'); - } - - public function testGeneratesTransactionsCommands() - { - $this->assertEquals( - 'SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED), - '' - ); - $this->assertEquals( - 'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) - ); - $this->assertEquals( - 'SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) - ); - $this->assertEquals( - 'SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) - ); - } - - - public function testGeneratesDDLSnippets() - { - $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL()); - $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar')); - $this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar')); - $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar')); - } - - public function testGeneratesTypeDeclarationForIntegers() - { - $this->assertEquals( - 'INT', - $this->_platform->getIntegerTypeDeclarationSQL(array()) - ); - $this->assertEquals( - 'INT AUTO_INCREMENT', - $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true) - )); - $this->assertEquals( - 'INT AUTO_INCREMENT', - $this->_platform->getIntegerTypeDeclarationSQL( - array('autoincrement' => true, 'primary' => true) - )); - } - - public function testGeneratesTypeDeclarationForStrings() - { - $this->assertEquals( - 'CHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( - array('length' => 10, 'fixed' => true) - )); - $this->assertEquals( - 'VARCHAR(50)', - $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), - 'Variable string declaration is not correct' - ); - $this->assertEquals( - 'VARCHAR(255)', - $this->_platform->getVarcharTypeDeclarationSQL(array()), - 'Long string declaration is not correct' - ); - } - - public function testPrefersIdentityColumns() - { - $this->assertTrue($this->_platform->prefersIdentityColumns()); - } - - public function testSupportsIdentityColumns() - { - $this->assertTrue($this->_platform->supportsIdentityColumns()); - } - - public function testDoesNotSupportSavePoints() - { - $this->assertFalse($this->_platform->supportsSavepoints()); - } - - public function getGenerateIndexSql() - { - return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; - } - - public function getGenerateUniqueIndexSql() - { - return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; - } - - public function getGenerateForeignKeySql() - { - return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table(id)'; - } - - public function testModifyLimitQuery() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); - $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql); - } - - public function testModifyLimitQueryWithEmptyOffset() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); - $this->assertEquals('SELECT * FROM user LIMIT 10', $sql); - } - - /** - * @group DDC-118 - */ - public function testGetDateTimeTypeDeclarationSql() - { - $this->assertEquals("DATETIME", $this->_platform->getDateTimeTypeDeclarationSQL(array('version' => false))); - $this->assertEquals("TIMESTAMP", $this->_platform->getDateTimeTypeDeclarationSQL(array('version' => true))); - $this->assertEquals("DATETIME", $this->_platform->getDateTimeTypeDeclarationSQL(array())); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php deleted file mode 100644 index 8fb24abf6..000000000 --- a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php +++ /dev/null @@ -1,189 +0,0 @@ -assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); - } - - public function testGeneratesSqlSnippets() - { - $this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct'); - $this->assertEquals('column1 || column2 || column3', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct'); - } - - public function testGeneratesTransactionsCommands() - { - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED) - ); - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) - ); - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) - ); - $this->assertEquals( - 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) - ); - } - - /** - * @expectedException Doctrine\DBAL\DBALException - */ - public function testShowDatabasesThrowsException() - { - $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL()); - } - - /** - * @expectedException Doctrine\DBAL\DBALException - */ - public function testCreateDatabaseThrowsException() - { - $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar')); - } - - public function testDropDatabaseThrowsException() - { - $this->assertEquals('DROP USER foobar CASCADE', $this->_platform->getDropDatabaseSQL('foobar')); - } - - public function testDropTable() - { - $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar')); - } - - public function testGeneratesTypeDeclarationForIntegers() - { - $this->assertEquals( - 'NUMBER(10)', - $this->_platform->getIntegerTypeDeclarationSQL(array()) - ); - $this->assertEquals( - 'NUMBER(10)', - $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true) - )); - $this->assertEquals( - 'NUMBER(10)', - $this->_platform->getIntegerTypeDeclarationSQL( - array('autoincrement' => true, 'primary' => true) - )); - } - - public function testGeneratesTypeDeclarationsForStrings() - { - $this->assertEquals( - 'CHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( - array('length' => 10, 'fixed' => true) - )); - $this->assertEquals( - 'VARCHAR2(50)', - $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), - 'Variable string declaration is not correct' - ); - $this->assertEquals( - 'VARCHAR2(4000)', - $this->_platform->getVarcharTypeDeclarationSQL(array()), - 'Long string declaration is not correct' - ); - } - - public function testPrefersIdentityColumns() - { - $this->assertFalse($this->_platform->prefersIdentityColumns()); - } - - public function testSupportsIdentityColumns() - { - $this->assertFalse($this->_platform->supportsIdentityColumns()); - } - - public function testSupportsSavePoints() - { - $this->assertTrue($this->_platform->supportsSavepoints()); - } - - public function getGenerateIndexSql() - { - return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; - } - - public function getGenerateUniqueIndexSql() - { - return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; - } - - public function getGenerateForeignKeySql() - { - return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table(id)'; - } - - public function testModifyLimitQuery() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); - $this->assertEquals('SELECT a.* FROM (SELECT * FROM user) a WHERE ROWNUM <= 10', $sql); - } - - public function testModifyLimitQueryWithEmptyOffset() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); - $this->assertEquals('SELECT a.* FROM (SELECT * FROM user) a WHERE ROWNUM <= 10', $sql); - } - - public function testModifyLimitQueryWithAscOrderBy() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10); - $this->assertEquals('SELECT a.* FROM (SELECT * FROM user ORDER BY username ASC) a WHERE ROWNUM <= 10', $sql); - } - - public function testModifyLimitQueryWithDescOrderBy() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10); - $this->assertEquals('SELECT a.* FROM (SELECT * FROM user ORDER BY username DESC) a WHERE ROWNUM <= 10', $sql); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php deleted file mode 100644 index 38681b3e1..000000000 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php +++ /dev/null @@ -1,193 +0,0 @@ - 'CASCADE') - ); - $this->assertEquals( - "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE", - $this->_platform->getForeignKeyDeclarationSQL($foreignKey) - ); - } - - public function testGeneratesSqlSnippets() - { - $this->assertEquals('SIMILAR TO', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); - $this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct'); - $this->assertEquals('column1 || column2 || column3', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct'); - $this->assertEquals('SUBSTR(column, 5)', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct'); - $this->assertEquals('SUBSTR(column, 0, 5)', $this->_platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct'); - } - - public function testGeneratesTransactionCommands() - { - $this->assertEquals( - 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED) - ); - $this->assertEquals( - 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) - ); - $this->assertEquals( - 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL REPEATABLE READ', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) - ); - $this->assertEquals( - 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) - ); - } - - public function testGeneratesDDLSnippets() - { - $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar')); - $this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar')); - $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar')); - } - - public function testGeneratesTypeDeclarationForIntegers() - { - $this->assertEquals( - 'INT', - $this->_platform->getIntegerTypeDeclarationSQL(array()) - ); - $this->assertEquals( - 'SERIAL', - $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true) - )); - $this->assertEquals( - 'SERIAL', - $this->_platform->getIntegerTypeDeclarationSQL( - array('autoincrement' => true, 'primary' => true) - )); - } - - public function testGeneratesTypeDeclarationForStrings() - { - $this->assertEquals( - 'CHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( - array('length' => 10, 'fixed' => true)) - ); - $this->assertEquals( - 'VARCHAR(50)', - $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), - 'Variable string declaration is not correct' - ); - $this->assertEquals( - 'TEXT', - $this->_platform->getVarcharTypeDeclarationSQL(array()), - 'Long string declaration is not correct' - ); - } - - public function getGenerateUniqueIndexSql() - { - return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; - } - - public function testGeneratesSequenceSqlCommands() - { - $sequence = new \Doctrine\DBAL\Schema\Sequence('myseq', 20, 1); - $this->assertEquals( - 'CREATE SEQUENCE myseq INCREMENT BY 20 MINVALUE 1 START 1', - $this->_platform->getCreateSequenceSQL($sequence) - ); - $this->assertEquals( - 'DROP SEQUENCE myseq', - $this->_platform->getDropSequenceSQL('myseq') - ); - $this->assertEquals( - "SELECT NEXTVAL('myseq')", - $this->_platform->getSequenceNextValSQL('myseq') - ); - } - - public function testDoesNotPreferIdentityColumns() - { - $this->assertFalse($this->_platform->prefersIdentityColumns()); - } - - public function testPrefersSequences() - { - $this->assertTrue($this->_platform->prefersSequences()); - } - - public function testSupportsIdentityColumns() - { - $this->assertTrue($this->_platform->supportsIdentityColumns()); - } - - public function testSupportsSavePoints() - { - $this->assertTrue($this->_platform->supportsSavepoints()); - } - - public function testSupportsSequences() - { - $this->assertTrue($this->_platform->supportsSequences()); - } - - public function testModifyLimitQuery() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); - $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql); - } - - public function testModifyLimitQueryWithEmptyOffset() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); - $this->assertEquals('SELECT * FROM user LIMIT 10', $sql); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php deleted file mode 100644 index fae5538e3..000000000 --- a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php +++ /dev/null @@ -1,129 +0,0 @@ -assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); - $this->assertEquals('SUBSTR(column, 5, LENGTH(column))', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct'); - $this->assertEquals('SUBSTR(column, 0, 5)', $this->_platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct'); - } - - public function testGeneratesTransactionCommands() - { - $this->assertEquals( - 'PRAGMA read_uncommitted = 0', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED) - ); - $this->assertEquals( - 'PRAGMA read_uncommitted = 1', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) - ); - $this->assertEquals( - 'PRAGMA read_uncommitted = 1', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) - ); - $this->assertEquals( - 'PRAGMA read_uncommitted = 1', - $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) - ); - } - - public function testPrefersIdentityColumns() - { - $this->assertTrue($this->_platform->prefersIdentityColumns()); - } - - public function testGeneratesTypeDeclarationForIntegers() - { - $this->assertEquals( - 'INTEGER', - $this->_platform->getIntegerTypeDeclarationSQL(array()) - ); - $this->assertEquals( - 'INTEGER AUTOINCREMENT', - $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)) - ); - $this->assertEquals( - 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getIntegerTypeDeclarationSQL( - array('autoincrement' => true, 'primary' => true)) - ); - } - - public function testGeneratesTypeDeclarationForStrings() - { - $this->assertEquals( - 'CHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( - array('length' => 10, 'fixed' => true)) - ); - $this->assertEquals( - 'VARCHAR(50)', - $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), - 'Variable string declaration is not correct' - ); - $this->assertEquals( - 'TEXT', - $this->_platform->getVarcharTypeDeclarationSQL(array()), - 'Long string declaration is not correct' - ); - } - - public function getGenerateIndexSql() - { - return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; - } - - public function getGenerateUniqueIndexSql() - { - return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; - } - - public function getGenerateForeignKeySql() - { - $this->markTestSkipped('SQLite does not support ForeignKeys.'); - } - - public function testModifyLimitQuery() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); - $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql); - } - - public function testModifyLimitQueryWithEmptyOffset() - { - $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); - $this->assertEquals('SELECT * FROM user LIMIT 10', $sql); - } - - public function getGenerateAlterTableSql() - { - $this->markTestSkipped('SQlite does not support ALTER Table.'); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php b/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php deleted file mode 100644 index 4b6cd85a4..000000000 --- a/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php +++ /dev/null @@ -1,73 +0,0 @@ -createColumn(); - - $this->assertEquals("foo", $column->getName()); - $this->assertSame(Type::getType('string'), $column->getType()); - - $this->assertEquals(200, $column->getLength()); - $this->assertEquals(5, $column->getPrecision()); - $this->assertEquals(2, $column->getScale()); - $this->assertTrue($column->getUnsigned()); - $this->assertFalse($column->getNotNull()); - $this->assertTrue($column->getFixed()); - $this->assertEquals("baz", $column->getDefault()); - - $this->assertEquals(array('foo' => 'bar'), $column->getPlatformOptions()); - $this->assertTrue($column->hasPlatformOption('foo')); - $this->assertEquals('bar', $column->getPlatformOption('foo')); - $this->assertFalse($column->hasPlatformOption('bar')); - } - - public function testToArray() - { - $expected = array( - 'name' => 'foo', - 'type' => Type::getType('string'), - 'default' => 'baz', - 'notnull' => false, - 'length' => 200, - 'precision' => 5, - 'scale' => 2, - 'fixed' => true, - 'unsigned' => true, - 'columnDefinition' => null, - 'foo' => 'bar', - ); - - $this->assertEquals($expected, $this->createColumn()->toArray()); - } - - /** - * @return Column - */ - public function createColumn() - { - $options = array( - 'length' => 200, - 'precision' => 5, - 'scale' => 2, - 'unsigned' => true, - 'notnull' => false, - 'fixed' => true, - 'default' => 'baz', - 'platformOptions' => array('foo' => 'bar'), - ); - - $string = Type::getType('string'); - return new Column("foo", $string, $options); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php deleted file mode 100644 index 4433ef924..000000000 --- a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php +++ /dev/null @@ -1,600 +0,0 @@ -. - */ - -namespace Doctrine\Tests\DBAL\Schema; - -require_once __DIR__ . '/../../TestInit.php'; - -use Doctrine\DBAL\Schema\Schema, - Doctrine\DBAL\Schema\Table, - Doctrine\DBAL\Schema\Column, - Doctrine\DBAL\Schema\Index, - Doctrine\DBAL\Schema\Sequence, - Doctrine\DBAL\Schema\SchemaDiff, - Doctrine\DBAL\Schema\TableDiff, - Doctrine\DBAL\Schema\Comparator, - Doctrine\DBAL\Types\Type, - Doctrine\DBAL\Schema\ForeignKeyConstraint; - -/** - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. - * @license http://ez.no/licenses/new_bsd New BSD License - * @since 2.0 - * @version $Revision$ - * @author Benjamin Eberlei - */ -class ComparatorTest extends \PHPUnit_Framework_TestCase -{ - public function testCompareSame1() - { - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer' ) ), - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer') ), - ) - ), - ) ); - - $this->assertEquals(new SchemaDiff(), Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareSame2() - { - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - ) - ), - ) ); - $this->assertEquals(new SchemaDiff(), Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareMissingTable() - { - $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig; - $table = new Table('bugdb', array ('integerfield1' => new Column('integerfield1', Type::getType('integer')))); - $table->setSchemaConfig($schemaConfig); - - $schema1 = new Schema( array($table), array(), $schemaConfig ); - $schema2 = new Schema( array(), array(), $schemaConfig ); - - $expected = new SchemaDiff( array(), array(), array('bugdb' => $table) ); - - $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareNewTable() - { - $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig; - $table = new Table('bugdb', array ('integerfield1' => new Column('integerfield1', Type::getType('integer')))); - $table->setSchemaConfig($schemaConfig); - - $schema1 = new Schema( array(), array(), $schemaConfig ); - $schema2 = new Schema( array($table), array(), $schemaConfig ); - - $expected = new SchemaDiff( array('bugdb' => $table), array(), array() ); - $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareMissingField() - { - $missingColumn = new Column('integerfield1', Type::getType('integer')); - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => $missingColumn, - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ) - ), - ) ); - - $expected = new SchemaDiff ( array(), - array ( - 'bugdb' => new TableDiff( 'bugdb', array(), array(), - array ( - 'integerfield1' => $missingColumn, - ) - ) - ) - ); - $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareNewField() - { - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ) - ), - ) ); - - $expected = new SchemaDiff ( array(), - array ( - 'bugdb' => new TableDiff ('bugdb', - array ( - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ) - ), - ) - ); - $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareChangedColumns_ChangeType() - { - $column1 = new Column('charfield1', Type::getType('string')); - $column2 = new Column('charfield1', Type::getType('integer')); - - $c = new Comparator(); - $this->assertEquals(array('type'), $c->diffColumn($column1, $column2)); - $this->assertEquals(array(), $c->diffColumn($column1, $column1)); - } - - public function testCompareRemovedIndex() - { - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ), - array ( - 'primary' => new Index('primary', - array( - 'integerfield1' - ), - true - ) - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ) - ), - ) ); - - $expected = new SchemaDiff ( array(), - array ( - 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), array(), array(), - array ( - 'primary' => new Index('primary', - array( - 'integerfield1' - ), - true - ) - ) - ), - ) - ); - $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareNewIndex() - { - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ), - array ( - 'primary' => new Index('primary', - array( - 'integerfield1' - ), - true - ) - ) - ), - ) ); - - $expected = new SchemaDiff ( array(), - array ( - 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), - array ( - 'primary' => new Index('primary', - array( - 'integerfield1' - ), - true - ) - ) - ), - ) - ); - $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); - } - - public function testCompareChangedIndex() - { - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ), - array ( - 'primary' => new Index('primary', - array( - 'integerfield1' - ), - true - ) - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ), - array ( - 'primary' => new Index('primary', - array('integerfield1', 'integerfield2'), - true - ) - ) - ), - ) ); - - $expected = new SchemaDiff ( array(), - array ( - 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), array(), - array ( - 'primary' => new Index('primary', - array( - 'integerfield1', - 'integerfield2' - ), - true - ) - ) - ), - ) - ); - $actual = Comparator::compareSchemas( $schema1, $schema2 ); - $this->assertEquals($expected, $actual); - } - - public function testCompareChangedIndexFieldPositions() - { - $schema1 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ), - array ( - 'primary' => new Index('primary', array('integerfield1', 'integerfield2'), true) - ) - ), - ) ); - $schema2 = new Schema( array( - 'bugdb' => new Table('bugdb', - array ( - 'integerfield1' => new Column('integerfield1', Type::getType('integer')), - 'integerfield2' => new Column('integerfield2', Type::getType('integer')), - ), - array ( - 'primary' => new Index('primary', array('integerfield2', 'integerfield1'), true) - ) - ), - ) ); - - $expected = new SchemaDiff ( array(), - array ( - 'bugdb' => new TableDiff('bugdb', array(), array(), array(), array(), - array ( - 'primary' => new Index('primary', array('integerfield2', 'integerfield1'), true) - ) - ), - ) - ); - $actual = Comparator::compareSchemas( $schema1, $schema2 ); - $this->assertEquals($expected, $actual); - } - - public function testCompareSequences() - { - $seq1 = new Sequence('foo', 1, 1); - $seq2 = new Sequence('foo', 1, 2); - $seq3 = new Sequence('foo', 2, 1); - - $c = new Comparator(); - - $this->assertTrue($c->diffSequence($seq1, $seq2)); - $this->assertTrue($c->diffSequence($seq1, $seq3)); - } - - public function testRemovedSequence() - { - $schema1 = new Schema(); - $seq = $schema1->createSequence('foo'); - - $schema2 = new Schema(); - - $c = new Comparator(); - $diffSchema = $c->compare($schema1, $schema2); - - $this->assertEquals(1, count($diffSchema->removedSequences)); - $this->assertSame($seq, $diffSchema->removedSequences[0]); - } - - public function testAddedSequence() - { - $schema1 = new Schema(); - - $schema2 = new Schema(); - $seq = $schema2->createSequence('foo'); - - $c = new Comparator(); - $diffSchema = $c->compare($schema1, $schema2); - - $this->assertEquals(1, count($diffSchema->newSequences)); - $this->assertSame($seq, $diffSchema->newSequences[0]); - } - - public function testTableAddForeignKey() - { - $tableForeign = new Table("bar"); - $tableForeign->addColumn('id', 'integer'); - - $table1 = new Table("foo"); - $table1->addColumn('fk', 'integer'); - - $table2 = new Table("foo"); - $table2->addColumn('fk', 'integer'); - $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id')); - - $c = new Comparator(); - $tableDiff = $c->diffTable($table1, $table2); - - $this->assertType('Doctrine\DBAL\Schema\TableDiff', $tableDiff); - $this->assertEquals(1, count($tableDiff->addedForeignKeys)); - } - - public function testTableRemoveForeignKey() - { - $tableForeign = new Table("bar"); - $tableForeign->addColumn('id', 'integer'); - - $table1 = new Table("foo"); - $table1->addColumn('fk', 'integer'); - - $table2 = new Table("foo"); - $table2->addColumn('fk', 'integer'); - $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id')); - - $c = new Comparator(); - $tableDiff = $c->diffTable($table2, $table1); - - $this->assertType('Doctrine\DBAL\Schema\TableDiff', $tableDiff); - $this->assertEquals(1, count($tableDiff->removedForeignKeys)); - } - - public function testTableUpdateForeignKey() - { - $tableForeign = new Table("bar"); - $tableForeign->addColumn('id', 'integer'); - - $table1 = new Table("foo"); - $table1->addColumn('fk', 'integer'); - $table1->addForeignKeyConstraint($tableForeign, array('fk'), array('id')); - - $table2 = new Table("foo"); - $table2->addColumn('fk', 'integer'); - $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'), array('onUpdate' => 'CASCADE')); - - $c = new Comparator(); - $tableDiff = $c->diffTable($table1, $table2); - - $this->assertType('Doctrine\DBAL\Schema\TableDiff', $tableDiff); - $this->assertEquals(1, count($tableDiff->changedForeignKeys)); - } - - public function testTablesCaseInsensitive() - { - $schemaA = new Schema(); - $schemaA->createTable('foo'); - $schemaA->createTable('bAr'); - $schemaA->createTable('BAZ'); - $schemaA->createTable('new'); - - $schemaB = new Schema(); - $schemaB->createTable('FOO'); - $schemaB->createTable('bar'); - $schemaB->createTable('Baz'); - $schemaB->createTable('old'); - - $c = new Comparator(); - $diff = $c->compare($schemaA, $schemaB); - - $this->assertSchemaTableChangeCount($diff, 1, 0, 1); - } - - public function testSequencesCaseInsenstive() - { - $schemaA = new Schema(); - $schemaA->createSequence('foo'); - $schemaA->createSequence('BAR'); - $schemaA->createSequence('Baz'); - $schemaA->createSequence('new'); - - $schemaB = new Schema(); - $schemaB->createSequence('FOO'); - $schemaB->createSequence('Bar'); - $schemaB->createSequence('baz'); - $schemaB->createSequence('old'); - - $c = new Comparator(); - $diff = $c->compare($schemaA, $schemaB); - - $this->assertSchemaSequenceChangeCount($diff, 1, 0, 1); - } - - public function testCompareColumnCompareCaseInsensitive() - { - $tableA = new Table("foo"); - $tableA->addColumn('id', 'integer'); - - $tableB = new Table("foo"); - $tableB->addColumn('ID', 'integer'); - - $c = new Comparator(); - $tableDiff = $c->diffTable($tableA, $tableB); - - $this->assertFalse($tableDiff); - } - - public function testCompareIndexBasedOnPropertiesNotName() - { - $tableA = new Table("foo"); - $tableA->addColumn('id', 'integer'); - $tableA->addIndex(array("id"), "foo_bar_idx"); - - $tableB = new Table("foo"); - $tableB->addColumn('ID', 'integer'); - $tableB->addIndex(array("id"), "bar_foo_idx"); - - $c = new Comparator(); - $tableDiff = $c->diffTable($tableA, $tableB); - - $this->assertFalse($tableDiff); - } - - public function testCompareForeignKeyBasedOnPropertiesNotName() - { - $tableA = new Table("foo"); - $tableA->addColumn('id', 'integer'); - $tableA->addNamedForeignKeyConstraint('foo_constraint', 'bar', array('id'), array('id')); - - $tableB = new Table("foo"); - $tableB->addColumn('ID', 'integer'); - $tableB->addNamedForeignKeyConstraint('bar_constraint', 'bar', array('id'), array('id')); - - $c = new Comparator(); - $tableDiff = $c->diffTable($tableA, $tableB); - - $this->assertFalse($tableDiff); - } - - public function testCompareForeignKey_RestrictNoAction_AreTheSame() - { - $fk1 = new ForeignKeyConstraint(array("foo"), "bar", array("baz"), "fk1", array('onDelete' => 'NO ACTION')); - $fk2 = new ForeignKeyConstraint(array("foo"), "bar", array("baz"), "fk1", array('onDelete' => 'RESTRICT')); - - $c = new Comparator(); - $this->assertFalse($c->diffForeignKey($fk1, $fk2)); - } - - public function testDetectRenameColumn() - { - $tableA = new Table("foo"); - $tableA->addColumn('foo', 'integer'); - - $tableB = new Table("foo"); - $tableB->addColumn('bar', 'integer'); - - $c = new Comparator(); - $tableDiff = $c->diffTable($tableA, $tableB); - - $this->assertEquals(0, count($tableDiff->addedColumns)); - $this->assertEquals(0, count($tableDiff->removedColumns)); - $this->assertArrayHasKey('foo', $tableDiff->renamedColumns); - $this->assertEquals('bar', $tableDiff->renamedColumns['foo']->getName()); - } - - /** - * @param SchemaDiff $diff - * @param int $newTableCount - * @param int $changeTableCount - * @param int $removeTableCount - */ - public function assertSchemaTableChangeCount($diff, $newTableCount=0, $changeTableCount=0, $removeTableCount=0) - { - $this->assertEquals($newTableCount, count($diff->newTables)); - $this->assertEquals($changeTableCount, count($diff->changedTables)); - $this->assertEquals($removeTableCount, count($diff->removedTables)); - } - - /** - * @param SchemaDiff $diff - * @param int $newSequenceCount - * @param int $changeSequenceCount - * @param int $changeSequenceCount - */ - public function assertSchemaSequenceChangeCount($diff, $newSequenceCount=0, $changeSequenceCount=0, $removeSequenceCount=0) - { - $this->assertEquals($newSequenceCount, count($diff->newSequences), "Expected number of new sequences is wrong."); - $this->assertEquals($changeSequenceCount, count($diff->changedSequences), "Expected number of changed sequences is wrong."); - $this->assertEquals($removeSequenceCount, count($diff->removedSequences), "Expected number of removed sequences is wrong."); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php b/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php deleted file mode 100644 index 338fbedc8..000000000 --- a/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php +++ /dev/null @@ -1,43 +0,0 @@ -createIndex(); - $this->assertEquals("foo", $idx->getName()); - $columns = $idx->getColumns(); - $this->assertEquals(2, count($columns)); - $this->assertEquals(array("bar", "baz"), $columns); - $this->assertFalse($idx->isUnique()); - $this->assertFalse($idx->isPrimary()); - } - - public function testCreatePrimary() - { - $idx = $this->createIndex(false, true); - $this->assertTrue($idx->isUnique()); - $this->assertTrue($idx->isPrimary()); - } - - public function testCreateUnique() - { - $idx = $this->createIndex(true, false); - $this->assertTrue($idx->isUnique()); - $this->assertFalse($idx->isPrimary()); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php deleted file mode 100644 index ecffaf5d1..000000000 --- a/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php +++ /dev/null @@ -1,97 +0,0 @@ -createSchemaDiff(); - $platform = $this->createPlatform(); - - $sql = $diff->toSql($platform); - - $expected = array('drop_orphan_fk', 'drop_seq', 'create_seq', 'drop_seq', 'create_seq', 'create_table', 'drop_table', 'alter_table'); - - $this->assertEquals($expected, $sql); - } - - public function testSchemaDiffToSaveSql() - { - $diff = $this->createSchemaDiff(); - $platform = $this->createPlatform(1, 0, 0); - - $sql = $diff->toSaveSql($platform); - - $expected = array('drop_seq', 'create_seq', 'create_seq', 'create_table', 'alter_table'); - - $this->assertEquals($expected, $sql); - } - - public function createPlatform($dropSequenceCount=2, $dropTableCount=1, $dropOrphanedFkCount=1) - { - $platform = $this->getMock('Doctrine\Tests\DBAL\Mocks\MockPlatform'); - $platform->expects($this->exactly($dropSequenceCount)) - ->method('getDropSequenceSql') - ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence')) - ->will($this->returnValue('drop_seq')); - $platform->expects($this->exactly(2)) - ->method('getCreateSequenceSql') - ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence')) - ->will($this->returnValue('create_seq')); - if ($dropTableCount > 0) { - $platform->expects($this->exactly($dropTableCount)) - ->method('getDropTableSql') - ->with($this->isInstanceof('Doctrine\DBAL\Schema\Table')) - ->will($this->returnValue('drop_table')); - } - $platform->expects($this->exactly(1)) - ->method('getCreateTableSql') - ->with($this->isInstanceof('Doctrine\DBAL\Schema\Table')) - ->will($this->returnValue(array('create_table'))); - $platform->expects($this->exactly(1)) - ->method('getAlterTableSql') - ->with($this->isInstanceOf('Doctrine\DBAL\Schema\TableDiff')) - ->will($this->returnValue(array('alter_table'))); - if ($dropOrphanedFkCount > 0) { - $platform->expects($this->exactly($dropOrphanedFkCount)) - ->method('getDropForeignKeySql') - ->with($this->isInstanceof('Doctrine\DBAL\Schema\ForeignKeyConstraint'), $this->equalTo('local_table')) - ->will($this->returnValue('drop_orphan_fk')); - } - $platform->expects($this->exactly(1)) - ->method('supportsSequences') - ->will($this->returnValue(true)); - $platform->expects($this->exactly(1)) - ->method('supportsForeignKeyConstraints') - ->will($this->returnValue(true)); - return $platform; - } - - public function createSchemaDiff() - { - $diff = new SchemaDiff(); - $diff->changedSequences['foo_seq'] = new Sequence('foo_seq'); - $diff->newSequences['bar_seq'] = new Sequence('bar_seq'); - $diff->removedSequences['baz_seq'] = new Sequence('baz_seq'); - $diff->newTables['foo_table'] = new Table('foo_table'); - $diff->removedTables['bar_table'] = new Table('bar_table'); - $diff->changedTables['baz_table'] = new TableDiff('baz_table'); - $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('id'), 'foreign_table', array('id')); - $fk->setLocalTable(new Table('local_table')); - $diff->orphanedForeignKeys[] = $fk; - return $diff; - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php deleted file mode 100644 index 9e073fdd4..000000000 --- a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php +++ /dev/null @@ -1,243 +0,0 @@ -assertTrue($schema->hasTable($tableName)); - - $tables = $schema->getTables(); - $this->assertTrue( isset($tables[$tableName]) ); - $this->assertSame($table, $tables[$tableName]); - $this->assertSame($table, $schema->getTable($tableName)); - $this->assertTrue($schema->hasTable($tableName)); - } - - public function testTableMatchingCaseInsenstive() - { - $table = new Table("Foo"); - - $schema = new Schema(array($table)); - $this->assertTrue($schema->hasTable("foo")); - $this->assertTrue($schema->hasTable("FOO")); - - $this->assertSame($table, $schema->getTable('FOO')); - $this->assertSame($table, $schema->getTable('foo')); - $this->assertSame($table, $schema->getTable('Foo')); - } - - public function testGetUnknownTableThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $schema = new Schema(); - $schema->getTable("unknown"); - } - - public function testCreateTableTwiceThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $tableName = "foo"; - $table = new Table($tableName); - $tables = array($table, $table); - - $schema = new Schema($tables); - } - - public function testRenameTable() - { - $tableName = "foo"; - $table = new Table($tableName); - $schema = new Schema(array($table)); - - $this->assertTrue($schema->hasTable("foo")); - $schema->renameTable("foo", "bar"); - $this->assertFalse($schema->hasTable("foo")); - $this->assertTrue($schema->hasTable("bar")); - $this->assertSame($table, $schema->getTable("bar")); - } - - public function testDropTable() - { - $tableName = "foo"; - $table = new Table($tableName); - $schema = new Schema(array($table)); - - $this->assertTrue($schema->hasTable("foo")); - - $schema->dropTable("foo"); - - $this->assertFalse($schema->hasTable("foo")); - } - - public function testCreateTable() - { - $schema = new Schema(); - - $this->assertFalse($schema->hasTable("foo")); - - $table = $schema->createTable("foo"); - - $this->assertType('Doctrine\DBAL\Schema\Table', $table); - $this->assertEquals("foo", $table->getName()); - $this->assertTrue($schema->hasTable("foo")); - } - - public function testAddSequences() - { - $sequence = new Sequence("a_seq", 1, 1); - - $schema = new Schema(array(), array($sequence)); - - $this->assertTrue($schema->hasSequence("a_seq")); - $this->assertType('Doctrine\DBAL\Schema\Sequence', $schema->getSequence("a_seq")); - - $sequences = $schema->getSequences(); - $this->assertArrayHasKey('a_seq', $sequences); - } - - public function testSequenceAccessCaseInsensitive() - { - $sequence = new Sequence("a_Seq"); - - $schema = new Schema(array(), array($sequence)); - $this->assertTrue($schema->hasSequence('a_seq')); - $this->assertTrue($schema->hasSequence('a_Seq')); - $this->assertTrue($schema->hasSequence('A_SEQ')); - - $this->assertEquals($sequence, $schema->getSequence('a_seq')); - $this->assertEquals($sequence, $schema->getSequence('a_Seq')); - $this->assertEquals($sequence, $schema->getSequence('A_SEQ')); - } - - public function testGetUnknownSequenceThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $schema = new Schema(); - $schema->getSequence("unknown"); - } - - public function testCreateSequence() - { - $schema = new Schema(); - $sequence = $schema->createSequence('a_seq', 10, 20); - - $this->assertEquals('a_seq', $sequence->getName()); - $this->assertEquals(10, $sequence->getAllocationSize()); - $this->assertEquals(20, $sequence->getInitialValue()); - - $this->assertTrue($schema->hasSequence("a_seq")); - $this->assertType('Doctrine\DBAL\Schema\Sequence', $schema->getSequence("a_seq")); - - $sequences = $schema->getSequences(); - $this->assertArrayHasKey('a_seq', $sequences); - } - - public function testDropSequence() - { - $sequence = new Sequence("a_seq", 1, 1); - - $schema = new Schema(array(), array($sequence)); - - $schema->dropSequence("a_seq"); - $this->assertFalse($schema->hasSequence("a_seq")); - } - - public function testAddSequenceTwiceThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $sequence = new Sequence("a_seq", 1, 1); - - $schema = new Schema(array(), array($sequence, $sequence)); - } - - public function testFixSchema_AddExplicitIndexForForeignKey() - { - $schema = new Schema(); - $tableA = $schema->createTable('foo'); - $tableA->addColumn('id', 'integer'); - - $tableB = $schema->createTable('bar'); - $tableB->addColumn('id', 'integer'); - $tableB->addColumn('foo_id', 'integer'); - $tableB->addForeignKeyConstraint($tableA, array('foo_id'), array('id')); - - $this->assertEquals(0, count($tableB->getIndexes())); - - $schema->visit(new \Doctrine\DBAL\Schema\Visitor\FixSchema(true)); - - $this->assertEquals(1, count($tableB->getIndexes())); - $indexes = $tableB->getIndexes(); - $index = current($indexes); - $this->assertTrue($index->hasColumnAtPosition('foo_id', 0)); - } - - public function testConfigHasExplicitForeignKeyIndex() - { - $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig(); - $schemaConfig->setExplicitForeignKeyIndexes(false); - - $schema = new Schema(array(), array(), $schemaConfig); - $this->assertFalse($schema->hasExplicitForeignKeyIndexes()); - - $schemaConfig->setExplicitForeignKeyIndexes(true); - $this->assertTrue($schema->hasExplicitForeignKeyIndexes()); - } - - public function testConfigMaxIdentifierLength() - { - $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig(); - $schemaConfig->setMaxIdentifierLength(10); - - $schema = new Schema(array(), array(), $schemaConfig); - $table = $schema->createTable("smalltable"); - $table->addColumn('long_id', 'integer'); - $table->addIndex(array('long_id')); - - $this->assertTrue($table->hasIndex('le_id_idx')); - } - - public function testDeepClone() - { - $schema = new Schema(); - $sequence = $schema->createSequence('baz'); - - $tableA = $schema->createTable('foo'); - $tableA->addColumn('id', 'integer'); - - $tableB = $schema->createTable('bar'); - $tableB->addColumn('id', 'integer'); - $tableB->addColumn('foo_id', 'integer'); - $tableB->addForeignKeyConstraint($tableA, array('foo_id'), array('id')); - - $schemaNew = clone $schema; - - $this->assertNotSame($sequence, $schemaNew->getSequence('baz')); - - $this->assertNotSame($tableA, $schemaNew->getTable('foo')); - $this->assertNotSame($tableA->getColumn('id'), $schemaNew->getTable('foo')->getColumn('id')); - - $this->assertNotSame($tableB, $schemaNew->getTable('bar')); - $this->assertNotSame($tableB->getColumn('id'), $schemaNew->getTable('bar')->getColumn('id')); - - $fk = $schemaNew->getTable('bar')->getForeignKeys(); - $fk = current($fk); - $this->assertSame($schemaNew->getTable('bar'), $this->readAttribute($fk, '_localTable')); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php deleted file mode 100644 index 652e475b9..000000000 --- a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php +++ /dev/null @@ -1,362 +0,0 @@ -setExpectedException('Doctrine\DBAL\DBALException'); - $table = new \Doctrine\DBAL\Schema\Table(''); - } - - public function testGetName() - { - $table = new Table("foo", array(), array(), array()); - $this->assertEquals("foo", $table->getName()); - } - - public function testColumns() - { - $type = Type::getType('integer'); - $columns = array(); - $columns[] = new Column("foo", $type); - $columns[] = new Column("bar", $type); - $table = new Table("foo", $columns, array(), array()); - - $this->assertTrue($table->hasColumn("foo")); - $this->assertTrue($table->hasColumn("bar")); - $this->assertFalse($table->hasColumn("baz")); - - $this->assertType('Doctrine\DBAL\Schema\Column', $table->getColumn("foo")); - $this->assertType('Doctrine\DBAL\Schema\Column', $table->getColumn("bar")); - - $this->assertEquals(2, count($table->getColumns())); - } - - public function testColumnsCaseInsensitive() - { - $table = new Table("foo"); - $column = $table->addColumn('Foo', 'integer'); - - $this->assertTrue($table->hasColumn('Foo')); - $this->assertTrue($table->hasColumn('foo')); - $this->assertTrue($table->hasColumn('FOO')); - - $this->assertSame($column, $table->getColumn('Foo')); - $this->assertSame($column, $table->getColumn('foo')); - $this->assertSame($column, $table->getColumn('FOO')); - } - - public function testCreateColumn() - { - $type = Type::getType('integer'); - - $table = new Table("foo"); - - $this->assertFalse($table->hasColumn("bar")); - $table->addColumn("bar", 'integer'); - $this->assertTrue($table->hasColumn("bar")); - $this->assertSame($type, $table->getColumn("bar")->getType()); - } - - public function testDropColumn() - { - $type = Type::getType('integer'); - $columns = array(); - $columns[] = new Column("foo", $type); - $columns[] = new Column("bar", $type); - $table = new Table("foo", $columns, array(), array()); - - $this->assertTrue($table->hasColumn("foo")); - $this->assertTrue($table->hasColumn("bar")); - - $table->dropColumn("foo")->dropColumn("bar"); - - $this->assertFalse($table->hasColumn("foo")); - $this->assertFalse($table->hasColumn("bar")); - } - - public function testGetUnknownColumnThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $table = new Table("foo", array(), array(), array()); - $table->getColumn('unknown'); - } - - public function testAddColumnTwiceThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $type = \Doctrine\DBAL\Types\Type::getType('integer'); - $columns = array(); - $columns[] = new Column("foo", $type); - $columns[] = new Column("foo", $type); - $table = new Table("foo", $columns, array(), array()); - } - - public function testCreateIndex() - { - $type = \Doctrine\DBAL\Types\Type::getType('integer'); - $columns = array(new Column("foo", $type), new Column("bar", $type), new Column("baz", $type)); - $table = new Table("foo", $columns); - - $table->addIndex(array("foo", "bar", "baz")); - $table->addUniqueIndex(array("foo", "bar", "baz")); - - $this->assertTrue($table->hasIndex("foo_foo_bar_baz_idx")); - $this->assertTrue($table->hasIndex("foo_foo_bar_baz_uniq")); - } - - public function testIndexCaseInsensitive() - { - $type = \Doctrine\DBAL\Types\Type::getType('integer'); - $columns = array(new Column("foo", $type), new Column("bar", $type), new Column("baz", $type)); - $table = new Table("foo", $columns); - - $table->addIndex(array("foo", "bar", "baz"), "Foo_Idx"); - - $this->assertTrue($table->hasIndex('foo_idx')); - $this->assertTrue($table->hasIndex('Foo_Idx')); - $this->assertTrue($table->hasIndex('FOO_IDX')); - } - - public function testAddIndexes() - { - $type = \Doctrine\DBAL\Types\Type::getType('integer'); - $columns = array(new Column("foo", $type)); - $indexes = array( - new Index("the_primary", array("foo"), true, true), - new Index("foo_idx", array("foo"), false, false), - ); - $table = new Table("foo", $columns, $indexes, array()); - - $this->assertTrue($table->hasIndex("the_primary")); - $this->assertTrue($table->hasIndex("foo_idx")); - $this->assertFalse($table->hasIndex("some_idx")); - - $this->assertType('Doctrine\DBAL\Schema\Index', $table->getPrimaryKey()); - $this->assertType('Doctrine\DBAL\Schema\Index', $table->getIndex('the_primary')); - $this->assertType('Doctrine\DBAL\Schema\Index', $table->getIndex('foo_idx')); - } - - public function testGetUnknownIndexThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $table = new Table("foo", array(), array(), array()); - $table->getIndex("unknownIndex"); - } - - public function testAddTwoPrimaryThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $type = \Doctrine\DBAL\Types\Type::getType('integer'); - $columns = array(new Column("foo", $type), new Column("bar", $type)); - $indexes = array( - new Index("the_primary", array("foo"), true, true), - new Index("other_primary", array("bar"), true, true), - ); - $table = new Table("foo", $columns, $indexes, array()); - } - - public function testAddTwoIndexesWithSameNameThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $type = \Doctrine\DBAL\Types\Type::getType('integer'); - $columns = array(new Column("foo", $type), new Column("bar", $type)); - $indexes = array( - new Index("an_idx", array("foo"), false, false), - new Index("an_idx", array("bar"), false, false), - ); - $table = new Table("foo", $columns, $indexes, array()); - } - - public function testIdGenerator() - { - $tableA = new Table("foo", array(), array(), array(), Table::ID_NONE); - $this->assertFalse($tableA->isIdGeneratorIdentity()); - $this->assertFalse($tableA->isIdGeneratorSequence());; - - $tableB = new Table("foo", array(), array(), array(), Table::ID_IDENTITY); - $this->assertTrue($tableB->isIdGeneratorIdentity()); - $this->assertFalse($tableB->isIdGeneratorSequence());; - - $tableC = new Table("foo", array(), array(), array(), Table::ID_SEQUENCE); - $this->assertFalse($tableC->isIdGeneratorIdentity()); - $this->assertTrue($tableC->isIdGeneratorSequence());; - } - - public function testConstraints() - { - $constraint = new ForeignKeyConstraint(array(), "foo", array()); - - $tableA = new Table("foo", array(), array(), array($constraint)); - $constraints = $tableA->getForeignKeys(); - - $this->assertEquals(1, count($constraints)); - $this->assertSame($constraint, array_shift($constraints)); - } - - public function testOptions() - { - $table = new Table("foo", array(), array(), array(), Table::ID_NONE, array("foo" => "bar")); - - $this->assertTrue($table->hasOption("foo")); - $this->assertEquals("bar", $table->getOption("foo")); - } - - public function testBuilderSetPrimaryKey() - { - $table = new Table("foo"); - - $table->addColumn("bar", 'integer'); - $table->setPrimaryKey(array("bar")); - - $this->assertTrue($table->hasIndex("primary")); - $this->assertType('Doctrine\DBAL\Schema\Index', $table->getPrimaryKey()); - $this->assertTrue($table->getIndex("primary")->isUnique()); - $this->assertTrue($table->getIndex("primary")->isPrimary()); - } - - public function testBuilderAddUniqueIndex() - { - $table = new Table("foo"); - - $table->addColumn("bar", 'integer'); - $table->addUniqueIndex(array("bar"), "my_idx"); - - $this->assertTrue($table->hasIndex("my_idx")); - $this->assertTrue($table->getIndex("my_idx")->isUnique()); - $this->assertFalse($table->getIndex("my_idx")->isPrimary()); - } - - public function testBuilderAddIndex() - { - $table = new Table("foo"); - - $table->addColumn("bar", 'integer'); - $table->addIndex(array("bar"), "my_idx"); - - $this->assertTrue($table->hasIndex("my_idx")); - $this->assertFalse($table->getIndex("my_idx")->isUnique()); - $this->assertFalse($table->getIndex("my_idx")->isPrimary()); - } - - public function testBuilderAddIndexWithInvalidNameThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $table = new Table("foo"); - $table->addColumn("bar",'integer'); - $table->addIndex(array("bar"), "invalid name %&/"); - } - - public function testBuilderAddIndexWithUnknownColumnThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $table = new Table("foo"); - $table->addIndex(array("bar"), "invalidName"); - } - - public function testBuilderOptions() - { - $table = new Table("foo"); - $table->addOption("foo", "bar"); - $this->assertTrue($table->hasOption("foo")); - $this->assertEquals("bar", $table->getOption("foo")); - } - - public function testIdGeneratorType() - { - $table = new Table("foo"); - - $table->setIdGeneratorType(Table::ID_IDENTITY); - $this->assertTrue($table->isIdGeneratorIdentity()); - - $table->setIdGeneratorType(Table::ID_SEQUENCE); - $this->assertTrue($table->isIdGeneratorSequence()); - } - - public function testAddForeignKeyConstraint_UnknownLocalColumn_ThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $table = new Table("foo"); - $table->addColumn("id", 'integer'); - - $foreignTable = new Table("bar"); - $foreignTable->addColumn("id", 'integer'); - - $table->addForeignKeyConstraint($foreignTable, array("foo"), array("id")); - } - - public function testAddForeignKeyConstraint_UnknownForeignColumn_ThrowsException() - { - $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); - - $table = new Table("foo"); - $table->addColumn("id", 'integer'); - - $foreignTable = new Table("bar"); - $foreignTable->addColumn("id", 'integer'); - - $table->addForeignKeyConstraint($foreignTable, array("id"), array("foo")); - } - - public function testAddForeignKeyConstraint() - { - $table = new Table("foo"); - $table->addColumn("id", 'integer'); - - $foreignTable = new Table("bar"); - $foreignTable->addColumn("id", 'integer'); - - $table->addForeignKeyConstraint($foreignTable, array("id"), array("id"), array("foo" => "bar")); - - $constraints = $table->getForeignKeys(); - $this->assertEquals(1, count($constraints)); - $this->assertType('Doctrine\DBAL\Schema\ForeignKeyConstraint', $constraints["foo_id_fk"]); - - $this->assertEquals("foo_id_fk", $constraints["foo_id_fk"]->getName()); - $this->assertTrue($constraints["foo_id_fk"]->hasOption("foo")); - $this->assertEquals("bar", $constraints["foo_id_fk"]->getOption("foo")); - } - - public function testAddIndexWithCaseSensitiveColumnProblem() - { - $table = new Table("foo"); - $table->addColumn("id", 'integer'); - - $table->addIndex(array("ID"), "my_idx"); - - $this->assertTrue($table->hasIndex('my_idx')); - $this->assertEquals(array("ID"), $table->getIndex("my_idx")->getColumns()); - } - - public function testAddPrimaryKey_ColumnsAreExplicitlySetToNotNull() - { - $table = new Table("foo"); - $column = $table->addColumn("id", 'integer', array('notnull' => false)); - - $this->assertFalse($column->getNotnull()); - - $table->setPrimaryKey(array('id')); - - $this->assertTrue($column->getNotnull()); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php deleted file mode 100644 index f38a609d1..000000000 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php +++ /dev/null @@ -1,81 +0,0 @@ -getMock( - 'Doctrine\DBAL\Platforms\MySqlPlatform', - array('getCreateTableSql', 'getCreateSequenceSql', 'getCreateForeignKeySql') - ); - $platformMock->expects($this->exactly(2)) - ->method('getCreateTableSql') - ->will($this->returnValue(array("foo"))); - $platformMock->expects($this->exactly(1)) - ->method('getCreateSequenceSql') - ->will($this->returnValue(array("bar"))); - $platformMock->expects($this->exactly(1)) - ->method('getCreateForeignKeySql') - ->will($this->returnValue(array("baz"))); - - $schema = $this->createFixtureSchema(); - - $sql = $schema->toSql($platformMock); - - $this->assertEquals(array("foo", "foo", "bar", "baz"), $sql); - } - - public function testDropSchema() - { - $platformMock = $this->getMock( - 'Doctrine\DBAL\Platforms\MySqlPlatform', - array('getDropTableSql', 'getDropSequenceSql', 'getDropForeignKeySql') - ); - $platformMock->expects($this->exactly(2)) - ->method('getDropTableSql') - ->will($this->returnValue("tbl")); - $platformMock->expects($this->exactly(1)) - ->method('getDropSequenceSql') - ->will($this->returnValue("seq")); - $platformMock->expects($this->exactly(1)) - ->method('getDropForeignKeySql') - ->will($this->returnValue("fk")); - - $schema = $this->createFixtureSchema(); - - $sql = $schema->toDropSql($platformMock); - - $this->assertEquals(array("fk", "seq", "tbl", "tbl"), $sql); - } - - /** - * @return Schema - */ - public function createFixtureSchema() - { - $schema = new Schema(); - $tableA = $schema->createTable("foo"); - $tableA->addColumn("id", 'integer'); - $tableA->addColumn("bar", 'string', array('length' => 255)); - $tableA->setPrimaryKey(array("id")); - $tableA->setIdGeneratorType(Table::ID_SEQUENCE); - - $schema->createSequence("foo_seq"); - - $tableB = $schema->createTable("bar"); - $tableB->addColumn("id", 'integer'); - $tableB->setPrimaryKey(array("id")); - - $tableA->addForeignKeyConstraint($tableB, array("bar"), array("id")); - - return $schema; - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php deleted file mode 100644 index dc4a223a9..000000000 --- a/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php +++ /dev/null @@ -1,35 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('array'); - } - - public function testArrayConvertsToDatabaseValue() - { - $this->assertTrue( - is_string($this->_type->convertToDatabaseValue(array(), $this->_platform)) - ); - } - - public function testArrayConvertsToPHPValue() - { - $this->assertTrue( - is_array($this->_type->convertToPHPValue(serialize(array()), $this->_platform)) - ); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php b/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php deleted file mode 100644 index 1e9cf2a44..000000000 --- a/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php +++ /dev/null @@ -1,35 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('boolean'); - } - - public function testBooleanConvertsToDatabaseValue() - { - $this->assertTrue( - is_integer($this->_type->convertToDatabaseValue(1, $this->_platform)) - ); - } - - public function testBooleanConvertsToPHPValue() - { - $this->assertTrue( - is_bool($this->_type->convertToPHPValue(0, $this->_platform)) - ); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTest.php deleted file mode 100644 index 3368a6c93..000000000 --- a/tests/Doctrine/Tests/DBAL/Types/DateTest.php +++ /dev/null @@ -1,64 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('date'); - $this->_tz = date_default_timezone_get(); - } - - public function tearDown() - { - date_default_timezone_set($this->_tz); - } - - public function testDateConvertsToDatabaseValue() - { - $this->assertTrue( - is_string($this->_type->convertToDatabaseValue(new \DateTime(), $this->_platform)) - ); - } - - public function testDateConvertsToPHPValue() - { - // Birthday of jwage and also birthday of Doctrine. Send him a present ;) - $this->assertTrue( - $this->_type->convertToPHPValue('1985-09-01', $this->_platform) - instanceof \DateTime - ); - } - - public function testDateResetsNonDatePartsToZeroUnixTimeValues() - { - $date = $this->_type->convertToPHPValue('1985-09-01', $this->_platform); - - $this->assertEquals('00:00:00', $date->format('H:i:s')); - } - - public function testDateRests_SummerTimeAffection() - { - date_default_timezone_set('Europe/Berlin'); - - $date = $this->_type->convertToPHPValue('2009-08-01', $this->_platform); - $this->assertEquals('00:00:00', $date->format('H:i:s')); - $this->assertEquals('2009-08-01', $date->format('Y-m-d')); - - $date = $this->_type->convertToPHPValue('2009-11-01', $this->_platform); - $this->assertEquals('00:00:00', $date->format('H:i:s')); - $this->assertEquals('2009-11-01', $date->format('Y-m-d')); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php deleted file mode 100644 index a60cae01b..000000000 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php +++ /dev/null @@ -1,37 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('datetime'); - } - - public function testDateTimeConvertsToDatabaseValue() - { - $this->assertTrue( - is_string($this->_type->convertToDatabaseValue(new \DateTime(), $this->_platform)) - ); - } - - public function testDateTimeConvertsToPHPValue() - { - // Birthday of jwage and also birthday of Doctrine. Send him a present ;) - $this->assertTrue( - $this->_type->convertToPHPValue('1985-09-01 00:00:00', $this->_platform) - instanceof \DateTime - ); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php b/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php deleted file mode 100644 index ee5e2491a..000000000 --- a/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php +++ /dev/null @@ -1,28 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('decimal'); - } - - public function testDecimalConvertsToPHPValue() - { - $this->assertTrue( - is_float($this->_type->convertToPHPValue('5.5', $this->_platform)) - ); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php b/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php deleted file mode 100644 index f03e400ba..000000000 --- a/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php +++ /dev/null @@ -1,32 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('integer'); - } - - public function testIntegerConvertsToPHPValue() - { - $this->assertTrue( - is_integer($this->_type->convertToPHPValue('1', $this->_platform)) - ); - - $this->assertTrue( - is_null($this->_type->convertToPHPValue(null, $this->_platform)) - ); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php b/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php deleted file mode 100644 index 122844c22..000000000 --- a/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php +++ /dev/null @@ -1,35 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('object'); - } - - public function testObjectConvertsToDatabaseValue() - { - $this->assertTrue( - is_string($this->_type->convertToDatabaseValue(new \stdClass(), $this->_platform)) - ); - } - - public function testObjectConvertsToPHPValue() - { - $this->assertTrue( - is_object($this->_type->convertToPHPValue(serialize(new \stdClass), $this->_platform)) - ); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php b/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php deleted file mode 100644 index 8495d45f3..000000000 --- a/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php +++ /dev/null @@ -1,28 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('smallint'); - } - - public function testDecimalConvertsToPHPValue() - { - $this->assertTrue( - is_integer($this->_type->convertToPHPValue('1', $this->_platform)) - ); - } -} \ No newline at end of file diff --git a/tests/Doctrine/Tests/DBAL/Types/StringTest.php b/tests/Doctrine/Tests/DBAL/Types/StringTest.php deleted file mode 100644 index f67adbf0b..000000000 --- a/tests/Doctrine/Tests/DBAL/Types/StringTest.php +++ /dev/null @@ -1,31 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('string'); - } - - public function testReturnsSqlDeclarationFromPlatformVarchar() - { - $this->assertEquals("DUMMYVARCHAR()", $this->_type->getSqlDeclaration(array(), $this->_platform)); - } - - public function testReturnsDefaultLengthFromPlatformVarchar() - { - $this->assertEquals(255, $this->_type->getDefaultLength($this->_platform)); - } -} diff --git a/tests/Doctrine/Tests/DBAL/Types/TimeTest.php b/tests/Doctrine/Tests/DBAL/Types/TimeTest.php deleted file mode 100644 index eb272ed59..000000000 --- a/tests/Doctrine/Tests/DBAL/Types/TimeTest.php +++ /dev/null @@ -1,36 +0,0 @@ -_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); - $this->_type = Type::getType('time'); - } - - public function testTimeConvertsToDatabaseValue() - { - $this->assertTrue( - is_string($this->_type->convertToDatabaseValue(new \DateTime(), $this->_platform)) - ); - } - - public function testTimeConvertsToPHPValue() - { - $this->assertTrue( - $this->_type->convertToPHPValue('5:30:55', $this->_platform) - instanceof \DateTime - ); - } -} \ No newline at end of file