X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=vendor%2Fdoctrine%2Fdbal%2Ftests%2FDoctrine%2FTests%2FDBAL%2FSchema%2FColumnTest.php;fp=vendor%2Fdoctrine%2Fdbal%2Ftests%2FDoctrine%2FTests%2FDBAL%2FSchema%2FColumnTest.php;h=20510616572b8173fd2270a0f36c100c853a2288;hb=8b04b2d11798dee4f3e1358e4f43e97a6df851f6;hp=0000000000000000000000000000000000000000;hpb=73568cf05a785a45f94ca3f2351d9e07bf917958;p=zf2.biz%2Fapplication_blanche.git diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php new file mode 100644 index 0000000..2051061 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php @@ -0,0 +1,114 @@ +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')); + + $this->assertEquals(array('bar' => 'baz'), $column->getCustomSchemaOptions()); + $this->assertTrue($column->hasCustomSchemaOption('bar')); + $this->assertEquals('baz', $column->getCustomSchemaOption('bar')); + $this->assertFalse($column->hasCustomSchemaOption('foo')); + } + + 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, + 'autoincrement' => false, + 'columnDefinition' => null, + 'comment' => null, + 'foo' => 'bar', + 'bar' => 'baz' + ); + + $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'), + 'customSchemaOptions' => array('bar' => 'baz'), + ); + + $string = Type::getType('string'); + return new Column("foo", $string, $options); + } + + /** + * @group DBAL-64 + */ + public function testQuotedColumnName() + { + $string = Type::getType('string'); + $column = new Column("`bar`", $string, array()); + + $mysqlPlatform = new \Doctrine\DBAL\Platforms\MySqlPlatform(); + $sqlitePlatform = new \Doctrine\DBAL\Platforms\SqlitePlatform(); + + $this->assertEquals('bar', $column->getName()); + $this->assertEquals('`bar`', $column->getQuotedName($mysqlPlatform)); + $this->assertEquals('"bar"', $column->getQuotedName($sqlitePlatform)); + } + + /** + * @group DBAL-42 + */ + public function testColumnComment() + { + $column = new Column("bar", Type::getType('string')); + $this->assertNull($column->getComment()); + + $column->setComment("foo"); + $this->assertEquals("foo", $column->getComment()); + + $columnArray = $column->toArray(); + $this->assertArrayHasKey('comment', $columnArray); + $this->assertEquals('foo', $columnArray['comment']); + } +} \ No newline at end of file