File: SerializationFailedTest.php

package info (click to toggle)
php-doctrine-dbal 4.3.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 5,092 kB
  • sloc: php: 60,293; xml: 618; makefile: 23
file content (30 lines) | stat: -rw-r--r-- 721 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

declare(strict_types=1);

namespace Doctrine\DBAL\Tests\Types\Exception;

use Doctrine\DBAL\Types\Exception\SerializationFailed;
use PHPUnit\Framework\TestCase;

use function json_encode;
use function json_last_error_msg;

use const NAN;

class SerializationFailedTest extends TestCase
{
    public function testNew(): void
    {
        $value = NAN;
        json_encode($value);

        $exception = SerializationFailed::new($value, 'json', json_last_error_msg());

        self::assertSame(
            'Could not convert PHP type "float" to "json". An error was triggered by the serialization: '
                . 'Inf and NaN cannot be JSON encoded',
            $exception->getMessage(),
        );
    }
}