Completed
Push — master ( c7757e...39cb21 )
by Luís
16s
created

tests/Doctrine/Tests/DBAL/Types/StringTest.php (2 issues)

1
<?php
2
3
namespace Doctrine\Tests\DBAL\Types;
4
5
use Doctrine\DBAL\Types\Type;
6
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
7
8
class StringTest extends \Doctrine\Tests\DbalTestCase
9
{
10
    protected
11
        $_platform,
0 ignored issues
show
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
The visibility should be declared for property $_platform.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
12
        $_type;
13
14
    protected function setUp()
15
    {
16
        $this->_platform = new MockPlatform();
17
        $this->_type = Type::getType('string');
18
    }
19
20
    public function testReturnsSqlDeclarationFromPlatformVarchar()
21
    {
22
        self::assertEquals("DUMMYVARCHAR()", $this->_type->getSqlDeclaration(array(), $this->_platform));
23
    }
24
25
    public function testReturnsDefaultLengthFromPlatformVarchar()
26
    {
27
        self::assertEquals(255, $this->_type->getDefaultLength($this->_platform));
28
    }
29
30
    public function testConvertToPHPValue()
31
    {
32
        self::assertInternalType("string", $this->_type->convertToPHPValue("foo", $this->_platform));
33
        self::assertInternalType("string", $this->_type->convertToPHPValue("", $this->_platform));
34
    }
35
36
    public function testNullConversion()
37
    {
38
        self::assertNull($this->_type->convertToPHPValue(null, $this->_platform));
39
    }
40
41
    public function testSQLConversion()
42
    {
43
        self::assertFalse($this->_type->canRequireSQLConversion(), "String type can never require SQL conversion to work.");
44
        self::assertEquals('t.foo', $this->_type->convertToDatabaseValueSQL('t.foo', $this->_platform));
45
        self::assertEquals('t.foo', $this->_type->convertToPHPValueSQL('t.foo', $this->_platform));
46
    }
47
}
48