Completed
Push — develop ( 5ee944...c7cb25 )
by Sergei
22s queued 13s
created

SerializationFailedTest::testNew()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\DBAL\Types\Exception;
6
7
use Doctrine\DBAL\Types\Exception\SerializationFailed;
8
use PHPUnit\Framework\TestCase;
9
use const NAN;
10
use function json_encode;
11
use function json_last_error_msg;
12
13
class SerializationFailedTest extends TestCase
14
{
15
    public function testNew() : void
16
    {
17
        $value   = NAN;
18
        $encoded = json_encode($value);
0 ignored issues
show
Unused Code introduced by
The assignment to $encoded is dead and can be removed.
Loading history...
19
20
        $exception = SerializationFailed::new($value, 'json', json_last_error_msg());
21
22
        self::assertSame(
23
            'Could not convert PHP type "double" to "json". An error was triggered by the serialization: Inf and NaN cannot be JSON encoded',
24
            $exception->getMessage()
25
        );
26
    }
27
}
28