1
0

提交代码

This commit is contained in:
2020-08-06 14:50:07 +08:00
parent 9d0d5f4be9
commit d7a848c824
11299 changed files with 1321854 additions and 0 deletions

View File

@@ -0,0 +1,178 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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\Caster;
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
class CasterTest extends TestCase
{
use VarDumperTestTrait;
private $referenceArray = [
'null' => null,
'empty' => false,
'public' => 'pub',
"\0~\0virtual" => 'virt',
"\0+\0dynamic" => 'dyn',
"\0*\0protected" => 'prot',
"\0Foo\0private" => 'priv',
];
/**
* @dataProvider provideFilter
*/
public function testFilter($filter, $expectedDiff, $listedProperties = null)
{
if (null === $listedProperties) {
$filteredArray = Caster::filter($this->referenceArray, $filter);
} else {
$filteredArray = Caster::filter($this->referenceArray, $filter, $listedProperties);
}
$this->assertSame($expectedDiff, array_diff_assoc($this->referenceArray, $filteredArray));
}
public function provideFilter()
{
return [
[
0,
[],
],
[
Caster::EXCLUDE_PUBLIC,
[
'null' => null,
'empty' => false,
'public' => 'pub',
],
],
[
Caster::EXCLUDE_NULL,
[
'null' => null,
],
],
[
Caster::EXCLUDE_EMPTY,
[
'null' => null,
'empty' => false,
],
],
[
Caster::EXCLUDE_VIRTUAL,
[
"\0~\0virtual" => 'virt',
],
],
[
Caster::EXCLUDE_DYNAMIC,
[
"\0+\0dynamic" => 'dyn',
],
],
[
Caster::EXCLUDE_PROTECTED,
[
"\0*\0protected" => 'prot',
],
],
[
Caster::EXCLUDE_PRIVATE,
[
"\0Foo\0private" => 'priv',
],
],
[
Caster::EXCLUDE_VERBOSE,
[
'public' => 'pub',
"\0*\0protected" => 'prot',
],
['public', "\0*\0protected"],
],
[
Caster::EXCLUDE_NOT_IMPORTANT,
[
'null' => null,
'empty' => false,
"\0~\0virtual" => 'virt',
"\0+\0dynamic" => 'dyn',
"\0Foo\0private" => 'priv',
],
['public', "\0*\0protected"],
],
[
Caster::EXCLUDE_VIRTUAL | Caster::EXCLUDE_DYNAMIC,
[
"\0~\0virtual" => 'virt',
"\0+\0dynamic" => 'dyn',
],
],
[
Caster::EXCLUDE_NOT_IMPORTANT | Caster::EXCLUDE_VERBOSE,
$this->referenceArray,
['public', "\0*\0protected"],
],
[
Caster::EXCLUDE_NOT_IMPORTANT | Caster::EXCLUDE_EMPTY,
[
'null' => null,
'empty' => false,
"\0~\0virtual" => 'virt',
"\0+\0dynamic" => 'dyn',
"\0*\0protected" => 'prot',
"\0Foo\0private" => 'priv',
],
['public', 'empty'],
],
[
Caster::EXCLUDE_VERBOSE | Caster::EXCLUDE_EMPTY | Caster::EXCLUDE_STRICT,
[
'empty' => false,
],
['public', 'empty'],
],
];
}
public function testAnonymousClass()
{
$c = eval('return new class extends stdClass { private $foo = "foo"; };');
$this->assertDumpMatchesFormat(
<<<'EOTXT'
stdClass@anonymous {
-foo: "foo"
}
EOTXT
, $c
);
$c = eval('return new class { private $foo = "foo"; };');
$this->assertDumpMatchesFormat(
<<<'EOTXT'
@anonymous {
-foo: "foo"
}
EOTXT
, $c
);
}
}

View File

@@ -0,0 +1,390 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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\Caster;
use Symfony\Component\VarDumper\Caster\DateCaster;
use Symfony\Component\VarDumper\Cloner\Stub;
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
/**
* @author Dany Maillard <danymaillard93b@gmail.com>
*/
class DateCasterTest extends TestCase
{
use VarDumperTestTrait;
/**
* @dataProvider provideDateTimes
*/
public function testDumpDateTime($time, $timezone, $xDate, $xTimestamp)
{
$date = new \DateTime($time, new \DateTimeZone($timezone));
$xDump = <<<EODUMP
DateTime @$xTimestamp {
date: $xDate
}
EODUMP;
$this->assertDumpEquals($xDump, $date);
}
/**
* @dataProvider provideDateTimes
*/
public function testCastDateTime($time, $timezone, $xDate, $xTimestamp, $xInfos)
{
$stub = new Stub();
$date = new \DateTime($time, new \DateTimeZone($timezone));
$cast = DateCaster::castDateTime($date, ['foo' => 'bar'], $stub, false, 0);
$xDump = <<<EODUMP
array:1 [
"\\x00~\\x00date" => $xDate
]
EODUMP;
$this->assertDumpEquals($xDump, $cast);
$xDump = <<<EODUMP
Symfony\Component\VarDumper\Caster\ConstStub {
+type: 1
+class: "$xDate"
+value: "%A$xInfos%A"
+cut: 0
+handle: 0
+refCount: 0
+position: 0
+attr: []
}
EODUMP;
$this->assertDumpMatchesFormat($xDump, $cast["\0~\0date"]);
}
public function provideDateTimes()
{
return [
['2017-04-30 00:00:00.000000', 'Europe/Zurich', '2017-04-30 00:00:00.0 Europe/Zurich (+02:00)', 1493503200, 'Sunday, April 30, 2017%Afrom now%ADST On'],
['2017-12-31 00:00:00.000000', 'Europe/Zurich', '2017-12-31 00:00:00.0 Europe/Zurich (+01:00)', 1514674800, 'Sunday, December 31, 2017%Afrom now%ADST Off'],
['2017-04-30 00:00:00.000000', '+02:00', '2017-04-30 00:00:00.0 +02:00', 1493503200, 'Sunday, April 30, 2017%Afrom now'],
['2017-04-30 00:00:00.100000', '+00:00', '2017-04-30 00:00:00.100 +00:00', 1493510400, 'Sunday, April 30, 2017%Afrom now'],
['2017-04-30 00:00:00.120000', '+00:00', '2017-04-30 00:00:00.120 +00:00', 1493510400, 'Sunday, April 30, 2017%Afrom now'],
['2017-04-30 00:00:00.123000', '+00:00', '2017-04-30 00:00:00.123 +00:00', 1493510400, 'Sunday, April 30, 2017%Afrom now'],
['2017-04-30 00:00:00.123400', '+00:00', '2017-04-30 00:00:00.123400 +00:00', 1493510400, 'Sunday, April 30, 2017%Afrom now'],
['2017-04-30 00:00:00.123450', '+00:00', '2017-04-30 00:00:00.123450 +00:00', 1493510400, 'Sunday, April 30, 2017%Afrom now'],
['2017-04-30 00:00:00.123456', '+00:00', '2017-04-30 00:00:00.123456 +00:00', 1493510400, 'Sunday, April 30, 2017%Afrom now'],
];
}
/**
* @dataProvider provideIntervals
*/
public function testDumpInterval($intervalSpec, $ms, $invert, $expected)
{
if ($ms && \PHP_VERSION_ID >= 70200 && version_compare(PHP_VERSION, '7.2.0rc3', '<=')) {
$this->markTestSkipped('Skipped on 7.2 before rc4 because of php bug #75354.');
}
$interval = $this->createInterval($intervalSpec, $ms, $invert);
$xDump = <<<EODUMP
DateInterval {
interval: $expected
%A}
EODUMP;
$this->assertDumpMatchesFormat($xDump, $interval);
}
/**
* @dataProvider provideIntervals
*/
public function testDumpIntervalExcludingVerbosity($intervalSpec, $ms, $invert, $expected)
{
if ($ms && \PHP_VERSION_ID >= 70200 && version_compare(PHP_VERSION, '7.2.0rc3', '<=')) {
$this->markTestSkipped('Skipped on 7.2 before rc4 because of php bug #75354.');
}
$interval = $this->createInterval($intervalSpec, $ms, $invert);
$xDump = <<<EODUMP
DateInterval {
interval: $expected
}
EODUMP;
$this->assertDumpEquals($xDump, $interval, Caster::EXCLUDE_VERBOSE);
}
/**
* @dataProvider provideIntervals
*/
public function testCastInterval($intervalSpec, $ms, $invert, $xInterval, $xSeconds)
{
if ($ms && \PHP_VERSION_ID >= 70200 && version_compare(PHP_VERSION, '7.2.0rc3', '<=')) {
$this->markTestSkipped('Skipped on 7.2 before rc4 because of php bug #75354.');
}
$interval = $this->createInterval($intervalSpec, $ms, $invert);
$stub = new Stub();
$cast = DateCaster::castInterval($interval, ['foo' => 'bar'], $stub, false, Caster::EXCLUDE_VERBOSE);
$xDump = <<<EODUMP
array:1 [
"\\x00~\\x00interval" => $xInterval
]
EODUMP;
$this->assertDumpEquals($xDump, $cast);
if (null === $xSeconds) {
return;
}
$xDump = <<<EODUMP
Symfony\Component\VarDumper\Caster\ConstStub {
+type: 1
+class: "$xInterval"
+value: "$xSeconds"
+cut: 0
+handle: 0
+refCount: 0
+position: 0
+attr: []
}
EODUMP;
$this->assertDumpMatchesFormat($xDump, $cast["\0~\0interval"]);
}
public function provideIntervals()
{
return [
['PT0S', 0, 0, '0s', '0s'],
['PT0S', 0.1, 0, '+ 00:00:00.100', '%is'],
['PT1S', 0, 0, '+ 00:00:01.0', '%is'],
['PT2M', 0, 0, '+ 00:02:00.0', '%is'],
['PT3H', 0, 0, '+ 03:00:00.0', '%ss'],
['P4D', 0, 0, '+ 4d', '%ss'],
['P5M', 0, 0, '+ 5m', null],
['P6Y', 0, 0, '+ 6y', null],
['P1Y2M3DT4H5M6S', 0, 0, '+ 1y 2m 3d 04:05:06.0', null],
['PT1M60S', 0, 0, '+ 00:02:00.0', null],
['PT1H60M', 0, 0, '+ 02:00:00.0', null],
['P1DT24H', 0, 0, '+ 2d', null],
['P1M32D', 0, 0, '+ 1m 32d', null],
['PT0S', 0, 1, '0s', '0s'],
['PT0S', 0.1, 1, '- 00:00:00.100', '%is'],
['PT1S', 0, 1, '- 00:00:01.0', '%is'],
['PT2M', 0, 1, '- 00:02:00.0', '%is'],
['PT3H', 0, 1, '- 03:00:00.0', '%ss'],
['P4D', 0, 1, '- 4d', '%ss'],
['P5M', 0, 1, '- 5m', null],
['P6Y', 0, 1, '- 6y', null],
['P1Y2M3DT4H5M6S', 0, 1, '- 1y 2m 3d 04:05:06.0', null],
['PT1M60S', 0, 1, '- 00:02:00.0', null],
['PT1H60M', 0, 1, '- 02:00:00.0', null],
['P1DT24H', 0, 1, '- 2d', null],
['P1M32D', 0, 1, '- 1m 32d', null],
];
}
/**
* @dataProvider provideTimeZones
*/
public function testDumpTimeZone($timezone, $expected)
{
$timezone = new \DateTimeZone($timezone);
$xDump = <<<EODUMP
DateTimeZone {
timezone: $expected
%A}
EODUMP;
$this->assertDumpMatchesFormat($xDump, $timezone);
}
/**
* @dataProvider provideTimeZones
*/
public function testDumpTimeZoneExcludingVerbosity($timezone, $expected)
{
$timezone = new \DateTimeZone($timezone);
$xDump = <<<EODUMP
DateTimeZone {
timezone: $expected
}
EODUMP;
$this->assertDumpMatchesFormat($xDump, $timezone, Caster::EXCLUDE_VERBOSE);
}
/**
* @dataProvider provideTimeZones
*/
public function testCastTimeZone($timezone, $xTimezone, $xRegion)
{
$timezone = new \DateTimeZone($timezone);
$stub = new Stub();
$cast = DateCaster::castTimeZone($timezone, ['foo' => 'bar'], $stub, false, Caster::EXCLUDE_VERBOSE);
$xDump = <<<EODUMP
array:1 [
"\\x00~\\x00timezone" => $xTimezone
]
EODUMP;
$this->assertDumpMatchesFormat($xDump, $cast);
$xDump = <<<EODUMP
Symfony\Component\VarDumper\Caster\ConstStub {
+type: 1
+class: "$xTimezone"
+value: "$xRegion"
+cut: 0
+handle: 0
+refCount: 0
+position: 0
+attr: []
}
EODUMP;
$this->assertDumpMatchesFormat($xDump, $cast["\0~\0timezone"]);
}
public function provideTimeZones()
{
$xRegion = \extension_loaded('intl') ? '%s' : '';
return [
// type 1 (UTC offset)
['-12:00', '-12:00', ''],
['+00:00', '+00:00', ''],
['+14:00', '+14:00', ''],
// type 2 (timezone abbreviation)
['GMT', '+00:00', ''],
['a', '+01:00', ''],
['b', '+02:00', ''],
['z', '+00:00', ''],
// type 3 (timezone identifier)
['Africa/Tunis', 'Africa/Tunis (%s:00)', $xRegion],
['America/Panama', 'America/Panama (%s:00)', $xRegion],
['Asia/Jerusalem', 'Asia/Jerusalem (%s:00)', $xRegion],
['Atlantic/Canary', 'Atlantic/Canary (%s:00)', $xRegion],
['Australia/Perth', 'Australia/Perth (%s:00)', $xRegion],
['Europe/Zurich', 'Europe/Zurich (%s:00)', $xRegion],
['Pacific/Tahiti', 'Pacific/Tahiti (%s:00)', $xRegion],
];
}
/**
* @dataProvider providePeriods
*/
public function testDumpPeriod($start, $interval, $end, $options, $expected)
{
$p = new \DatePeriod(new \DateTime($start), new \DateInterval($interval), \is_int($end) ? $end : new \DateTime($end), $options);
$xDump = <<<EODUMP
DatePeriod {
period: $expected
%A}
EODUMP;
$this->assertDumpMatchesFormat($xDump, $p);
}
/**
* @dataProvider providePeriods
*/
public function testCastPeriod($start, $interval, $end, $options, $xPeriod, $xDates)
{
$p = new \DatePeriod(new \DateTime($start), new \DateInterval($interval), \is_int($end) ? $end : new \DateTime($end), $options);
$stub = new Stub();
$cast = DateCaster::castPeriod($p, [], $stub, false, 0);
$xDump = <<<EODUMP
array:1 [
"\\x00~\\x00period" => $xPeriod
]
EODUMP;
$this->assertDumpEquals($xDump, $cast);
$xDump = <<<EODUMP
Symfony\Component\VarDumper\Caster\ConstStub {
+type: 1
+class: "$xPeriod"
+value: "%A$xDates%A"
+cut: 0
+handle: 0
+refCount: 0
+position: 0
+attr: []
}
EODUMP;
$this->assertDumpMatchesFormat($xDump, $cast["\0~\0period"]);
}
public function providePeriods()
{
$periods = [
['2017-01-01', 'P1D', '2017-01-03', 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) to 2017-01-03 00:00:00.0', '1) 2017-01-01%a2) 2017-01-02'],
['2017-01-01', 'P1D', 1, 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) recurring 2 time/s', '1) 2017-01-01%a2) 2017-01-02'],
['2017-01-01', 'P1D', '2017-01-04', 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) to 2017-01-04 00:00:00.0', '1) 2017-01-01%a2) 2017-01-02%a3) 2017-01-03'],
['2017-01-01', 'P1D', 2, 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) recurring 3 time/s', '1) 2017-01-01%a2) 2017-01-02%a3) 2017-01-03'],
['2017-01-01', 'P1D', '2017-01-05', 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) to 2017-01-05 00:00:00.0', '1) 2017-01-01%a2) 2017-01-02%a1 more'],
['2017-01-01', 'P1D', 3, 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) recurring 4 time/s', '1) 2017-01-01%a2) 2017-01-02%a3) 2017-01-03%a1 more'],
['2017-01-01', 'P1D', '2017-01-21', 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) to 2017-01-21 00:00:00.0', '1) 2017-01-01%a17 more'],
['2017-01-01', 'P1D', 19, 0, 'every + 1d, from 2017-01-01 00:00:00.0 (included) recurring 20 time/s', '1) 2017-01-01%a17 more'],
['2017-01-01 01:00:00', 'P1D', '2017-01-03 01:00:00', 0, 'every + 1d, from 2017-01-01 01:00:00.0 (included) to 2017-01-03 01:00:00.0', '1) 2017-01-01 01:00:00.0%a2) 2017-01-02 01:00:00.0'],
['2017-01-01 01:00:00', 'P1D', 1, 0, 'every + 1d, from 2017-01-01 01:00:00.0 (included) recurring 2 time/s', '1) 2017-01-01 01:00:00.0%a2) 2017-01-02 01:00:00.0'],
['2017-01-01', 'P1DT1H', '2017-01-03', 0, 'every + 1d 01:00:00.0, from 2017-01-01 00:00:00.0 (included) to 2017-01-03 00:00:00.0', '1) 2017-01-01 00:00:00.0%a2) 2017-01-02 01:00:00.0'],
['2017-01-01', 'P1DT1H', 1, 0, 'every + 1d 01:00:00.0, from 2017-01-01 00:00:00.0 (included) recurring 2 time/s', '1) 2017-01-01 00:00:00.0%a2) 2017-01-02 01:00:00.0'],
['2017-01-01', 'P1D', '2017-01-04', \DatePeriod::EXCLUDE_START_DATE, 'every + 1d, from 2017-01-01 00:00:00.0 (excluded) to 2017-01-04 00:00:00.0', '1) 2017-01-02%a2) 2017-01-03'],
['2017-01-01', 'P1D', 2, \DatePeriod::EXCLUDE_START_DATE, 'every + 1d, from 2017-01-01 00:00:00.0 (excluded) recurring 2 time/s', '1) 2017-01-02%a2) 2017-01-03'],
];
if (\PHP_VERSION_ID < 70107) {
array_walk($periods, function (&$i) { $i[5] = ''; });
}
return $periods;
}
private function createInterval($intervalSpec, $ms, $invert)
{
$interval = new \DateInterval($intervalSpec);
$interval->f = $ms;
$interval->invert = $invert;
return $interval;
}
}

View File

@@ -0,0 +1,244 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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\Caster;
use Symfony\Component\VarDumper\Caster\ExceptionCaster;
use Symfony\Component\VarDumper\Caster\FrameStub;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
class ExceptionCasterTest extends TestCase
{
use VarDumperTestTrait;
private function getTestException($msg, &$ref = null)
{
return new \Exception(''.$msg);
}
protected function tearDown(): void
{
ExceptionCaster::$srcContext = 1;
ExceptionCaster::$traceArgs = true;
}
public function testDefaultSettings()
{
$ref = ['foo'];
$e = $this->getTestException('foo', $ref);
$expectedDump = <<<'EODUMP'
Exception {
#message: "foo"
#code: 0
#file: "%sExceptionCasterTest.php"
#line: 28
trace: {
%s%eTests%eCaster%eExceptionCasterTest.php:28 {
{
return new \Exception(''.$msg);
}
}
%s%eTests%eCaster%eExceptionCasterTest.php:40 { …}
%A
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $e);
$this->assertSame(['foo'], $ref);
}
public function testSeek()
{
$e = $this->getTestException(2);
$expectedDump = <<<'EODUMP'
{
%s%eTests%eCaster%eExceptionCasterTest.php:28 {
{
return new \Exception(''.$msg);
}
}
%s%eTests%eCaster%eExceptionCasterTest.php:64 { …}
%A
EODUMP;
$this->assertStringMatchesFormat($expectedDump, $this->getDump($e, 'trace'));
}
public function testNoArgs()
{
$e = $this->getTestException(1);
ExceptionCaster::$traceArgs = false;
$expectedDump = <<<'EODUMP'
Exception {
#message: "1"
#code: 0
#file: "%sExceptionCasterTest.php"
#line: 28
trace: {
%sExceptionCasterTest.php:28 {
{
return new \Exception(''.$msg);
}
}
%s%eTests%eCaster%eExceptionCasterTest.php:82 { …}
%A
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $e);
}
public function testNoSrcContext()
{
$e = $this->getTestException(1);
ExceptionCaster::$srcContext = -1;
$expectedDump = <<<'EODUMP'
Exception {
#message: "1"
#code: 0
#file: "%sExceptionCasterTest.php"
#line: 28
trace: {
%s%eTests%eCaster%eExceptionCasterTest.php:28
%s%eTests%eCaster%eExceptionCasterTest.php:%d
%A
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $e);
}
public function testHtmlDump()
{
if (ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) {
$this->markTestSkipped('A custom file_link_format is defined.');
}
$e = $this->getTestException(1);
ExceptionCaster::$srcContext = -1;
$cloner = new VarCloner();
$cloner->setMaxItems(1);
$dumper = new HtmlDumper();
$dumper->setDumpHeader('<foo></foo>');
$dumper->setDumpBoundaries('<bar>', '</bar>');
$dump = $dumper->dump($cloner->cloneVar($e)->withRefHandles(false), true);
$expectedDump = <<<'EODUMP'
<foo></foo><bar><span class=sf-dump-note>Exception</span> {<samp>
#<span class=sf-dump-protected title="Protected property">message</span>: "<span class=sf-dump-str>1</span>"
#<span class=sf-dump-protected title="Protected property">code</span>: <span class=sf-dump-num>0</span>
#<span class=sf-dump-protected title="Protected property">file</span>: "<span class=sf-dump-str title="%sExceptionCasterTest.php
%d characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class=sf-dump-ellipsis>%e</span>Tests%eCaster%eExceptionCasterTest.php</span>"
#<span class=sf-dump-protected title="Protected property">line</span>: <span class=sf-dump-num>28</span>
<span class=sf-dump-meta>trace</span>: {<samp>
<span class=sf-dump-meta title="%sExceptionCasterTest.php
Stack level %d."><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class=sf-dump-ellipsis>%e</span>Tests%eCaster%eExceptionCasterTest.php</span>:<span class=sf-dump-num>28</span>
&hellip;%d
</samp>}
</samp>}
</bar>
EODUMP;
$this->assertStringMatchesFormat($expectedDump, $dump);
}
/**
* @requires function Twig\Template::getSourceContext
*/
public function testFrameWithTwig()
{
require_once \dirname(__DIR__).'/Fixtures/Twig.php';
$f = [
new FrameStub([
'file' => \dirname(__DIR__).'/Fixtures/Twig.php',
'line' => 20,
'class' => '__TwigTemplate_VarDumperFixture_u75a09',
]),
new FrameStub([
'file' => \dirname(__DIR__).'/Fixtures/Twig.php',
'line' => 21,
'class' => '__TwigTemplate_VarDumperFixture_u75a09',
'object' => new \__TwigTemplate_VarDumperFixture_u75a09(null, __FILE__),
]),
];
$expectedDump = <<<'EODUMP'
array:2 [
0 => {
class: "__TwigTemplate_VarDumperFixture_u75a09"
src: {
%sTwig.php:1 {
foo bar
twig source
}
}
}
1 => {
class: "__TwigTemplate_VarDumperFixture_u75a09"
object: __TwigTemplate_VarDumperFixture_u75a09 {
%A
}
src: {
%sExceptionCasterTest.php:2 {
foo bar
twig source
}
}
}
]
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $f);
}
public function testExcludeVerbosity()
{
$e = $this->getTestException('foo');
$expectedDump = <<<'EODUMP'
Exception {
#message: "foo"
#code: 0
#file: "%sExceptionCasterTest.php"
#line: 28
}
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $e, Caster::EXCLUDE_VERBOSE);
}
public function testAnonymous()
{
$e = new \Exception(sprintf('Boo "%s" ba.', \get_class(new class('Foo') extends \Exception {
})));
$expectedDump = <<<'EODUMP'
Exception {
#message: "Boo "Exception@anonymous" ba."
#code: 0
#file: "%sExceptionCasterTest.php"
#line: %d
}
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $e, Caster::EXCLUDE_VERBOSE);
}
}

View File

@@ -0,0 +1,48 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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\GmpCaster;
use Symfony\Component\VarDumper\Cloner\Stub;
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
class GmpCasterTest extends TestCase
{
use VarDumperTestTrait;
/**
* @requires extension gmp
*/
public function testCastGmp()
{
$gmpString = gmp_init('1234');
$gmpOctal = gmp_init(010);
$gmp = gmp_init('01101');
$gmpDump = <<<EODUMP
array:1 [
"\\x00~\\x00value" => %s
]
EODUMP;
$this->assertDumpEquals(sprintf($gmpDump, $gmpString), GmpCaster::castGmp($gmpString, [], new Stub(), false, 0));
$this->assertDumpEquals(sprintf($gmpDump, $gmpOctal), GmpCaster::castGmp($gmpOctal, [], new Stub(), false, 0));
$this->assertDumpEquals(sprintf($gmpDump, $gmp), GmpCaster::castGmp($gmp, [], new Stub(), false, 0));
$dump = <<<EODUMP
GMP {
value: 577
}
EODUMP;
$this->assertDumpEquals($dump, $gmp);
}
}

View File

@@ -0,0 +1,297 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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\Test\VarDumperTestTrait;
/**
* @requires extension intl
*/
class IntlCasterTest extends TestCase
{
use VarDumperTestTrait;
public function testMessageFormatter()
{
$var = new \MessageFormatter('en', 'Hello {name}');
$expected = <<<EOTXT
MessageFormatter {
locale: "en"
pattern: "Hello {name}"
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testCastNumberFormatter()
{
$var = new \NumberFormatter('en', \NumberFormatter::DECIMAL);
$expectedLocale = $var->getLocale();
$expectedPattern = $var->getPattern();
$expectedAttribute1 = $var->getAttribute(\NumberFormatter::PARSE_INT_ONLY);
$expectedAttribute2 = $var->getAttribute(\NumberFormatter::GROUPING_USED);
$expectedAttribute3 = $var->getAttribute(\NumberFormatter::DECIMAL_ALWAYS_SHOWN);
$expectedAttribute4 = $var->getAttribute(\NumberFormatter::MAX_INTEGER_DIGITS);
$expectedAttribute5 = $var->getAttribute(\NumberFormatter::MIN_INTEGER_DIGITS);
$expectedAttribute6 = $var->getAttribute(\NumberFormatter::INTEGER_DIGITS);
$expectedAttribute7 = $var->getAttribute(\NumberFormatter::MAX_FRACTION_DIGITS);
$expectedAttribute8 = $var->getAttribute(\NumberFormatter::MIN_FRACTION_DIGITS);
$expectedAttribute9 = $var->getAttribute(\NumberFormatter::FRACTION_DIGITS);
$expectedAttribute10 = $var->getAttribute(\NumberFormatter::MULTIPLIER);
$expectedAttribute11 = $var->getAttribute(\NumberFormatter::GROUPING_SIZE);
$expectedAttribute12 = $var->getAttribute(\NumberFormatter::ROUNDING_MODE);
$expectedAttribute13 = number_format($var->getAttribute(\NumberFormatter::ROUNDING_INCREMENT), 1);
$expectedAttribute14 = $this->getDump($var->getAttribute(\NumberFormatter::FORMAT_WIDTH));
$expectedAttribute15 = $var->getAttribute(\NumberFormatter::PADDING_POSITION);
$expectedAttribute16 = $var->getAttribute(\NumberFormatter::SECONDARY_GROUPING_SIZE);
$expectedAttribute17 = $var->getAttribute(\NumberFormatter::SIGNIFICANT_DIGITS_USED);
$expectedAttribute18 = $this->getDump($var->getAttribute(\NumberFormatter::MIN_SIGNIFICANT_DIGITS));
$expectedAttribute19 = $this->getDump($var->getAttribute(\NumberFormatter::MAX_SIGNIFICANT_DIGITS));
$expectedAttribute20 = $var->getAttribute(\NumberFormatter::LENIENT_PARSE);
$expectedTextAttribute1 = $var->getTextAttribute(\NumberFormatter::POSITIVE_PREFIX);
$expectedTextAttribute2 = $var->getTextAttribute(\NumberFormatter::POSITIVE_SUFFIX);
$expectedTextAttribute3 = $var->getTextAttribute(\NumberFormatter::NEGATIVE_PREFIX);
$expectedTextAttribute4 = $var->getTextAttribute(\NumberFormatter::NEGATIVE_SUFFIX);
$expectedTextAttribute5 = $var->getTextAttribute(\NumberFormatter::PADDING_CHARACTER);
$expectedTextAttribute6 = $var->getTextAttribute(\NumberFormatter::CURRENCY_CODE);
$expectedTextAttribute7 = $var->getTextAttribute(\NumberFormatter::DEFAULT_RULESET) ? 'true' : 'false';
$expectedTextAttribute8 = $var->getTextAttribute(\NumberFormatter::PUBLIC_RULESETS) ? 'true' : 'false';
$expectedSymbol1 = $var->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
$expectedSymbol2 = $var->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL);
$expectedSymbol3 = $var->getSymbol(\NumberFormatter::PATTERN_SEPARATOR_SYMBOL);
$expectedSymbol4 = $var->getSymbol(\NumberFormatter::PERCENT_SYMBOL);
$expectedSymbol5 = $var->getSymbol(\NumberFormatter::ZERO_DIGIT_SYMBOL);
$expectedSymbol6 = $var->getSymbol(\NumberFormatter::DIGIT_SYMBOL);
$expectedSymbol7 = $var->getSymbol(\NumberFormatter::MINUS_SIGN_SYMBOL);
$expectedSymbol8 = $var->getSymbol(\NumberFormatter::PLUS_SIGN_SYMBOL);
$expectedSymbol9 = $var->getSymbol(\NumberFormatter::CURRENCY_SYMBOL);
$expectedSymbol10 = $var->getSymbol(\NumberFormatter::INTL_CURRENCY_SYMBOL);
$expectedSymbol11 = $var->getSymbol(\NumberFormatter::MONETARY_SEPARATOR_SYMBOL);
$expectedSymbol12 = $var->getSymbol(\NumberFormatter::EXPONENTIAL_SYMBOL);
$expectedSymbol13 = $var->getSymbol(\NumberFormatter::PERMILL_SYMBOL);
$expectedSymbol14 = $var->getSymbol(\NumberFormatter::PAD_ESCAPE_SYMBOL);
$expectedSymbol15 = $var->getSymbol(\NumberFormatter::INFINITY_SYMBOL);
$expectedSymbol16 = $var->getSymbol(\NumberFormatter::NAN_SYMBOL);
$expectedSymbol17 = $var->getSymbol(\NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL);
$expectedSymbol18 = $var->getSymbol(\NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL);
$expected = <<<EOTXT
NumberFormatter {
locale: "$expectedLocale"
pattern: "$expectedPattern"
attributes: {
PARSE_INT_ONLY: $expectedAttribute1
GROUPING_USED: $expectedAttribute2
DECIMAL_ALWAYS_SHOWN: $expectedAttribute3
MAX_INTEGER_DIGITS: $expectedAttribute4
MIN_INTEGER_DIGITS: $expectedAttribute5
INTEGER_DIGITS: $expectedAttribute6
MAX_FRACTION_DIGITS: $expectedAttribute7
MIN_FRACTION_DIGITS: $expectedAttribute8
FRACTION_DIGITS: $expectedAttribute9
MULTIPLIER: $expectedAttribute10
GROUPING_SIZE: $expectedAttribute11
ROUNDING_MODE: $expectedAttribute12
ROUNDING_INCREMENT: $expectedAttribute13
FORMAT_WIDTH: $expectedAttribute14
PADDING_POSITION: $expectedAttribute15
SECONDARY_GROUPING_SIZE: $expectedAttribute16
SIGNIFICANT_DIGITS_USED: $expectedAttribute17
MIN_SIGNIFICANT_DIGITS: $expectedAttribute18
MAX_SIGNIFICANT_DIGITS: $expectedAttribute19
LENIENT_PARSE: $expectedAttribute20
}
text_attributes: {
POSITIVE_PREFIX: "$expectedTextAttribute1"
POSITIVE_SUFFIX: "$expectedTextAttribute2"
NEGATIVE_PREFIX: "$expectedTextAttribute3"
NEGATIVE_SUFFIX: "$expectedTextAttribute4"
PADDING_CHARACTER: "$expectedTextAttribute5"
CURRENCY_CODE: "$expectedTextAttribute6"
DEFAULT_RULESET: $expectedTextAttribute7
PUBLIC_RULESETS: $expectedTextAttribute8
}
symbols: {
DECIMAL_SEPARATOR_SYMBOL: "$expectedSymbol1"
GROUPING_SEPARATOR_SYMBOL: "$expectedSymbol2"
PATTERN_SEPARATOR_SYMBOL: "$expectedSymbol3"
PERCENT_SYMBOL: "$expectedSymbol4"
ZERO_DIGIT_SYMBOL: "$expectedSymbol5"
DIGIT_SYMBOL: "$expectedSymbol6"
MINUS_SIGN_SYMBOL: "$expectedSymbol7"
PLUS_SIGN_SYMBOL: "$expectedSymbol8"
CURRENCY_SYMBOL: "$expectedSymbol9"
INTL_CURRENCY_SYMBOL: "$expectedSymbol10"
MONETARY_SEPARATOR_SYMBOL: "$expectedSymbol11"
EXPONENTIAL_SYMBOL: "$expectedSymbol12"
PERMILL_SYMBOL: "$expectedSymbol13"
PAD_ESCAPE_SYMBOL: "$expectedSymbol14"
INFINITY_SYMBOL: "$expectedSymbol15"
NAN_SYMBOL: "$expectedSymbol16"
SIGNIFICANT_DIGIT_SYMBOL: "$expectedSymbol17"
MONETARY_GROUPING_SEPARATOR_SYMBOL: "$expectedSymbol18"
}
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testCastIntlTimeZoneWithDST()
{
$var = \IntlTimeZone::createTimeZone('America/Los_Angeles');
$expectedDisplayName = $var->getDisplayName();
$expectedDSTSavings = $var->getDSTSavings();
$expectedID = $var->getID();
$expectedRawOffset = $var->getRawOffset();
$expected = <<<EOTXT
IntlTimeZone {
display_name: "$expectedDisplayName"
id: "$expectedID"
raw_offset: $expectedRawOffset
dst_savings: $expectedDSTSavings
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testCastIntlTimeZoneWithoutDST()
{
$var = \IntlTimeZone::createTimeZone('Asia/Bangkok');
$expectedDisplayName = $var->getDisplayName();
$expectedID = $var->getID();
$expectedRawOffset = $var->getRawOffset();
$expected = <<<EOTXT
IntlTimeZone {
display_name: "$expectedDisplayName"
id: "$expectedID"
raw_offset: $expectedRawOffset
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testCastIntlCalendar()
{
$var = \IntlCalendar::createInstance('America/Los_Angeles', 'en');
$expectedType = $var->getType();
$expectedFirstDayOfWeek = $var->getFirstDayOfWeek();
$expectedMinimalDaysInFirstWeek = $var->getMinimalDaysInFirstWeek();
$expectedRepeatedWallTimeOption = $var->getRepeatedWallTimeOption();
$expectedSkippedWallTimeOption = $var->getSkippedWallTimeOption();
$expectedTime = $var->getTime().'.0';
$expectedInDaylightTime = $var->inDaylightTime() ? 'true' : 'false';
$expectedIsLenient = $var->isLenient() ? 'true' : 'false';
$expectedTimeZone = $var->getTimeZone();
$expectedTimeZoneDisplayName = $expectedTimeZone->getDisplayName();
$expectedTimeZoneID = $expectedTimeZone->getID();
$expectedTimeZoneRawOffset = $expectedTimeZone->getRawOffset();
$expectedTimeZoneDSTSavings = $expectedTimeZone->getDSTSavings();
$expected = <<<EOTXT
IntlGregorianCalendar {
type: "$expectedType"
first_day_of_week: $expectedFirstDayOfWeek
minimal_days_in_first_week: $expectedMinimalDaysInFirstWeek
repeated_wall_time_option: $expectedRepeatedWallTimeOption
skipped_wall_time_option: $expectedSkippedWallTimeOption
time: $expectedTime
in_daylight_time: $expectedInDaylightTime
is_lenient: $expectedIsLenient
time_zone: IntlTimeZone {
display_name: "$expectedTimeZoneDisplayName"
id: "$expectedTimeZoneID"
raw_offset: $expectedTimeZoneRawOffset
dst_savings: $expectedTimeZoneDSTSavings
}
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testCastDateFormatter()
{
$var = new \IntlDateFormatter('en', \IntlDateFormatter::TRADITIONAL, \IntlDateFormatter::TRADITIONAL);
$expectedLocale = $var->getLocale();
$expectedPattern = $var->getPattern();
$expectedCalendar = $var->getCalendar();
$expectedTimeZoneId = $var->getTimeZoneId();
$expectedTimeType = $var->getTimeType();
$expectedDateType = $var->getDateType();
$expectedTimeZone = $var->getTimeZone();
$expectedTimeZoneDisplayName = $expectedTimeZone->getDisplayName();
$expectedTimeZoneID = $expectedTimeZone->getID();
$expectedTimeZoneRawOffset = $expectedTimeZone->getRawOffset();
$expectedTimeZoneDSTSavings = $expectedTimeZone->useDaylightTime() ? "\n dst_savings: ".$expectedTimeZone->getDSTSavings() : '';
$expectedCalendarObject = $var->getCalendarObject();
$expectedCalendarObjectType = $expectedCalendarObject->getType();
$expectedCalendarObjectFirstDayOfWeek = $expectedCalendarObject->getFirstDayOfWeek();
$expectedCalendarObjectMinimalDaysInFirstWeek = $expectedCalendarObject->getMinimalDaysInFirstWeek();
$expectedCalendarObjectRepeatedWallTimeOption = $expectedCalendarObject->getRepeatedWallTimeOption();
$expectedCalendarObjectSkippedWallTimeOption = $expectedCalendarObject->getSkippedWallTimeOption();
$expectedCalendarObjectTime = $expectedCalendarObject->getTime().'.0';
$expectedCalendarObjectInDaylightTime = $expectedCalendarObject->inDaylightTime() ? 'true' : 'false';
$expectedCalendarObjectIsLenient = $expectedCalendarObject->isLenient() ? 'true' : 'false';
$expectedCalendarObjectTimeZone = $expectedCalendarObject->getTimeZone();
$expectedCalendarObjectTimeZoneDisplayName = $expectedCalendarObjectTimeZone->getDisplayName();
$expectedCalendarObjectTimeZoneID = $expectedCalendarObjectTimeZone->getID();
$expectedCalendarObjectTimeZoneRawOffset = $expectedCalendarObjectTimeZone->getRawOffset();
$expectedCalendarObjectTimeZoneDSTSavings = $expectedTimeZone->useDaylightTime() ? "\n dst_savings: ".$expectedCalendarObjectTimeZone->getDSTSavings() : '';
$expected = <<<EOTXT
IntlDateFormatter {
locale: "$expectedLocale"
pattern: "$expectedPattern"
calendar: $expectedCalendar
time_zone_id: "$expectedTimeZoneId"
time_type: $expectedTimeType
date_type: $expectedDateType
calendar_object: IntlGregorianCalendar {
type: "$expectedCalendarObjectType"
first_day_of_week: $expectedCalendarObjectFirstDayOfWeek
minimal_days_in_first_week: $expectedCalendarObjectMinimalDaysInFirstWeek
repeated_wall_time_option: $expectedCalendarObjectRepeatedWallTimeOption
skipped_wall_time_option: $expectedCalendarObjectSkippedWallTimeOption
time: $expectedCalendarObjectTime
in_daylight_time: $expectedCalendarObjectInDaylightTime
is_lenient: $expectedCalendarObjectIsLenient
time_zone: IntlTimeZone {
display_name: "$expectedCalendarObjectTimeZoneDisplayName"
id: "$expectedCalendarObjectTimeZoneID"
raw_offset: $expectedCalendarObjectTimeZoneRawOffset$expectedCalendarObjectTimeZoneDSTSavings
}
}
time_zone: IntlTimeZone {
display_name: "$expectedTimeZoneDisplayName"
id: "$expectedTimeZoneID"
raw_offset: $expectedTimeZoneRawOffset$expectedTimeZoneDSTSavings
}
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
}

View File

@@ -0,0 +1,93 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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\Test\VarDumperTestTrait;
/**
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
*/
class MemcachedCasterTest extends TestCase
{
use VarDumperTestTrait;
public function testCastMemcachedWithDefaultOptions()
{
if (!class_exists('Memcached')) {
$this->markTestSkipped('Memcached not available');
}
$var = new \Memcached();
$var->addServer('127.0.0.1', 11211);
$var->addServer('127.0.0.2', 11212);
$expected = <<<EOTXT
Memcached {
servers: array:2 [
0 => array:3 [
"host" => "127.0.0.1"
"port" => 11211
"type" => "TCP"
]
1 => array:3 [
"host" => "127.0.0.2"
"port" => 11212
"type" => "TCP"
]
]
options: {}
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testCastMemcachedWithCustomOptions()
{
if (!class_exists('Memcached')) {
$this->markTestSkipped('Memcached not available');
}
$var = new \Memcached();
$var->addServer('127.0.0.1', 11211);
$var->addServer('127.0.0.2', 11212);
// set a subset of non default options to test boolean, string and integer output
$var->setOption(\Memcached::OPT_COMPRESSION, false);
$var->setOption(\Memcached::OPT_PREFIX_KEY, 'pre');
$var->setOption(\Memcached::OPT_DISTRIBUTION, \Memcached::DISTRIBUTION_CONSISTENT);
$expected = <<<'EOTXT'
Memcached {
servers: array:2 [
0 => array:3 [
"host" => "127.0.0.1"
"port" => 11211
"type" => "TCP"
]
1 => array:3 [
"host" => "127.0.0.2"
"port" => 11212
"type" => "TCP"
]
]
options: {
OPT_COMPRESSION: false
OPT_PREFIX_KEY: "pre"
OPT_DISTRIBUTION: 1
}
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
}

View File

@@ -0,0 +1,64 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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\PdoCaster;
use Symfony\Component\VarDumper\Cloner\Stub;
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
class PdoCasterTest extends TestCase
{
use VarDumperTestTrait;
/**
* @requires extension pdo_sqlite
*/
public function testCastPdo()
{
$pdo = new \PDO('sqlite::memory:');
$pdo->setAttribute(\PDO::ATTR_STATEMENT_CLASS, ['PDOStatement', [$pdo]]);
$cast = PdoCaster::castPdo($pdo, [], new Stub(), false);
$this->assertInstanceOf('Symfony\Component\VarDumper\Caster\EnumStub', $cast["\0~\0attributes"]);
$attr = $cast["\0~\0attributes"] = $cast["\0~\0attributes"]->value;
$this->assertInstanceOf('Symfony\Component\VarDumper\Caster\ConstStub', $attr['CASE']);
$this->assertSame('NATURAL', $attr['CASE']->class);
$this->assertSame('BOTH', $attr['DEFAULT_FETCH_MODE']->class);
$xDump = <<<'EODUMP'
array:2 [
"\x00~\x00inTransaction" => false
"\x00~\x00attributes" => array:9 [
"CASE" => NATURAL
"ERRMODE" => SILENT
"PERSISTENT" => false
"DRIVER_NAME" => "sqlite"
"ORACLE_NULLS" => NATURAL
"CLIENT_VERSION" => "%s"
"SERVER_VERSION" => "%s"
"STATEMENT_CLASS" => array:%d [
0 => "PDOStatement"%A
]
"DEFAULT_FETCH_MODE" => BOTH
]
]
EODUMP;
$this->assertDumpMatchesFormat($xDump, $cast);
}
}

View File

@@ -0,0 +1,70 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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\Test\VarDumperTestTrait;
/**
* @author Nicolas Grekas <p@tchwork.com>
* @requires extension redis
*/
class RedisCasterTest extends TestCase
{
use VarDumperTestTrait;
public function testNotConnected()
{
$redis = new \Redis();
$xCast = <<<'EODUMP'
Redis {
isConnected: false
}
EODUMP;
$this->assertDumpMatchesFormat($xCast, $redis);
}
public function testConnected()
{
$redis = new \Redis();
if (!@$redis->connect('127.0.0.1')) {
$e = error_get_last();
self::markTestSkipped($e['message']);
}
$xCast = <<<'EODUMP'
Redis {%A
isConnected: true
host: "127.0.0.1"
port: 6379
auth: null
mode: ATOMIC
dbNum: 0
timeout: 0.0
lastError: null
persistentId: null
options: {
TCP_KEEPALIVE: 0
READ_TIMEOUT: 0.0
COMPRESSION: NONE
SERIALIZER: NONE
PREFIX: null
SCAN: NORETRY
}
}
EODUMP;
$this->assertDumpMatchesFormat($xCast, $redis);
}
}

View File

@@ -0,0 +1,256 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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\Caster;
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
use Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo;
use Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
class ReflectionCasterTest extends TestCase
{
use VarDumperTestTrait;
public function testReflectionCaster()
{
$var = new \ReflectionClass('ReflectionClass');
$this->assertDumpMatchesFormat(
<<<'EOTXT'
ReflectionClass {
+name: "ReflectionClass"
%Aimplements: array:%d [
0 => "Reflector"
%A]
constants: array:3 [
"IS_IMPLICIT_ABSTRACT" => 16
"IS_EXPLICIT_ABSTRACT" => %d
"IS_FINAL" => %d
]
properties: array:%d [
"name" => ReflectionProperty {
%A +name: "name"
+class: "ReflectionClass"
%A modifiers: "public"
}
%A]
methods: array:%d [
%A
"export" => ReflectionMethod {
+name: "export"
+class: "ReflectionClass"
%A parameters: {
$%s: ReflectionParameter {
%A position: 0
%A
}
EOTXT
, $var
);
}
public function testClosureCaster()
{
$a = $b = 123;
$var = function ($x) use ($a, &$b) {};
$this->assertDumpMatchesFormat(
<<<'EOTXT'
Closure($x) {
%Ause: {
$a: 123
$b: & 123
}
file: "%sReflectionCasterTest.php"
line: "68 to 68"
}
EOTXT
, $var
);
}
public function testFromCallableClosureCaster()
{
if (\defined('HHVM_VERSION_ID')) {
$this->markTestSkipped('Not for HHVM.');
}
$var = [
(new \ReflectionMethod($this, __FUNCTION__))->getClosure($this),
(new \ReflectionMethod(__CLASS__, 'stub'))->getClosure(),
];
$this->assertDumpMatchesFormat(
<<<EOTXT
array:2 [
0 => Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest::testFromCallableClosureCaster() {
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
file: "%sReflectionCasterTest.php"
line: "%d to %d"
}
1 => Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest::stub(): void {
returnType: "void"
file: "%sReflectionCasterTest.php"
line: "%d to %d"
}
]
EOTXT
, $var
);
}
public function testClosureCasterExcludingVerbosity()
{
$var = function &($a = 5) {};
$this->assertDumpEquals('Closure&($a = 5) { …5}', $var, Caster::EXCLUDE_VERBOSE);
}
public function testReflectionParameter()
{
$var = new \ReflectionParameter(__NAMESPACE__.'\reflectionParameterFixture', 0);
$this->assertDumpMatchesFormat(
<<<'EOTXT'
ReflectionParameter {
+name: "arg1"
position: 0
typeHint: "Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass"
default: null
}
EOTXT
, $var
);
}
public function testReflectionParameterScalar()
{
$f = eval('return function (int $a) {};');
$var = new \ReflectionParameter($f, 0);
$this->assertDumpMatchesFormat(
<<<'EOTXT'
ReflectionParameter {
+name: "a"
position: 0
typeHint: "int"
}
EOTXT
, $var
);
}
public function testReturnType()
{
$f = eval('return function ():int {};');
$line = __LINE__ - 1;
$this->assertDumpMatchesFormat(
<<<EOTXT
Closure(): int {
returnType: "int"
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
file: "%sReflectionCasterTest.php($line) : eval()'d code"
line: "1 to 1"
}
EOTXT
, $f
);
}
public function testGenerator()
{
if (\extension_loaded('xdebug')) {
$this->markTestSkipped('xdebug is active');
}
$generator = new GeneratorDemo();
$generator = $generator->baz();
$expectedDump = <<<'EODUMP'
Generator {
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
executing: {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() {
%sGeneratorDemo.php:14 {
{
yield from bar();
}
}
}
}
closed: false
}
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $generator);
foreach ($generator as $v) {
break;
}
$expectedDump = <<<'EODUMP'
array:2 [
0 => ReflectionGenerator {
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
trace: {
%s%eTests%eFixtures%eGeneratorDemo.php:9 {
{
yield 1;
}
}
%s%eTests%eFixtures%eGeneratorDemo.php:20 { …}
%s%eTests%eFixtures%eGeneratorDemo.php:14 { …}
}
closed: false
}
1 => Generator {
executing: {
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo() {
%sGeneratorDemo.php:10 {
yield 1;
}
}
}
}
closed: false
}
]
EODUMP;
$r = new \ReflectionGenerator($generator);
$this->assertDumpMatchesFormat($expectedDump, [$r, $r->getExecutingGenerator()]);
foreach ($generator as $v) {
}
$expectedDump = <<<'EODUMP'
Generator {
closed: true
}
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $generator);
}
public static function stub(): void
{
}
}
function reflectionParameterFixture(NotLoadableClass $arg1 = null, $arg2)
{
}

View File

@@ -0,0 +1,226 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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\Test\VarDumperTestTrait;
/**
* @author Grégoire Pineau <lyrixx@lyrixx.info>
*/
class SplCasterTest extends TestCase
{
use VarDumperTestTrait;
public function getCastFileInfoTests()
{
return [
[__FILE__, <<<'EOTXT'
SplFileInfo {
%Apath: "%sCaster"
filename: "SplCasterTest.php"
basename: "SplCasterTest.php"
pathname: "%sSplCasterTest.php"
extension: "php"
realPath: "%sSplCasterTest.php"
aTime: %s-%s-%d %d:%d:%d
mTime: %s-%s-%d %d:%d:%d
cTime: %s-%s-%d %d:%d:%d
inode: %i
size: %d
perms: 0%d
owner: %d
group: %d
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
%A}
EOTXT
],
['https://example.com/about', <<<'EOTXT'
SplFileInfo {
%Apath: "https://example.com"
filename: "about"
basename: "about"
pathname: "https://example.com/about"
extension: ""
realPath: false
%A}
EOTXT
],
];
}
/** @dataProvider getCastFileInfoTests */
public function testCastFileInfo($file, $dump)
{
$this->assertDumpMatchesFormat($dump, new \SplFileInfo($file));
}
public function testCastFileObject()
{
$var = new \SplFileObject(__FILE__);
$var->setFlags(\SplFileObject::DROP_NEW_LINE | \SplFileObject::SKIP_EMPTY);
$dump = <<<'EOTXT'
SplFileObject {
%Apath: "%sCaster"
filename: "SplCasterTest.php"
basename: "SplCasterTest.php"
pathname: "%sSplCasterTest.php"
extension: "php"
realPath: "%sSplCasterTest.php"
aTime: %s-%s-%d %d:%d:%d
mTime: %s-%s-%d %d:%d:%d
cTime: %s-%s-%d %d:%d:%d
inode: %i
size: %d
perms: 0%d
owner: %d
group: %d
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
%AcsvControl: array:%d [
0 => ","
1 => """
%A]
flags: DROP_NEW_LINE|SKIP_EMPTY
maxLineLen: 0
fstat: array:26 [
"dev" => %d
"ino" => %i
"nlink" => %d
"rdev" => 0
"blksize" => %i
"blocks" => %i
…20
]
eof: false
key: 0
}
EOTXT;
$this->assertDumpMatchesFormat($dump, $var);
}
/**
* @dataProvider provideCastSplDoublyLinkedList
*/
public function testCastSplDoublyLinkedList($modeValue, $modeDump)
{
$var = new \SplDoublyLinkedList();
$var->setIteratorMode($modeValue);
$dump = <<<EOTXT
SplDoublyLinkedList {
%Amode: $modeDump
dllist: []
}
EOTXT;
$this->assertDumpMatchesFormat($dump, $var);
}
public function provideCastSplDoublyLinkedList()
{
return [
[\SplDoublyLinkedList::IT_MODE_FIFO, 'IT_MODE_FIFO | IT_MODE_KEEP'],
[\SplDoublyLinkedList::IT_MODE_LIFO, 'IT_MODE_LIFO | IT_MODE_KEEP'],
[\SplDoublyLinkedList::IT_MODE_FIFO | \SplDoublyLinkedList::IT_MODE_DELETE, 'IT_MODE_FIFO | IT_MODE_DELETE'],
[\SplDoublyLinkedList::IT_MODE_LIFO | \SplDoublyLinkedList::IT_MODE_DELETE, 'IT_MODE_LIFO | IT_MODE_DELETE'],
];
}
public function testCastObjectStorageIsntModified()
{
$var = new \SplObjectStorage();
$var->attach(new \stdClass());
$var->rewind();
$current = $var->current();
$this->assertDumpMatchesFormat('%A', $var);
$this->assertSame($current, $var->current());
}
public function testCastObjectStorageDumpsInfo()
{
$var = new \SplObjectStorage();
$var->attach(new \stdClass(), new \DateTime());
$this->assertDumpMatchesFormat('%ADateTime%A', $var);
}
public function testCastArrayObject()
{
$var = new \ArrayObject([123]);
$var->foo = 234;
$expected = <<<EOTXT
ArrayObject {
+"foo": 234
flag::STD_PROP_LIST: false
flag::ARRAY_AS_PROPS: false
iteratorClass: "ArrayIterator"
storage: array:1 [
0 => 123
]
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testArrayIterator()
{
$var = new MyArrayIterator([234]);
$expected = <<<EOTXT
Symfony\Component\VarDumper\Tests\Caster\MyArrayIterator {
-foo: 123
flag::STD_PROP_LIST: false
flag::ARRAY_AS_PROPS: false
storage: array:1 [
0 => 234
]
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testBadSplFileInfo()
{
$var = new BadSplFileInfo();
$expected = <<<EOTXT
Symfony\Component\VarDumper\Tests\Caster\BadSplFileInfo {
⚠: "The parent constructor was not called: the object is in an invalid state"
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
}
class MyArrayIterator extends \ArrayIterator
{
private $foo = 123;
}
class BadSplFileInfo extends \SplFileInfo
{
public function __construct()
{
}
}

View File

@@ -0,0 +1,213 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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 = [new ArgsStub([123], __FUNCTION__, __CLASS__)];
$expectedDump = <<<'EODUMP'
array:1 [
0 => {
$foo: 123
}
]
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $args);
}
public function testArgsStubWithExtraArgs($foo = 234)
{
$args = [new ArgsStub([123, 456], __FUNCTION__, __CLASS__)];
$expectedDump = <<<'EODUMP'
array:1 [
0 => {
$foo: 123
...: {
456
}
}
]
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $args);
}
public function testArgsStubNoParamWithExtraArgs()
{
$args = [new ArgsStub([123], __FUNCTION__, __CLASS__)];
$expectedDump = <<<'EODUMP'
array:1 [
0 => {
123
}
]
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $args);
}
public function testArgsStubWithClosure()
{
$args = [new ArgsStub([123], '{closure}', null)];
$expectedDump = <<<'EODUMP'
array:1 [
0 => {
123
}
]
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $args);
}
public function testLinkStub()
{
$var = [new LinkStub(__CLASS__, 0, __FILE__)];
$cloner = new VarCloner();
$dumper = new HtmlDumper();
$dumper->setDumpHeader('<foo></foo>');
$dumper->setDumpBoundaries('<bar>', '</bar>');
$dumper->setDisplayOptions(['fileLinkFormat' => '%f:%l']);
$dump = $dumper->dump($cloner->cloneVar($var), true);
$expectedDump = <<<'EODUMP'
<foo></foo><bar><span class=sf-dump-note>array:1</span> [<samp>
<span class=sf-dump-index>0</span> => "<a href="%sStubCasterTest.php:0" rel="noopener noreferrer"><span class=sf-dump-str title="55 characters">Symfony\Component\VarDumper\Tests\Caster\StubCasterTest</span></a>"
</samp>]
</bar>
EODUMP;
$this->assertStringMatchesFormat($expectedDump, $dump);
}
public function testLinkStubWithNoFileLink()
{
$var = [new LinkStub('example.com', 0, 'http://example.com')];
$cloner = new VarCloner();
$dumper = new HtmlDumper();
$dumper->setDumpHeader('<foo></foo>');
$dumper->setDumpBoundaries('<bar>', '</bar>');
$dumper->setDisplayOptions(['fileLinkFormat' => '%f:%l']);
$dump = $dumper->dump($cloner->cloneVar($var), true);
$expectedDump = <<<'EODUMP'
<foo></foo><bar><span class=sf-dump-note>array:1</span> [<samp>
<span class=sf-dump-index>0</span> => "<a href="http://example.com" target="_blank" rel="noopener noreferrer"><span class=sf-dump-str title="11 characters">example.com</span></a>"
</samp>]
</bar>
EODUMP;
$this->assertStringMatchesFormat($expectedDump, $dump);
}
public function testClassStub()
{
$var = [new ClassStub('hello', [FooInterface::class, 'foo'])];
$cloner = new VarCloner();
$dumper = new HtmlDumper();
$dumper->setDumpHeader('<foo></foo>');
$dumper->setDumpBoundaries('<bar>', '</bar>');
$dump = $dumper->dump($cloner->cloneVar($var), true, ['fileLinkFormat' => '%f:%l']);
$expectedDump = <<<'EODUMP'
<foo></foo><bar><span class=sf-dump-note>array:1</span> [<samp>
<span class=sf-dump-index>0</span> => "<a href="%sFooInterface.php:10" rel="noopener noreferrer"><span class=sf-dump-str title="39 characters">hello(?stdClass $a, stdClass $b = null)</span></a>"
</samp>]
</bar>
EODUMP;
$this->assertStringMatchesFormat($expectedDump, $dump);
}
public function testClassStubWithNotExistingClass()
{
$var = [new ClassStub(NotExisting::class)];
$cloner = new VarCloner();
$dumper = new HtmlDumper();
$dumper->setDumpHeader('<foo></foo>');
$dumper->setDumpBoundaries('<bar>', '</bar>');
$dump = $dumper->dump($cloner->cloneVar($var), true);
$expectedDump = <<<'EODUMP'
<foo></foo><bar><span class=sf-dump-note>array:1</span> [<samp>
<span class=sf-dump-index>0</span> => "<span class=sf-dump-str title="Symfony\Component\VarDumper\Tests\Caster\NotExisting
52 characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-class">Symfony\Component\VarDumper\Tests\Caster</span><span class=sf-dump-ellipsis>\</span>NotExisting</span>"
</samp>]
</bar>
EODUMP;
$this->assertStringMatchesFormat($expectedDump, $dump);
}
public function testClassStubWithNotExistingMethod()
{
$var = [new ClassStub('hello', [FooInterface::class, 'missing'])];
$cloner = new VarCloner();
$dumper = new HtmlDumper();
$dumper->setDumpHeader('<foo></foo>');
$dumper->setDumpBoundaries('<bar>', '</bar>');
$dump = $dumper->dump($cloner->cloneVar($var), true, ['fileLinkFormat' => '%f:%l']);
$expectedDump = <<<'EODUMP'
<foo></foo><bar><span class=sf-dump-note>array:1</span> [<samp>
<span class=sf-dump-index>0</span> => "<a href="%sFooInterface.php:5" rel="noopener noreferrer"><span class=sf-dump-str title="5 characters">hello</span></a>"
</samp>]
</bar>
EODUMP;
$this->assertStringMatchesFormat($expectedDump, $dump);
}
public function testClassStubWithAnonymousClass()
{
$var = [new ClassStub(\get_class(new class() extends \Exception {
}))];
$cloner = new VarCloner();
$dumper = new HtmlDumper();
$dumper->setDumpHeader('<foo></foo>');
$dumper->setDumpBoundaries('<bar>', '</bar>');
$dump = $dumper->dump($cloner->cloneVar($var), true, ['fileLinkFormat' => '%f:%l']);
$expectedDump = <<<'EODUMP'
<foo></foo><bar><span class=sf-dump-note>array:1</span> [<samp>
<span class=sf-dump-index>0</span> => "<a href="%sStubCasterTest.php:195" rel="noopener noreferrer"><span class=sf-dump-str title="19 characters">Exception@anonymous</span></a>"
</samp>]
</bar>
EODUMP;
$this->assertStringMatchesFormat($expectedDump, $dump);
}
}

View File

@@ -0,0 +1,248 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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\Test\VarDumperTestTrait;
/**
* @author Baptiste Clavié <clavie.b@gmail.com>
*/
class XmlReaderCasterTest extends TestCase
{
use VarDumperTestTrait;
/** @var \XmlReader */
private $reader;
protected function setUp(): void
{
$this->reader = new \XmlReader();
$this->reader->open(__DIR__.'/../Fixtures/xml_reader.xml');
}
protected function tearDown(): void
{
$this->reader->close();
}
public function testParserProperty()
{
$this->reader->setParserProperty(\XMLReader::SUBST_ENTITIES, true);
$expectedDump = <<<'EODUMP'
XMLReader {
+nodeType: NONE
parserProperties: {
SUBST_ENTITIES: true
…3
}
…12
}
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $this->reader);
}
/**
* @dataProvider provideNodes
*/
public function testNodes($seek, $expectedDump)
{
while ($seek--) {
$this->reader->read();
}
$this->assertDumpMatchesFormat($expectedDump, $this->reader);
}
public function provideNodes()
{
return [
[0, <<<'EODUMP'
XMLReader {
+nodeType: NONE
…13
}
EODUMP
],
[1, <<<'EODUMP'
XMLReader {
+localName: "foo"
+nodeType: ELEMENT
+baseURI: "%sxml_reader.xml"
…11
}
EODUMP
],
[2, <<<'EODUMP'
XMLReader {
+localName: "#text"
+nodeType: SIGNIFICANT_WHITESPACE
+depth: 1
+value: """
\n
"""
+baseURI: "%sxml_reader.xml"
…9
}
EODUMP
],
[3, <<<'EODUMP'
XMLReader {
+localName: "bar"
+nodeType: ELEMENT
+depth: 1
+baseURI: "%sxml_reader.xml"
…10
}
EODUMP
],
[4, <<<'EODUMP'
XMLReader {
+localName: "bar"
+nodeType: END_ELEMENT
+depth: 1
+baseURI: "%sxml_reader.xml"
…10
}
EODUMP
],
[6, <<<'EODUMP'
XMLReader {
+localName: "bar"
+nodeType: ELEMENT
+depth: 1
+isEmptyElement: true
+baseURI: "%sxml_reader.xml"
…9
}
EODUMP
],
[9, <<<'EODUMP'
XMLReader {
+localName: "#text"
+nodeType: TEXT
+depth: 2
+value: "With text"
+baseURI: "%sxml_reader.xml"
…9
}
EODUMP
],
[12, <<<'EODUMP'
XMLReader {
+localName: "bar"
+nodeType: ELEMENT
+depth: 1
+attributeCount: 2
+baseURI: "%sxml_reader.xml"
…9
}
EODUMP
],
[13, <<<'EODUMP'
XMLReader {
+localName: "bar"
+nodeType: END_ELEMENT
+depth: 1
+baseURI: "%sxml_reader.xml"
…10
}
EODUMP
],
[15, <<<'EODUMP'
XMLReader {
+localName: "bar"
+nodeType: ELEMENT
+depth: 1
+attributeCount: 1
+baseURI: "%sxml_reader.xml"
…9
}
EODUMP
],
[16, <<<'EODUMP'
XMLReader {
+localName: "#text"
+nodeType: SIGNIFICANT_WHITESPACE
+depth: 2
+value: """
\n
"""
+baseURI: "%sxml_reader.xml"
…9
}
EODUMP
],
[17, <<<'EODUMP'
XMLReader {
+localName: "baz"
+prefix: "baz"
+nodeType: ELEMENT
+depth: 2
+namespaceURI: "http://symfony.com"
+baseURI: "%sxml_reader.xml"
…8
}
EODUMP
],
[18, <<<'EODUMP'
XMLReader {
+localName: "baz"
+prefix: "baz"
+nodeType: END_ELEMENT
+depth: 2
+namespaceURI: "http://symfony.com"
+baseURI: "%sxml_reader.xml"
…8
}
EODUMP
],
[19, <<<'EODUMP'
XMLReader {
+localName: "#text"
+nodeType: SIGNIFICANT_WHITESPACE
+depth: 2
+value: """
\n
"""
+baseURI: "%sxml_reader.xml"
…9
}
EODUMP
],
[21, <<<'EODUMP'
XMLReader {
+localName: "#text"
+nodeType: SIGNIFICANT_WHITESPACE
+depth: 1
+value: "\n"
+baseURI: "%sxml_reader.xml"
…9
}
EODUMP
],
[22, <<<'EODUMP'
XMLReader {
+localName: "foo"
+nodeType: END_ELEMENT
+baseURI: "%sxml_reader.xml"
…11
}
EODUMP
],
];
}
}