Completed
Push — master ( 62fe3f...89a52c )
by Marco
18s queued 13s
created

GuidTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A GuidTypeTest::testNullConversion() 0 3 1
A GuidTypeTest::setUp() 0 4 1
A GuidTypeTest::testConvertToPHPValue() 0 4 1
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Types;
4
5
use Doctrine\DBAL\Types\Type;
6
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
7
use Doctrine\Tests\DbalTestCase;
8
use function get_class;
9
10
class GuidTypeTest extends DbalTestCase
11
{
12
    /**
13
     * @var MockPlatform
14
     */
15
    protected $_platform;
16
17
    /**
18
     * @var Type
19
     */
20
    protected $_type;
21
22
    protected function setUp()
23
    {
24
        $this->_platform = new MockPlatform();
25
        $this->_type = Type::getType('guid');
26
    }
27
28
    public function testConvertToPHPValue()
29
    {
30
        self::assertInternalType("string", $this->_type->convertToPHPValue("foo", $this->_platform));
31
        self::assertInternalType("string", $this->_type->convertToPHPValue("", $this->_platform));
32
    }
33
34
    public function testNullConversion()
35
    {
36
        self::assertNull($this->_type->convertToPHPValue(null, $this->_platform));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->_type->convertToP...null, $this->_platform) targeting Doctrine\DBAL\Types\Type::convertToPHPValue() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
37
    }
38
39
    public function testNativeGuidSupport()
40
    {
41
        self::assertTrue($this->_type->requiresSQLCommentHint($this->_platform));
42
43
        $mock = $this->createMock(get_class($this->_platform));
44
        $mock->expects($this->any())
45
             ->method('hasNativeGuidType')
46
             ->will($this->returnValue(true));
47
48
        self::assertFalse($this->_type->requiresSQLCommentHint($mock));
49
    }
50
}
51