Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / dbal / tests / Doctrine / Tests / DBAL / Types / StringTest.php
1 <?php
2
3 namespace Doctrine\Tests\DBAL\Types;
4
5 use Doctrine\DBAL\Types\Type;
6 use Doctrine\Tests\DBAL\Mocks;
7
8 require_once __DIR__ . '/../../TestInit.php';
9
10 class StringTest extends \Doctrine\Tests\DbalTestCase
11 {
12     protected
13         $_platform,
14         $_type;
15
16     protected function setUp()
17     {
18         $this->_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform();
19         $this->_type = Type::getType('string');
20     }
21
22     public function testReturnsSqlDeclarationFromPlatformVarchar()
23     {
24         $this->assertEquals("DUMMYVARCHAR()", $this->_type->getSqlDeclaration(array(), $this->_platform));
25     }
26
27     public function testReturnsDefaultLengthFromPlatformVarchar()
28     {
29         $this->assertEquals(255, $this->_type->getDefaultLength($this->_platform));
30     }
31
32     public function testConvertToPHPValue()
33     {
34         $this->assertInternalType("string", $this->_type->convertToPHPValue("foo", $this->_platform));
35         $this->assertInternalType("string", $this->_type->convertToPHPValue("", $this->_platform));
36     }
37
38     public function testNullConversion()
39     {
40         $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform));
41     }
42
43     public function testSQLConversion()
44     {
45         $this->assertFalse($this->_type->canRequireSQLConversion(), "String type can never require SQL conversion to work.");
46         $this->assertEquals('t.foo', $this->_type->convertToDatabaseValueSQL('t.foo', $this->_platform));
47         $this->assertEquals('t.foo', $this->_type->convertToPHPValueSQL('t.foo', $this->_platform));
48     }
49 }