3 namespace Doctrine\Tests\DBAL\Types;
5 use Doctrine\DBAL\Types\Type;
6 use Doctrine\Tests\DBAL\Mocks;
8 require_once __DIR__ . '/../../TestInit.php';
10 class StringTest extends \Doctrine\Tests\DbalTestCase
16 protected function setUp()
18 $this->_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform();
19 $this->_type = Type::getType('string');
22 public function testReturnsSqlDeclarationFromPlatformVarchar()
24 $this->assertEquals("DUMMYVARCHAR()", $this->_type->getSqlDeclaration(array(), $this->_platform));
27 public function testReturnsDefaultLengthFromPlatformVarchar()
29 $this->assertEquals(255, $this->_type->getDefaultLength($this->_platform));
32 public function testConvertToPHPValue()
34 $this->assertInternalType("string", $this->_type->convertToPHPValue("foo", $this->_platform));
35 $this->assertInternalType("string", $this->_type->convertToPHPValue("", $this->_platform));
38 public function testNullConversion()
40 $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform));
43 public function testSQLConversion()
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));