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

SerializationFailedTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 6
dl 0
loc 12
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testNew() 0 10 1
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