Completed
Pull Request — master (#3254)
by Farhad
15:23
created

ArrayTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Types;
4
5
use Doctrine\DBAL\Platforms\AbstractPlatform;
6
use Doctrine\DBAL\Types\Type;
7
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
8
use const E_ALL;
9
use const E_STRICT;
10
use function error_reporting;
11
use function serialize;
12
13
class ArrayTest extends \Doctrine\Tests\DbalTestCase
14
{
15
    /**
16
     * @var AbstractPlatform
17
     */
18
    protected $_platform;
19
20
    /**
21
     * @var Type
22
     */
23
    protected $_type;
24
25
    protected function setUp()
26
    {
27
        $this->_platform = new MockPlatform();
28
        $this->_type = Type::getType('array');
29
    }
30
31
    public function testArrayConvertsToDatabaseValue()
32
    {
33
        self::assertInternalType(
34
            'string',
35
            $this->_type->convertToDatabaseValue(array(), $this->_platform)
36
        );
37
    }
38
39
    public function testArrayConvertsToPHPValue()
40
    {
41
        self::assertInternalType(
42
            'array',
43
            $this->_type->convertToPHPValue(serialize(array()), $this->_platform)
44
        );
45
    }
46
47
    public function testConversionFailure()
48
    {
49
        $this->expectException('Doctrine\DBAL\Types\ConversionException');
50
        $this->_type->convertToPHPValue('abcdefg', $this->_platform);
51
    }
52
53
    public function testNullConversion()
54
    {
55
        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...
56
    }
57
58
    /**
59
     * @group DBAL-73
60
     */
61
    public function testFalseConversion()
62
    {
63
        self::assertFalse($this->_type->convertToPHPValue(serialize(false), $this->_platform));
64
    }
65
}
66