GmpCasterTest.php 1.2 KB

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