1 | <?php |
||
2 | |||
3 | namespace Doctrine\Tests\DBAL\Types; |
||
4 | |||
5 | use Doctrine\DBAL\Types\ConversionException; |
||
6 | use Doctrine\DBAL\Types\Type; |
||
7 | use Doctrine\Tests\DBAL\Mocks\MockPlatform; |
||
8 | use Doctrine\Tests\DbalTestCase; |
||
9 | use stdClass; |
||
10 | use function serialize; |
||
11 | |||
12 | class ObjectTest extends DbalTestCase |
||
13 | { |
||
14 | /** @var MockPlatform */ |
||
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('object'); |
||
24 | } |
||
25 | |||
26 | public function testObjectConvertsToDatabaseValue() |
||
27 | { |
||
28 | self::assertIsString($this->type->convertToDatabaseValue(new stdClass(), $this->platform)); |
||
29 | } |
||
30 | |||
31 | public function testObjectConvertsToPHPValue() |
||
32 | { |
||
33 | self::assertIsObject($this->type->convertToPHPValue(serialize(new stdClass()), $this->platform)); |
||
34 | } |
||
35 | |||
36 | public function testConversionFailure() |
||
37 | { |
||
38 | $this->expectException(ConversionException::class); |
||
39 | $this->expectExceptionMessage("Could not convert database value to 'object' 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.