1 | <?php |
||
2 | |||
3 | namespace Doctrine\Tests\DBAL\Types; |
||
4 | |||
5 | use Doctrine\DBAL\Platforms\AbstractPlatform; |
||
6 | use Doctrine\DBAL\Types\ConversionException; |
||
7 | use Doctrine\DBAL\Types\Type; |
||
8 | use Doctrine\Tests\DBAL\Mocks\MockPlatform; |
||
9 | use Doctrine\Tests\DbalTestCase; |
||
10 | use function serialize; |
||
11 | |||
12 | class ArrayTest extends DbalTestCase |
||
13 | { |
||
14 | /** @var AbstractPlatform */ |
||
15 | private $platform; |
||
16 | |||
17 | /** @var Type */ |
||
18 | private $type; |
||
19 | |||
20 | protected function setUp() : void |
||
21 | { |
||
22 | $this->platform = new MockPlatform(); |
||
23 | $this->type = Type::getType('array'); |
||
24 | } |
||
25 | |||
26 | public function testArrayConvertsToDatabaseValue() |
||
27 | { |
||
28 | self::assertIsString($this->type->convertToDatabaseValue([], $this->platform)); |
||
29 | } |
||
30 | |||
31 | public function testArrayConvertsToPHPValue() |
||
32 | { |
||
33 | self::assertIsArray($this->type->convertToPHPValue(serialize([]), $this->platform)); |
||
34 | } |
||
35 | |||
36 | public function testConversionFailure() |
||
37 | { |
||
38 | $this->expectException(ConversionException::class); |
||
39 | $this->expectExceptionMessage("Could not convert database value to 'array' as an error was triggered by the unserialization: 'unserialize(): Error at offset 0 of 7 bytes'"); |
||
40 | $this->type->convertToPHPValue('abcdefg', $this->platform); |
||
41 | } |
||
42 | |||
43 | public function testNullConversion() |
||
44 | { |
||
45 | self::assertNull($this->type->convertToPHPValue(null, $this->platform)); |
||
0 ignored issues
–
show
|
|||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @group DBAL-73 |
||
50 | */ |
||
51 | public function testFalseConversion() |
||
52 | { |
||
53 | self::assertFalse($this->type->convertToPHPValue(serialize(false), $this->platform)); |
||
54 | } |
||
55 | } |
||
56 |
This check looks for function or method calls that always return null and whose return value is used.
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.