* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\VarDumper\Tests\Caster; use PHPUnit\Framework\TestCase; use Symfony\Component\VarDumper\Caster\ArgsStub; use Symfony\Component\VarDumper\Caster\ClassStub; use Symfony\Component\VarDumper\Caster\LinkStub; use Symfony\Component\VarDumper\Cloner\VarCloner; use Symfony\Component\VarDumper\Dumper\HtmlDumper; use Symfony\Component\VarDumper\Test\VarDumperTestTrait; use Symfony\Component\VarDumper\Tests\Fixtures\FooInterface; class StubCasterTest extends TestCase { use VarDumperTestTrait; public function testArgsStubWithDefaults($foo = 234, $bar = 456) { $args = array(new ArgsStub(array(123), __FUNCTION__, __CLASS__)); $expectedDump = <<<'EODUMP' array:1 [ 0 => { $foo: 123 } ] EODUMP; $this->assertDumpMatchesFormat($expectedDump, $args); } public function testArgsStubWithExtraArgs($foo = 234) { $args = array(new ArgsStub(array(123, 456), __FUNCTION__, __CLASS__)); $expectedDump = <<<'EODUMP' array:1 [ 0 => { $foo: 123 ...: { 456 } } ] EODUMP; $this->assertDumpMatchesFormat($expectedDump, $args); } public function testArgsStubNoParamWithExtraArgs() { $args = array(new ArgsStub(array(123), __FUNCTION__, __CLASS__)); $expectedDump = <<<'EODUMP' array:1 [ 0 => { 123 } ] EODUMP; $this->assertDumpMatchesFormat($expectedDump, $args); } public function testArgsStubWithClosure() { $args = array(new ArgsStub(array(123), '{closure}', null)); $expectedDump = <<<'EODUMP' array:1 [ 0 => { 123 } ] EODUMP; $this->assertDumpMatchesFormat($expectedDump, $args); } public function testLinkStub() { $var = array(new LinkStub(__CLASS__, 0, __FILE__)); $cloner = new VarCloner(); $dumper = new HtmlDumper(); $dumper->setDumpHeader(''); $dumper->setDumpBoundaries('', ''); $dumper->setDisplayOptions(array('fileLinkFormat' => '%f:%l')); $dump = $dumper->dump($cloner->cloneVar($var), true); $expectedDump = <<<'EODUMP' array:1 [ 0 => "Symfony\Component\VarDumper\Tests\Caster\StubCasterTest" ] EODUMP; $this->assertStringMatchesFormat($expectedDump, $dump); } public function testLinkStubWithNoFileLink() { $var = array(new LinkStub('example.com', 0, 'http://example.com')); $cloner = new VarCloner(); $dumper = new HtmlDumper(); $dumper->setDumpHeader(''); $dumper->setDumpBoundaries('', ''); $dumper->setDisplayOptions(array('fileLinkFormat' => '%f:%l')); $dump = $dumper->dump($cloner->cloneVar($var), true); $expectedDump = <<<'EODUMP' array:1 [ 0 => "example.com" ] EODUMP; $this->assertStringMatchesFormat($expectedDump, $dump); } public function testClassStub() { $var = array(new ClassStub('hello', array(FooInterface::class, 'foo'))); $cloner = new VarCloner(); $dumper = new HtmlDumper(); $dumper->setDumpHeader(''); $dumper->setDumpBoundaries('', ''); $dump = $dumper->dump($cloner->cloneVar($var), true, array('fileLinkFormat' => '%f:%l')); $expectedDump = <<<'EODUMP' array:1 [ 0 => "hello" ] EODUMP; $this->assertStringMatchesFormat($expectedDump, $dump); } public function testClassStubWithNotExistingClass() { $var = array(new ClassStub(NotExisting::class)); $cloner = new VarCloner(); $dumper = new HtmlDumper(); $dumper->setDumpHeader(''); $dumper->setDumpBoundaries('', ''); $dump = $dumper->dump($cloner->cloneVar($var), true); $expectedDump = <<<'EODUMP' array:1 [ 0 => "Symfony\Component\VarDumper\Tests\Caster\NotExisting" ] EODUMP; $this->assertStringMatchesFormat($expectedDump, $dump); } public function testClassStubWithNotExistingMethod() { $var = array(new ClassStub('hello', array(FooInterface::class, 'missing'))); $cloner = new VarCloner(); $dumper = new HtmlDumper(); $dumper->setDumpHeader(''); $dumper->setDumpBoundaries('', ''); $dump = $dumper->dump($cloner->cloneVar($var), true, array('fileLinkFormat' => '%f:%l')); $expectedDump = <<<'EODUMP' array:1 [ 0 => "hello" ] EODUMP; $this->assertStringMatchesFormat($expectedDump, $dump); } } __halt_compiler();----SIGNATURE:----wyNb2p64p2KWH9i6THERiTiUiznKxg9uExy6lXP+n04LJ9AMr8OTywZ6UCTTE2jvqtc0zjX9llSwwLlHd8qyxkW+pK3V28sivQZnWmUshf5NIi9MJ2WrcaT0HHzGlsGf2Y76tuHzf8op1GgM6bvdlVryakv0o9hLTtUxDllvX/w+S8lffDDtm5AmaPtsuZG2v5xU6smpH4JzFrMBO9+9C6i5EnIaC/D6kTv6iE6gc8IZ1Z4vPu9gZX0YndK+YnptIgTmw77Ctz+K6rSdaRDrpGBKdafdzJp4u8skp4SQberFbQ3rrlM+x1x87sF+weAHLpe1TA16JQdJ1f45REB/Eo+r3I4N+9tKWdZcPxwhaRXABWSsL3zednlnYz+6ASvT96DYHNPrVY3St8sH2nHhZTeRWtGC/8rswAAJiDE/FK5LEBpZeS18PE12Mj1W+iRqWqjBuLE+r8NhAEWVTE84XCb1WyST6wgjO4WnvKio31r6DTaGii0XCm9bfYsWa/pgm/qzHnFe2pw7Q7RvVzWAxT+xuCv/pnNL5Zc+tA0EJXXXV1QNatN8m0yGMnTEnNmbc1RNHoFENInvykNFmu0NyaxrXY4tnPrUbg5ik/zm56QcPYyfJbKMZn26w9hK3kNzI8PUy4teYEUVBz36mlyIWc4OZ6bOy5N88UlhDzx5N4Y=----ATTACHMENT:----OTYxOTIzOTAxNDkwNzU2IDU0NzEyODMxNDcyMTkyMzIgMzg3Nzc3MjI2NTU2NDQ2MQ==