1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\VarDumper\Tests\Caster;
13
14use PHPUnit\Framework\TestCase;
15use Symfony\Component\VarDumper\Caster\GmpCaster;
16use Symfony\Component\VarDumper\Cloner\Stub;
17use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
18
19class GmpCasterTest extends TestCase
20{
21    use VarDumperTestTrait;
22
23    /**
24     * @requires extension gmp
25     */
26    public function testCastGmp()
27    {
28        $gmpString = gmp_init('1234');
29        $gmpOctal = gmp_init(010);
30        $gmp = gmp_init('01101');
31        $gmpDump = <<<EODUMP
32array:1 [
33  "\\x00~\\x00value" => %s
34]
35EODUMP;
36        $this->assertDumpEquals(sprintf($gmpDump, $gmpString), GmpCaster::castGmp($gmpString, [], new Stub(), false, 0));
37        $this->assertDumpEquals(sprintf($gmpDump, $gmpOctal), GmpCaster::castGmp($gmpOctal, [], new Stub(), false, 0));
38        $this->assertDumpEquals(sprintf($gmpDump, $gmp), GmpCaster::castGmp($gmp, [], new Stub(), false, 0));
39
40        $dump = <<<EODUMP
41GMP {
42  value: 577
43}
44EODUMP;
45
46        $this->assertDumpEquals($dump, $gmp);
47    }
48}
49