Laravel version update
Laravel version update
This commit is contained in:
@@ -11,13 +11,14 @@
|
||||
|
||||
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 \PHPUnit_Framework_TestCase
|
||||
class CasterTest extends TestCase
|
||||
{
|
||||
use VarDumperTestTrait;
|
||||
|
||||
|
426
vendor/symfony/var-dumper/Tests/Caster/DateCasterTest.php
vendored
Normal file
426
vendor/symfony/var-dumper/Tests/Caster/DateCasterTest.php
vendored
Normal file
@@ -0,0 +1,426 @@
|
||||
<?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)
|
||||
{
|
||||
if ((\defined('HHVM_VERSION_ID') || \PHP_VERSION_ID <= 50509) && preg_match('/[-+]\d{2}:\d{2}/', $timezone)) {
|
||||
$this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.');
|
||||
}
|
||||
|
||||
$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)
|
||||
{
|
||||
if ((\defined('HHVM_VERSION_ID') || \PHP_VERSION_ID <= 50509) && preg_match('/[-+]\d{2}:\d{2}/', $timezone)) {
|
||||
$this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.');
|
||||
}
|
||||
|
||||
$stub = new Stub();
|
||||
$date = new \DateTime($time, new \DateTimeZone($timezone));
|
||||
$cast = DateCaster::castDateTime($date, array('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 array(
|
||||
array('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'),
|
||||
array('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'),
|
||||
array('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'),
|
||||
|
||||
array('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'),
|
||||
array('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'),
|
||||
array('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'),
|
||||
array('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'),
|
||||
array('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'),
|
||||
array('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, array('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()
|
||||
{
|
||||
$i = new \DateInterval('PT0S');
|
||||
$ms = ($withMs = \PHP_VERSION_ID >= 70100 && isset($i->f)) ? '.0' : '';
|
||||
|
||||
return array(
|
||||
array('PT0S', 0, 0, '0s', '0s'),
|
||||
array('PT0S', 0.1, 0, $withMs ? '+ 00:00:00.100' : '0s', '%is'),
|
||||
array('PT1S', 0, 0, '+ 00:00:01'.$ms, '%is'),
|
||||
array('PT2M', 0, 0, '+ 00:02:00'.$ms, '%is'),
|
||||
array('PT3H', 0, 0, '+ 03:00:00'.$ms, '%ss'),
|
||||
array('P4D', 0, 0, '+ 4d', '%ss'),
|
||||
array('P5M', 0, 0, '+ 5m', null),
|
||||
array('P6Y', 0, 0, '+ 6y', null),
|
||||
array('P1Y2M3DT4H5M6S', 0, 0, '+ 1y 2m 3d 04:05:06'.$ms, null),
|
||||
array('PT1M60S', 0, 0, '+ 00:02:00'.$ms, null),
|
||||
array('PT1H60M', 0, 0, '+ 02:00:00'.$ms, null),
|
||||
array('P1DT24H', 0, 0, '+ 2d', null),
|
||||
array('P1M32D', 0, 0, '+ 1m 32d', null),
|
||||
|
||||
array('PT0S', 0, 1, '0s', '0s'),
|
||||
array('PT0S', 0.1, 1, $withMs ? '- 00:00:00.100' : '0s', '%is'),
|
||||
array('PT1S', 0, 1, '- 00:00:01'.$ms, '%is'),
|
||||
array('PT2M', 0, 1, '- 00:02:00'.$ms, '%is'),
|
||||
array('PT3H', 0, 1, '- 03:00:00'.$ms, '%ss'),
|
||||
array('P4D', 0, 1, '- 4d', '%ss'),
|
||||
array('P5M', 0, 1, '- 5m', null),
|
||||
array('P6Y', 0, 1, '- 6y', null),
|
||||
array('P1Y2M3DT4H5M6S', 0, 1, '- 1y 2m 3d 04:05:06'.$ms, null),
|
||||
array('PT1M60S', 0, 1, '- 00:02:00'.$ms, null),
|
||||
array('PT1H60M', 0, 1, '- 02:00:00'.$ms, null),
|
||||
array('P1DT24H', 0, 1, '- 2d', null),
|
||||
array('P1M32D', 0, 1, '- 1m 32d', null),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTimeZones
|
||||
*/
|
||||
public function testDumpTimeZone($timezone, $expected)
|
||||
{
|
||||
if ((\defined('HHVM_VERSION_ID') || \PHP_VERSION_ID <= 50509) && !preg_match('/\w+\/\w+/', $timezone)) {
|
||||
$this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.');
|
||||
}
|
||||
|
||||
$timezone = new \DateTimeZone($timezone);
|
||||
|
||||
$xDump = <<<EODUMP
|
||||
DateTimeZone {
|
||||
timezone: $expected
|
||||
%A}
|
||||
EODUMP;
|
||||
|
||||
$this->assertDumpMatchesFormat($xDump, $timezone);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTimeZones
|
||||
*/
|
||||
public function testDumpTimeZoneExcludingVerbosity($timezone, $expected)
|
||||
{
|
||||
if ((\defined('HHVM_VERSION_ID') || \PHP_VERSION_ID <= 50509) && !preg_match('/\w+\/\w+/', $timezone)) {
|
||||
$this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.');
|
||||
}
|
||||
|
||||
$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)
|
||||
{
|
||||
if ((\defined('HHVM_VERSION_ID') || \PHP_VERSION_ID <= 50509) && !preg_match('/\w+\/\w+/', $timezone)) {
|
||||
$this->markTestSkipped('DateTimeZone GMT offsets are supported since 5.5.10. See https://github.com/facebook/hhvm/issues/5875 for HHVM.');
|
||||
}
|
||||
|
||||
$timezone = new \DateTimeZone($timezone);
|
||||
$stub = new Stub();
|
||||
|
||||
$cast = DateCaster::castTimeZone($timezone, array('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 array(
|
||||
// type 1 (UTC offset)
|
||||
array('-12:00', '-12:00', ''),
|
||||
array('+00:00', '+00:00', ''),
|
||||
array('+14:00', '+14:00', ''),
|
||||
|
||||
// type 2 (timezone abbreviation)
|
||||
array('GMT', '+00:00', ''),
|
||||
array('a', '+01:00', ''),
|
||||
array('b', '+02:00', ''),
|
||||
array('z', '+00:00', ''),
|
||||
|
||||
// type 3 (timezone identifier)
|
||||
array('Africa/Tunis', 'Africa/Tunis (%s:00)', $xRegion),
|
||||
array('America/Panama', 'America/Panama (%s:00)', $xRegion),
|
||||
array('Asia/Jerusalem', 'Asia/Jerusalem (%s:00)', $xRegion),
|
||||
array('Atlantic/Canary', 'Atlantic/Canary (%s:00)', $xRegion),
|
||||
array('Australia/Perth', 'Australia/Perth (%s:00)', $xRegion),
|
||||
array('Europe/Zurich', 'Europe/Zurich (%s:00)', $xRegion),
|
||||
array('Pacific/Tahiti', 'Pacific/Tahiti (%s:00)', $xRegion),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providePeriods
|
||||
*/
|
||||
public function testDumpPeriod($start, $interval, $end, $options, $expected)
|
||||
{
|
||||
if (\defined('HHVM_VERSION_ID') || \PHP_VERSION_ID < 50620 || (\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70005)) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
$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)
|
||||
{
|
||||
if (\defined('HHVM_VERSION_ID') || \PHP_VERSION_ID < 50620 || (\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70005)) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
$p = new \DatePeriod(new \DateTime($start), new \DateInterval($interval), \is_int($end) ? $end : new \DateTime($end), $options);
|
||||
$stub = new Stub();
|
||||
|
||||
$cast = DateCaster::castPeriod($p, array(), $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()
|
||||
{
|
||||
$i = new \DateInterval('PT0S');
|
||||
$ms = \PHP_VERSION_ID >= 70100 && isset($i->f) ? '.0' : '';
|
||||
|
||||
$periods = array(
|
||||
array('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'),
|
||||
array('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'),
|
||||
|
||||
array('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'),
|
||||
array('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'),
|
||||
|
||||
array('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'),
|
||||
array('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'),
|
||||
|
||||
array('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'),
|
||||
array('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'),
|
||||
|
||||
array('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'),
|
||||
array('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'),
|
||||
|
||||
array('2017-01-01', 'P1DT1H', '2017-01-03', 0, "every + 1d 01:00:00$ms, 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'),
|
||||
array('2017-01-01', 'P1DT1H', 1, 0, "every + 1d 01:00:00$ms, 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'),
|
||||
|
||||
array('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'),
|
||||
array('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);
|
||||
if (\PHP_VERSION_ID >= 70100 && isset($interval->f)) {
|
||||
$interval->f = $ms;
|
||||
}
|
||||
$interval->invert = $invert;
|
||||
|
||||
return $interval;
|
||||
}
|
||||
}
|
230
vendor/symfony/var-dumper/Tests/Caster/ExceptionCasterTest.php
vendored
Normal file
230
vendor/symfony/var-dumper/Tests/Caster/ExceptionCasterTest.php
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
<?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()
|
||||
{
|
||||
ExceptionCaster::$srcContext = 1;
|
||||
ExceptionCaster::$traceArgs = true;
|
||||
}
|
||||
|
||||
public function testDefaultSettings()
|
||||
{
|
||||
$ref = array('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 { …}
|
||||
Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->testDefaultSettings() {}
|
||||
%A
|
||||
EODUMP;
|
||||
|
||||
$this->assertDumpMatchesFormat($expectedDump, $e);
|
||||
$this->assertSame(array('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:65 { …}
|
||||
Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->testSeek() {}
|
||||
%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:84 { …}
|
||||
Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->testNoArgs() {}
|
||||
%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>
|
||||
…%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 = array(
|
||||
new FrameStub(array(
|
||||
'file' => \dirname(__DIR__).'/Fixtures/Twig.php',
|
||||
'line' => 20,
|
||||
'class' => '__TwigTemplate_VarDumperFixture_u75a09',
|
||||
)),
|
||||
new FrameStub(array(
|
||||
'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);
|
||||
}
|
||||
}
|
@@ -11,14 +11,18 @@
|
||||
|
||||
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 \PHPUnit_Framework_TestCase
|
||||
class PdoCasterTest extends TestCase
|
||||
{
|
||||
use VarDumperTestTrait;
|
||||
|
||||
/**
|
||||
* @requires extension pdo_sqlite
|
||||
*/
|
||||
@@ -36,22 +40,25 @@ class PdoCasterTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame('NATURAL', $attr['CASE']->class);
|
||||
$this->assertSame('BOTH', $attr['DEFAULT_FETCH_MODE']->class);
|
||||
|
||||
$xCast = array(
|
||||
"\0~\0inTransaction" => $pdo->inTransaction(),
|
||||
"\0~\0attributes" => array(
|
||||
'CASE' => $attr['CASE'],
|
||||
'ERRMODE' => $attr['ERRMODE'],
|
||||
'PERSISTENT' => false,
|
||||
'DRIVER_NAME' => 'sqlite',
|
||||
'ORACLE_NULLS' => $attr['ORACLE_NULLS'],
|
||||
'CLIENT_VERSION' => $pdo->getAttribute(\PDO::ATTR_CLIENT_VERSION),
|
||||
'SERVER_VERSION' => $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION),
|
||||
'STATEMENT_CLASS' => array('PDOStatement'),
|
||||
'DEFAULT_FETCH_MODE' => $attr['DEFAULT_FETCH_MODE'],
|
||||
),
|
||||
);
|
||||
unset($cast["\0~\0attributes"]['STATEMENT_CLASS'][1]);
|
||||
$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->assertSame($xCast, $cast);
|
||||
$this->assertDumpMatchesFormat($xDump, $cast);
|
||||
}
|
||||
}
|
||||
|
84
vendor/symfony/var-dumper/Tests/Caster/RedisCasterTest.php
vendored
Normal file
84
vendor/symfony/var-dumper/Tests/Caster/RedisCasterTest.php
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
<?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();
|
||||
|
||||
if (\defined('HHVM_VERSION_ID')) {
|
||||
$xCast = <<<'EODUMP'
|
||||
Redis {
|
||||
#host: ""
|
||||
%A
|
||||
}
|
||||
EODUMP;
|
||||
} else {
|
||||
$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']);
|
||||
}
|
||||
|
||||
if (\defined('HHVM_VERSION_ID')) {
|
||||
$xCast = <<<'EODUMP'
|
||||
Redis {
|
||||
#host: "127.0.0.1"
|
||||
%A
|
||||
}
|
||||
EODUMP;
|
||||
} else {
|
||||
$xCast = <<<'EODUMP'
|
||||
Redis {%A
|
||||
isConnected: true
|
||||
host: "127.0.0.1"
|
||||
port: 6379
|
||||
auth: null
|
||||
dbNum: 0
|
||||
timeout: 0.0
|
||||
persistentId: null
|
||||
options: {
|
||||
READ_TIMEOUT: 0.0
|
||||
SERIALIZER: NONE
|
||||
PREFIX: null
|
||||
SCAN: NORETRY
|
||||
}
|
||||
}
|
||||
EODUMP;
|
||||
}
|
||||
|
||||
$this->assertDumpMatchesFormat($xCast, $redis);
|
||||
}
|
||||
}
|
@@ -11,6 +11,8 @@
|
||||
|
||||
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;
|
||||
@@ -18,7 +20,7 @@ use Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass;
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class ReflectionCasterTest extends \PHPUnit_Framework_TestCase
|
||||
class ReflectionCasterTest extends TestCase
|
||||
{
|
||||
use VarDumperTestTrait;
|
||||
|
||||
@@ -76,13 +78,27 @@ Closure {
|
||||
\$b: & 123
|
||||
}
|
||||
file: "%sReflectionCasterTest.php"
|
||||
line: "66 to 66"
|
||||
line: "68 to 68"
|
||||
}
|
||||
EOTXT
|
||||
, $var
|
||||
);
|
||||
}
|
||||
|
||||
public function testClosureCasterExcludingVerbosity()
|
||||
{
|
||||
$var = function () {};
|
||||
|
||||
$expectedDump = <<<EOTXT
|
||||
Closure {
|
||||
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
|
||||
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
|
||||
}
|
||||
EOTXT;
|
||||
|
||||
$this->assertDumpEquals($expectedDump, $var, Caster::EXCLUDE_VERBOSE);
|
||||
}
|
||||
|
||||
public function testReflectionParameter()
|
||||
{
|
||||
$var = new \ReflectionParameter(__NAMESPACE__.'\reflectionParameterFixture', 0);
|
||||
@@ -147,80 +163,77 @@ EOTXT
|
||||
*/
|
||||
public function testGenerator()
|
||||
{
|
||||
$g = new GeneratorDemo();
|
||||
$g = $g->baz();
|
||||
$r = new \ReflectionGenerator($g);
|
||||
if (\extension_loaded('xdebug')) {
|
||||
$this->markTestSkipped('xdebug is active');
|
||||
}
|
||||
|
||||
$xDump = <<<'EODUMP'
|
||||
$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: """
|
||||
{\n
|
||||
yield from bar();\n
|
||||
}\n
|
||||
"""
|
||||
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() {
|
||||
%sGeneratorDemo.php:14 {
|
||||
› {
|
||||
› yield from bar();
|
||||
› }
|
||||
}
|
||||
}
|
||||
}
|
||||
closed: false
|
||||
}
|
||||
EODUMP;
|
||||
|
||||
$this->assertDumpMatchesFormat($xDump, $g);
|
||||
$this->assertDumpMatchesFormat($expectedDump, $generator);
|
||||
|
||||
foreach ($g as $v) {
|
||||
foreach ($generator as $v) {
|
||||
break;
|
||||
}
|
||||
|
||||
$xDump = <<<'EODUMP'
|
||||
$expectedDump = <<<'EODUMP'
|
||||
array:2 [
|
||||
0 => ReflectionGenerator {
|
||||
this: Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo { …}
|
||||
trace: {
|
||||
3. Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo() ==> yield(): {
|
||||
src: {
|
||||
%sGeneratorDemo.php:9: """
|
||||
{\n
|
||||
yield 1;\n
|
||||
}\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
2. Symfony\Component\VarDumper\Tests\Fixtures\bar() ==> Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo(): {
|
||||
src: {
|
||||
%sGeneratorDemo.php:20: """
|
||||
{\n
|
||||
yield from GeneratorDemo::foo();\n
|
||||
}\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
1. Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo->baz() ==> Symfony\Component\VarDumper\Tests\Fixtures\bar(): {
|
||||
src: {
|
||||
%sGeneratorDemo.php:14: """
|
||||
{\n
|
||||
yield from bar();\n
|
||||
}\n
|
||||
"""
|
||||
}
|
||||
%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;\n
|
||||
}\n
|
||||
\n
|
||||
"""
|
||||
Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo::foo() {
|
||||
%sGeneratorDemo.php:10 {
|
||||
› yield 1;
|
||||
› }
|
||||
›
|
||||
}
|
||||
}
|
||||
}
|
||||
closed: false
|
||||
}
|
||||
]
|
||||
EODUMP;
|
||||
|
||||
$this->assertDumpMatchesFormat($xDump, array($r, $r->getExecutingGenerator()));
|
||||
$r = new \ReflectionGenerator($generator);
|
||||
$this->assertDumpMatchesFormat($expectedDump, array($r, $r->getExecutingGenerator()));
|
||||
|
||||
foreach ($generator as $v) {
|
||||
}
|
||||
|
||||
$expectedDump = <<<'EODUMP'
|
||||
Generator {
|
||||
closed: true
|
||||
}
|
||||
EODUMP;
|
||||
$this->assertDumpMatchesFormat($expectedDump, $generator);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -11,12 +11,13 @@
|
||||
|
||||
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 \PHPUnit_Framework_TestCase
|
||||
class SplCasterTest extends TestCase
|
||||
{
|
||||
use VarDumperTestTrait;
|
||||
|
||||
@@ -96,10 +97,10 @@ SplFileObject {
|
||||
file: true
|
||||
dir: false
|
||||
link: false
|
||||
%AcsvControl: array:2 [
|
||||
%AcsvControl: array:%d [
|
||||
0 => ","
|
||||
1 => """
|
||||
]
|
||||
%A]
|
||||
flags: DROP_NEW_LINE|SKIP_EMPTY
|
||||
maxLineLen: 0
|
||||
fstat: array:26 [
|
||||
@@ -117,4 +118,96 @@ SplFileObject {
|
||||
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 array(
|
||||
array(\SplDoublyLinkedList::IT_MODE_FIFO, 'IT_MODE_FIFO | IT_MODE_KEEP'),
|
||||
array(\SplDoublyLinkedList::IT_MODE_LIFO, 'IT_MODE_LIFO | IT_MODE_KEEP'),
|
||||
array(\SplDoublyLinkedList::IT_MODE_FIFO | \SplDoublyLinkedList::IT_MODE_DELETE, 'IT_MODE_FIFO | IT_MODE_DELETE'),
|
||||
array(\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()
|
||||
{
|
||||
if (\defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped('HHVM as different internal details.');
|
||||
}
|
||||
$var = new \ArrayObject(array(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()
|
||||
{
|
||||
if (\defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped('HHVM as different internal details.');
|
||||
}
|
||||
$var = new MyArrayIterator(array(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);
|
||||
}
|
||||
}
|
||||
|
||||
class MyArrayIterator extends \ArrayIterator
|
||||
{
|
||||
private $foo = 123;
|
||||
}
|
||||
|
192
vendor/symfony/var-dumper/Tests/Caster/StubCasterTest.php
vendored
Normal file
192
vendor/symfony/var-dumper/Tests/Caster/StubCasterTest.php
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
<?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 = 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('<foo></foo>');
|
||||
$dumper->setDumpBoundaries('<bar>', '</bar>');
|
||||
$dumper->setDisplayOptions(array('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 = array(new LinkStub('example.com', 0, 'http://example.com'));
|
||||
|
||||
$cloner = new VarCloner();
|
||||
$dumper = new HtmlDumper();
|
||||
$dumper->setDumpHeader('<foo></foo>');
|
||||
$dumper->setDumpBoundaries('<bar>', '</bar>');
|
||||
$dumper->setDisplayOptions(array('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 = array(new ClassStub('hello', array(FooInterface::class, 'foo')));
|
||||
|
||||
$cloner = new VarCloner();
|
||||
$dumper = new HtmlDumper();
|
||||
$dumper->setDumpHeader('<foo></foo>');
|
||||
$dumper->setDumpBoundaries('<bar>', '</bar>');
|
||||
$dump = $dumper->dump($cloner->cloneVar($var), true, array('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="5 characters">hello</span></a>"
|
||||
</samp>]
|
||||
</bar>
|
||||
EODUMP;
|
||||
|
||||
$this->assertStringMatchesFormat($expectedDump, $dump);
|
||||
}
|
||||
|
||||
public function testClassStubWithNotExistingClass()
|
||||
{
|
||||
$var = array(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 = array(new ClassStub('hello', array(FooInterface::class, 'missing')));
|
||||
|
||||
$cloner = new VarCloner();
|
||||
$dumper = new HtmlDumper();
|
||||
$dumper->setDumpHeader('<foo></foo>');
|
||||
$dumper->setDumpBoundaries('<bar>', '</bar>');
|
||||
$dump = $dumper->dump($cloner->cloneVar($var), true, array('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);
|
||||
}
|
||||
}
|
248
vendor/symfony/var-dumper/Tests/Caster/XmlReaderCasterTest.php
vendored
Normal file
248
vendor/symfony/var-dumper/Tests/Caster/XmlReaderCasterTest.php
vendored
Normal 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()
|
||||
{
|
||||
$this->reader = new \XmlReader();
|
||||
$this->reader->open(__DIR__.'/../Fixtures/xml_reader.xml');
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$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 array(
|
||||
array(0, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+nodeType: NONE
|
||||
…13
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(1, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "foo"
|
||||
+nodeType: ELEMENT
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…11
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(2, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "#text"
|
||||
+nodeType: SIGNIFICANT_WHITESPACE
|
||||
+depth: 1
|
||||
+value: """
|
||||
\n
|
||||
|
||||
"""
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…9
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(3, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "bar"
|
||||
+nodeType: ELEMENT
|
||||
+depth: 1
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…10
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(4, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "bar"
|
||||
+nodeType: END_ELEMENT
|
||||
+depth: 1
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…10
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(6, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "bar"
|
||||
+nodeType: ELEMENT
|
||||
+depth: 1
|
||||
+isEmptyElement: true
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…9
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(9, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "#text"
|
||||
+nodeType: TEXT
|
||||
+depth: 2
|
||||
+value: "With text"
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…9
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(12, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "bar"
|
||||
+nodeType: ELEMENT
|
||||
+depth: 1
|
||||
+attributeCount: 2
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…9
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(13, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "bar"
|
||||
+nodeType: END_ELEMENT
|
||||
+depth: 1
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…10
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(15, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "bar"
|
||||
+nodeType: ELEMENT
|
||||
+depth: 1
|
||||
+attributeCount: 1
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…9
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(16, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "#text"
|
||||
+nodeType: SIGNIFICANT_WHITESPACE
|
||||
+depth: 2
|
||||
+value: """
|
||||
\n
|
||||
|
||||
"""
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…9
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(17, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "baz"
|
||||
+prefix: "baz"
|
||||
+nodeType: ELEMENT
|
||||
+depth: 2
|
||||
+namespaceURI: "http://symfony.com"
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…8
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(18, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "baz"
|
||||
+prefix: "baz"
|
||||
+nodeType: END_ELEMENT
|
||||
+depth: 2
|
||||
+namespaceURI: "http://symfony.com"
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…8
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(19, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "#text"
|
||||
+nodeType: SIGNIFICANT_WHITESPACE
|
||||
+depth: 2
|
||||
+value: """
|
||||
\n
|
||||
|
||||
"""
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…9
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(21, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "#text"
|
||||
+nodeType: SIGNIFICANT_WHITESPACE
|
||||
+depth: 1
|
||||
+value: "\n"
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…9
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
array(22, <<<'EODUMP'
|
||||
XMLReader {
|
||||
+localName: "foo"
|
||||
+nodeType: END_ELEMENT
|
||||
+baseURI: "%sxml_reader.xml"
|
||||
…11
|
||||
}
|
||||
EODUMP
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
115
vendor/symfony/var-dumper/Tests/Cloner/DataTest.php
vendored
Normal file
115
vendor/symfony/var-dumper/Tests/Cloner/DataTest.php
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
<?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\Cloner;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\VarDumper\Caster\Caster;
|
||||
use Symfony\Component\VarDumper\Caster\ClassStub;
|
||||
use Symfony\Component\VarDumper\Cloner\Data;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
|
||||
class DataTest extends TestCase
|
||||
{
|
||||
public function testBasicData()
|
||||
{
|
||||
$values = array(1 => 123, 4.5, 'abc', null, false);
|
||||
$data = $this->cloneVar($values);
|
||||
$clonedValues = array();
|
||||
|
||||
$this->assertInstanceOf(Data::class, $data);
|
||||
$this->assertCount(\count($values), $data);
|
||||
$this->assertFalse(isset($data->{0}));
|
||||
$this->assertFalse(isset($data[0]));
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
$this->assertTrue(isset($data->{$k}));
|
||||
$this->assertTrue(isset($data[$k]));
|
||||
$this->assertSame(\gettype($values[$k]), $data->seek($k)->getType());
|
||||
$this->assertSame($values[$k], $data->seek($k)->getValue());
|
||||
$this->assertSame($values[$k], $data->{$k});
|
||||
$this->assertSame($values[$k], $data[$k]);
|
||||
$this->assertSame((string) $values[$k], (string) $data->seek($k));
|
||||
|
||||
$clonedValues[$k] = $v->getValue();
|
||||
}
|
||||
|
||||
$this->assertSame($values, $clonedValues);
|
||||
}
|
||||
|
||||
public function testObject()
|
||||
{
|
||||
$data = $this->cloneVar(new \Exception('foo'));
|
||||
|
||||
$this->assertSame('Exception', $data->getType());
|
||||
|
||||
$this->assertSame('foo', $data->message);
|
||||
$this->assertSame('foo', $data->{Caster::PREFIX_PROTECTED.'message'});
|
||||
|
||||
$this->assertSame('foo', $data['message']);
|
||||
$this->assertSame('foo', $data[Caster::PREFIX_PROTECTED.'message']);
|
||||
|
||||
$this->assertStringMatchesFormat('Exception (count=%d)', (string) $data);
|
||||
}
|
||||
|
||||
public function testArray()
|
||||
{
|
||||
$values = array(array(), array(123));
|
||||
$data = $this->cloneVar($values);
|
||||
|
||||
$this->assertSame($values, $data->getValue(true));
|
||||
|
||||
$children = $data->getValue();
|
||||
|
||||
$this->assertInternalType('array', $children);
|
||||
|
||||
$this->assertInstanceOf(Data::class, $children[0]);
|
||||
$this->assertInstanceOf(Data::class, $children[1]);
|
||||
|
||||
$this->assertEquals($children[0], $data[0]);
|
||||
$this->assertEquals($children[1], $data[1]);
|
||||
|
||||
$this->assertSame($values[0], $children[0]->getValue(true));
|
||||
$this->assertSame($values[1], $children[1]->getValue(true));
|
||||
}
|
||||
|
||||
public function testStub()
|
||||
{
|
||||
$data = $this->cloneVar(array(new ClassStub('stdClass')));
|
||||
$data = $data[0];
|
||||
|
||||
$this->assertSame('string', $data->getType());
|
||||
$this->assertSame('stdClass', $data->getValue());
|
||||
$this->assertSame('stdClass', (string) $data);
|
||||
}
|
||||
|
||||
public function testHardRefs()
|
||||
{
|
||||
$values = array(array());
|
||||
$values[1] = &$values[0];
|
||||
$values[2][0] = &$values[2];
|
||||
|
||||
$data = $this->cloneVar($values);
|
||||
|
||||
$this->assertSame(array(), $data[0]->getValue());
|
||||
$this->assertSame(array(), $data[1]->getValue());
|
||||
$this->assertEquals(array($data[2]->getValue()), $data[2]->getValue(true));
|
||||
|
||||
$this->assertSame('array (count=3)', (string) $data);
|
||||
}
|
||||
|
||||
private function cloneVar($value)
|
||||
{
|
||||
$cloner = new VarCloner();
|
||||
|
||||
return $cloner->cloneVar($value);
|
||||
}
|
||||
}
|
437
vendor/symfony/var-dumper/Tests/Cloner/VarClonerTest.php
vendored
Normal file
437
vendor/symfony/var-dumper/Tests/Cloner/VarClonerTest.php
vendored
Normal file
@@ -0,0 +1,437 @@
|
||||
<?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\Cloner;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class VarClonerTest extends TestCase
|
||||
{
|
||||
public function testMaxIntBoundary()
|
||||
{
|
||||
$data = array(PHP_INT_MAX => 123);
|
||||
|
||||
$cloner = new VarCloner();
|
||||
$clone = $cloner->cloneVar($data);
|
||||
|
||||
$expected = <<<EOTXT
|
||||
Symfony\Component\VarDumper\Cloner\Data Object
|
||||
(
|
||||
[data:Symfony\Component\VarDumper\Cloner\Data:private] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[1] => 1
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[%s] => 123
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[position:Symfony\Component\VarDumper\Cloner\Data:private] => 0
|
||||
[key:Symfony\Component\VarDumper\Cloner\Data:private] => 0
|
||||
[maxDepth:Symfony\Component\VarDumper\Cloner\Data:private] => 20
|
||||
[maxItemsPerDepth:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
[useRefHandles:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
)
|
||||
|
||||
EOTXT;
|
||||
$this->assertSame(sprintf($expected, PHP_INT_MAX), print_r($clone, true));
|
||||
}
|
||||
|
||||
public function testClone()
|
||||
{
|
||||
$json = json_decode('{"1":{"var":"val"},"2":{"var":"val"}}');
|
||||
|
||||
$cloner = new VarCloner();
|
||||
$clone = $cloner->cloneVar($json);
|
||||
|
||||
$expected = <<<EOTXT
|
||||
Symfony\Component\VarDumper\Cloner\Data Object
|
||||
(
|
||||
[data:Symfony\Component\VarDumper\Cloner\Data:private] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => Symfony\Component\VarDumper\Cloner\Stub Object
|
||||
(
|
||||
[type] => 4
|
||||
[class] => stdClass
|
||||
[value] =>
|
||||
[cut] => 0
|
||||
[handle] => %i
|
||||
[refCount] => 0
|
||||
[position] => 1
|
||||
[attr] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[\000+\0001] => Symfony\Component\VarDumper\Cloner\Stub Object
|
||||
(
|
||||
[type] => 4
|
||||
[class] => stdClass
|
||||
[value] =>
|
||||
[cut] => 0
|
||||
[handle] => %i
|
||||
[refCount] => 0
|
||||
[position] => 2
|
||||
[attr] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[\000+\0002] => Symfony\Component\VarDumper\Cloner\Stub Object
|
||||
(
|
||||
[type] => 4
|
||||
[class] => stdClass
|
||||
[value] =>
|
||||
[cut] => 0
|
||||
[handle] => %i
|
||||
[refCount] => 0
|
||||
[position] => 3
|
||||
[attr] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[2] => Array
|
||||
(
|
||||
[\000+\000var] => val
|
||||
)
|
||||
|
||||
[3] => Array
|
||||
(
|
||||
[\000+\000var] => val
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[position:Symfony\Component\VarDumper\Cloner\Data:private] => 0
|
||||
[key:Symfony\Component\VarDumper\Cloner\Data:private] => 0
|
||||
[maxDepth:Symfony\Component\VarDumper\Cloner\Data:private] => 20
|
||||
[maxItemsPerDepth:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
[useRefHandles:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
)
|
||||
|
||||
EOTXT;
|
||||
$this->assertStringMatchesFormat($expected, print_r($clone, true));
|
||||
}
|
||||
|
||||
public function testLimits()
|
||||
{
|
||||
// Level 0:
|
||||
$data = array(
|
||||
// Level 1:
|
||||
array(
|
||||
// Level 2:
|
||||
array(
|
||||
// Level 3:
|
||||
'Level 3 Item 0',
|
||||
'Level 3 Item 1',
|
||||
'Level 3 Item 2',
|
||||
'Level 3 Item 3',
|
||||
),
|
||||
array(
|
||||
'Level 3 Item 4',
|
||||
'Level 3 Item 5',
|
||||
'Level 3 Item 6',
|
||||
),
|
||||
array(
|
||||
'Level 3 Item 7',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'Level 3 Item 8',
|
||||
),
|
||||
'Level 2 Item 0',
|
||||
),
|
||||
array(
|
||||
'Level 2 Item 1',
|
||||
),
|
||||
'Level 1 Item 0',
|
||||
array(
|
||||
// Test setMaxString:
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||
'SHORT',
|
||||
),
|
||||
);
|
||||
|
||||
$cloner = new VarCloner();
|
||||
$cloner->setMinDepth(2);
|
||||
$cloner->setMaxItems(5);
|
||||
$cloner->setMaxString(20);
|
||||
$clone = $cloner->cloneVar($data);
|
||||
|
||||
$expected = <<<EOTXT
|
||||
Symfony\Component\VarDumper\Cloner\Data Object
|
||||
(
|
||||
[data:Symfony\Component\VarDumper\Cloner\Data:private] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[2] => 1
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[2] => 2
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[2] => 3
|
||||
)
|
||||
|
||||
[2] => Array
|
||||
(
|
||||
[2] => 4
|
||||
)
|
||||
|
||||
[3] => Level 1 Item 0
|
||||
[4] => Array
|
||||
(
|
||||
[2] => 5
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[2] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[2] => 6
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[0] => 2
|
||||
[2] => 7
|
||||
)
|
||||
|
||||
[2] => Array
|
||||
(
|
||||
[0] => 1
|
||||
[2] => 0
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[3] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => 1
|
||||
[2] => 0
|
||||
)
|
||||
|
||||
[1] => Level 2 Item 0
|
||||
)
|
||||
|
||||
[4] => Array
|
||||
(
|
||||
[0] => Level 2 Item 1
|
||||
)
|
||||
|
||||
[5] => Array
|
||||
(
|
||||
[0] => Symfony\Component\VarDumper\Cloner\Stub Object
|
||||
(
|
||||
[type] => 2
|
||||
[class] => 2
|
||||
[value] => ABCDEFGHIJKLMNOPQRST
|
||||
[cut] => 6
|
||||
[handle] => 0
|
||||
[refCount] => 0
|
||||
[position] => 0
|
||||
[attr] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => SHORT
|
||||
)
|
||||
|
||||
[6] => Array
|
||||
(
|
||||
[0] => Level 3 Item 0
|
||||
[1] => Level 3 Item 1
|
||||
[2] => Level 3 Item 2
|
||||
[3] => Level 3 Item 3
|
||||
)
|
||||
|
||||
[7] => Array
|
||||
(
|
||||
[0] => Level 3 Item 4
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[position:Symfony\Component\VarDumper\Cloner\Data:private] => 0
|
||||
[key:Symfony\Component\VarDumper\Cloner\Data:private] => 0
|
||||
[maxDepth:Symfony\Component\VarDumper\Cloner\Data:private] => 20
|
||||
[maxItemsPerDepth:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
[useRefHandles:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
)
|
||||
|
||||
EOTXT;
|
||||
$this->assertStringMatchesFormat($expected, print_r($clone, true));
|
||||
}
|
||||
|
||||
public function testJsonCast()
|
||||
{
|
||||
if (2 == ini_get('xdebug.overload_var_dump')) {
|
||||
$this->markTestSkipped('xdebug is active');
|
||||
}
|
||||
|
||||
$data = (array) json_decode('{"1":{}}');
|
||||
|
||||
$cloner = new VarCloner();
|
||||
$clone = $cloner->cloneVar($data);
|
||||
|
||||
$expected = <<<'EOTXT'
|
||||
object(Symfony\Component\VarDumper\Cloner\Data)#%i (6) {
|
||||
["data":"Symfony\Component\VarDumper\Cloner\Data":private]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(1) {
|
||||
[1]=>
|
||||
int(1)
|
||||
}
|
||||
}
|
||||
[1]=>
|
||||
array(1) {
|
||||
["1"]=>
|
||||
object(Symfony\Component\VarDumper\Cloner\Stub)#%i (8) {
|
||||
["type"]=>
|
||||
int(4)
|
||||
["class"]=>
|
||||
string(8) "stdClass"
|
||||
["value"]=>
|
||||
NULL
|
||||
["cut"]=>
|
||||
int(0)
|
||||
["handle"]=>
|
||||
int(%i)
|
||||
["refCount"]=>
|
||||
int(0)
|
||||
["position"]=>
|
||||
int(0)
|
||||
["attr"]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
["position":"Symfony\Component\VarDumper\Cloner\Data":private]=>
|
||||
int(0)
|
||||
["key":"Symfony\Component\VarDumper\Cloner\Data":private]=>
|
||||
int(0)
|
||||
["maxDepth":"Symfony\Component\VarDumper\Cloner\Data":private]=>
|
||||
int(20)
|
||||
["maxItemsPerDepth":"Symfony\Component\VarDumper\Cloner\Data":private]=>
|
||||
int(-1)
|
||||
["useRefHandles":"Symfony\Component\VarDumper\Cloner\Data":private]=>
|
||||
int(-1)
|
||||
}
|
||||
|
||||
EOTXT;
|
||||
ob_start();
|
||||
var_dump($clone);
|
||||
$this->assertStringMatchesFormat(\PHP_VERSION_ID >= 70200 ? str_replace('"1"', '1', $expected) : $expected, ob_get_clean());
|
||||
}
|
||||
|
||||
public function testCaster()
|
||||
{
|
||||
$cloner = new VarCloner(array(
|
||||
'*' => function ($obj, $array) {
|
||||
return array('foo' => 123);
|
||||
},
|
||||
__CLASS__ => function ($obj, $array) {
|
||||
++$array['foo'];
|
||||
|
||||
return $array;
|
||||
},
|
||||
));
|
||||
$clone = $cloner->cloneVar($this);
|
||||
|
||||
$expected = <<<EOTXT
|
||||
Symfony\Component\VarDumper\Cloner\Data Object
|
||||
(
|
||||
[data:Symfony\Component\VarDumper\Cloner\Data:private] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => Symfony\Component\VarDumper\Cloner\Stub Object
|
||||
(
|
||||
[type] => 4
|
||||
[class] => %s
|
||||
[value] =>
|
||||
[cut] => 0
|
||||
[handle] => %i
|
||||
[refCount] => 0
|
||||
[position] => 1
|
||||
[attr] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[foo] => 124
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[position:Symfony\Component\VarDumper\Cloner\Data:private] => 0
|
||||
[key:Symfony\Component\VarDumper\Cloner\Data:private] => 0
|
||||
[maxDepth:Symfony\Component\VarDumper\Cloner\Data:private] => 20
|
||||
[maxItemsPerDepth:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
[useRefHandles:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
)
|
||||
|
||||
EOTXT;
|
||||
$this->assertStringMatchesFormat($expected, print_r($clone, true));
|
||||
}
|
||||
}
|
@@ -9,22 +9,25 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Tests;
|
||||
namespace Symfony\Component\VarDumper\Tests\Dumper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
use Symfony\Component\VarDumper\Dumper\CliDumper;
|
||||
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class CliDumperTest extends \PHPUnit_Framework_TestCase
|
||||
class CliDumperTest extends TestCase
|
||||
{
|
||||
use VarDumperTestTrait;
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
require __DIR__.'/Fixtures/dumb-var.php';
|
||||
require __DIR__.'/../Fixtures/dumb-var.php';
|
||||
|
||||
$dumper = new CliDumper('php://output');
|
||||
$dumper->setColors(false);
|
||||
@@ -45,7 +48,7 @@ class CliDumperTest extends \PHPUnit_Framework_TestCase
|
||||
$intMax = PHP_INT_MAX;
|
||||
$res = (int) $var['res'];
|
||||
|
||||
$r = defined('HHVM_VERSION') ? '' : '#%d';
|
||||
$r = \defined('HHVM_VERSION') ? '' : '#%d';
|
||||
$this->assertStringMatchesFormat(
|
||||
<<<EOTXT
|
||||
array:24 [
|
||||
@@ -74,8 +77,8 @@ array:24 [
|
||||
+"bar": "bar"
|
||||
}
|
||||
"closure" => Closure {{$r}
|
||||
class: "Symfony\Component\VarDumper\Tests\CliDumperTest"
|
||||
this: Symfony\Component\VarDumper\Tests\CliDumperTest {{$r} …}
|
||||
class: "Symfony\Component\VarDumper\Tests\Dumper\CliDumperTest"
|
||||
this: Symfony\Component\VarDumper\Tests\Dumper\CliDumperTest {{$r} …}
|
||||
parameters: {
|
||||
\$a: {}
|
||||
&\$b: {
|
||||
@@ -83,7 +86,7 @@ array:24 [
|
||||
default: null
|
||||
}
|
||||
}
|
||||
file: "{$var['file']}"
|
||||
file: "%s%eTests%eFixtures%edumb-var.php"
|
||||
line: "{$var['line']} to {$var['line']}"
|
||||
}
|
||||
"line" => {$var['line']}
|
||||
@@ -107,6 +110,97 @@ EOTXT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideDumpWithCommaFlagTests
|
||||
*/
|
||||
public function testDumpWithCommaFlag($expected, $flags)
|
||||
{
|
||||
$dumper = new CliDumper(null, null, $flags);
|
||||
$dumper->setColors(false);
|
||||
$cloner = new VarCloner();
|
||||
|
||||
$var = array(
|
||||
'array' => array('a', 'b'),
|
||||
'string' => 'hello',
|
||||
'multiline string' => "this\nis\na\multiline\nstring",
|
||||
);
|
||||
|
||||
$dump = $dumper->dump($cloner->cloneVar($var), true);
|
||||
|
||||
$this->assertSame($expected, $dump);
|
||||
}
|
||||
|
||||
public function testDumpWithCommaFlagsAndExceptionCodeExcerpt()
|
||||
{
|
||||
$dumper = new CliDumper(null, null, CliDumper::DUMP_TRAILING_COMMA);
|
||||
$dumper->setColors(false);
|
||||
$cloner = new VarCloner();
|
||||
|
||||
$ex = new \RuntimeException('foo');
|
||||
|
||||
$dump = $dumper->dump($cloner->cloneVar($ex)->withRefHandles(false), true);
|
||||
|
||||
$this->assertStringMatchesFormat(<<<'EOTXT'
|
||||
RuntimeException {
|
||||
#message: "foo"
|
||||
#code: 0
|
||||
#file: "%ACliDumperTest.php"
|
||||
#line: %d
|
||||
trace: {
|
||||
%ACliDumperTest.php:%d {
|
||||
›
|
||||
› $ex = new \RuntimeException('foo');
|
||||
›
|
||||
}
|
||||
%A
|
||||
}
|
||||
}
|
||||
|
||||
EOTXT
|
||||
, $dump);
|
||||
}
|
||||
|
||||
public function provideDumpWithCommaFlagTests()
|
||||
{
|
||||
$expected = <<<'EOTXT'
|
||||
array:3 [
|
||||
"array" => array:2 [
|
||||
0 => "a",
|
||||
1 => "b"
|
||||
],
|
||||
"string" => "hello",
|
||||
"multiline string" => """
|
||||
this\n
|
||||
is\n
|
||||
a\multiline\n
|
||||
string
|
||||
"""
|
||||
]
|
||||
|
||||
EOTXT;
|
||||
|
||||
yield array($expected, CliDumper::DUMP_COMMA_SEPARATOR);
|
||||
|
||||
$expected = <<<'EOTXT'
|
||||
array:3 [
|
||||
"array" => array:2 [
|
||||
0 => "a",
|
||||
1 => "b",
|
||||
],
|
||||
"string" => "hello",
|
||||
"multiline string" => """
|
||||
this\n
|
||||
is\n
|
||||
a\multiline\n
|
||||
string
|
||||
""",
|
||||
]
|
||||
|
||||
EOTXT;
|
||||
|
||||
yield array($expected, CliDumper::DUMP_TRAILING_COMMA);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension xml
|
||||
*/
|
||||
@@ -115,7 +209,7 @@ EOTXT
|
||||
$var = xml_parser_create();
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<EOTXT
|
||||
<<<'EOTXT'
|
||||
xml resource {
|
||||
current_byte_index: %i
|
||||
current_column_number: %i
|
||||
@@ -136,8 +230,22 @@ EOTXT
|
||||
$var[] = &$v;
|
||||
$var[''] = 2;
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<EOTXT
|
||||
if (\PHP_VERSION_ID >= 70200) {
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<'EOTXT'
|
||||
array:4 [
|
||||
0 => {}
|
||||
1 => &1 null
|
||||
2 => &1 null
|
||||
"" => 2
|
||||
]
|
||||
EOTXT
|
||||
,
|
||||
$var
|
||||
);
|
||||
} else {
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<'EOTXT'
|
||||
array:4 [
|
||||
"0" => {}
|
||||
"1" => &1 null
|
||||
@@ -145,9 +253,10 @@ array:4 [
|
||||
"" => 2
|
||||
]
|
||||
EOTXT
|
||||
,
|
||||
$var
|
||||
);
|
||||
,
|
||||
$var
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function testObjectCast()
|
||||
@@ -155,21 +264,33 @@ EOTXT
|
||||
$var = (object) array(1 => 1);
|
||||
$var->{1} = 2;
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<EOTXT
|
||||
if (\PHP_VERSION_ID >= 70200) {
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<'EOTXT'
|
||||
{
|
||||
+"1": 2
|
||||
}
|
||||
EOTXT
|
||||
,
|
||||
$var
|
||||
);
|
||||
} else {
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<'EOTXT'
|
||||
{
|
||||
+1: 1
|
||||
+"1": 2
|
||||
}
|
||||
EOTXT
|
||||
,
|
||||
$var
|
||||
);
|
||||
,
|
||||
$var
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function testClosedResource()
|
||||
{
|
||||
if (defined('HHVM_VERSION') && HHVM_VERSION_ID < 30600) {
|
||||
if (\defined('HHVM_VERSION') && HHVM_VERSION_ID < 30600) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
@@ -188,7 +309,7 @@ EOTXT
|
||||
|
||||
$this->assertStringMatchesFormat(
|
||||
<<<EOTXT
|
||||
Unknown resource @{$res}
|
||||
Closed resource @{$res}
|
||||
|
||||
EOTXT
|
||||
,
|
||||
@@ -196,12 +317,47 @@ EOTXT
|
||||
);
|
||||
}
|
||||
|
||||
public function testFlags()
|
||||
{
|
||||
putenv('DUMP_LIGHT_ARRAY=1');
|
||||
putenv('DUMP_STRING_LENGTH=1');
|
||||
|
||||
$var = array(
|
||||
range(1, 3),
|
||||
array('foo', 2 => 'bar'),
|
||||
);
|
||||
|
||||
$this->assertDumpEquals(
|
||||
<<<EOTXT
|
||||
[
|
||||
[
|
||||
1
|
||||
2
|
||||
3
|
||||
]
|
||||
[
|
||||
0 => (3) "foo"
|
||||
2 => (3) "bar"
|
||||
]
|
||||
]
|
||||
EOTXT
|
||||
,
|
||||
$var
|
||||
);
|
||||
|
||||
putenv('DUMP_LIGHT_ARRAY=');
|
||||
putenv('DUMP_STRING_LENGTH=');
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires function Twig\Template::getSourceContext
|
||||
*/
|
||||
public function testThrowingCaster()
|
||||
{
|
||||
$out = fopen('php://memory', 'r+b');
|
||||
|
||||
require_once __DIR__.'/Fixtures/Twig.php';
|
||||
$twig = new \__TwigTemplate_VarDumperFixture_u75a09(new \Twig_Environment(new \Twig_Loader_Filesystem()));
|
||||
require_once __DIR__.'/../Fixtures/Twig.php';
|
||||
$twig = new \__TwigTemplate_VarDumperFixture_u75a09(new Environment(new FilesystemLoader()));
|
||||
|
||||
$dumper = new CliDumper();
|
||||
$dumper->setColors(false);
|
||||
@@ -217,36 +373,35 @@ EOTXT
|
||||
':stream' => eval('return function () use ($twig) {
|
||||
try {
|
||||
$twig->render(array());
|
||||
} catch (\Twig_Error_Runtime $e) {
|
||||
} catch (\Twig\Error\RuntimeError $e) {
|
||||
throw $e->getPrevious();
|
||||
}
|
||||
};'),
|
||||
));
|
||||
$line = __LINE__ - 2;
|
||||
$ref = (int) $out;
|
||||
|
||||
$data = $cloner->cloneVar($out);
|
||||
$dumper->dump($data, $out);
|
||||
rewind($out);
|
||||
$out = stream_get_contents($out);
|
||||
$out = stream_get_contents($out, -1, 0);
|
||||
|
||||
if (method_exists($twig, 'getSource')) {
|
||||
$twig = <<<EOTXT
|
||||
foo.twig:2: """
|
||||
foo bar\\n
|
||||
twig source\\n
|
||||
\\n
|
||||
"""
|
||||
|
||||
EOTXT;
|
||||
} else {
|
||||
$twig = '';
|
||||
}
|
||||
|
||||
$r = defined('HHVM_VERSION') ? '' : '#%d';
|
||||
$r = \defined('HHVM_VERSION') ? '' : '#%d';
|
||||
$this->assertStringMatchesFormat(
|
||||
<<<EOTXT
|
||||
stream resource {@{$ref}
|
||||
⚠: Symfony\Component\VarDumper\Exception\ThrowingCasterException {{$r}
|
||||
#message: "Unexpected Exception thrown from a caster: Foobar"
|
||||
trace: {
|
||||
%sTwig.php:2 {
|
||||
› foo bar
|
||||
› twig source
|
||||
›
|
||||
}
|
||||
%s%eTemplate.php:%d { …}
|
||||
%s%eTemplate.php:%d { …}
|
||||
%s%eTemplate.php:%d { …}
|
||||
%s%eTests%eDumper%eCliDumperTest.php:%d { …}
|
||||
%A }
|
||||
}
|
||||
%Awrapper_type: "PHP"
|
||||
stream_type: "MEMORY"
|
||||
mode: "%s+b"
|
||||
@@ -254,56 +409,6 @@ stream resource {@{$ref}
|
||||
seekable: true
|
||||
uri: "php://memory"
|
||||
%Aoptions: []
|
||||
⚠: Symfony\Component\VarDumper\Exception\ThrowingCasterException {{$r}
|
||||
#message: "Unexpected Exception thrown from a caster: Foobar"
|
||||
-trace: {
|
||||
%d. __TwigTemplate_VarDumperFixture_u75a09->doDisplay() ==> new Exception(): {
|
||||
src: {
|
||||
%sTwig.php:19: """
|
||||
// line 2\\n
|
||||
throw new \Exception('Foobar');\\n
|
||||
}\\n
|
||||
"""
|
||||
{$twig} }
|
||||
}
|
||||
%d. Twig_Template->displayWithErrorHandling() ==> __TwigTemplate_VarDumperFixture_u75a09->doDisplay(): {
|
||||
src: {
|
||||
%sTemplate.php:%d: """
|
||||
try {\\n
|
||||
\$this->doDisplay(\$context, \$blocks);\\n
|
||||
} catch (Twig_Error \$e) {\\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
%d. Twig_Template->display() ==> Twig_Template->displayWithErrorHandling(): {
|
||||
src: {
|
||||
%sTemplate.php:%d: """
|
||||
{\\n
|
||||
\$this->displayWithErrorHandling(\$this->env->mergeGlobals(\$context), array_merge(\$this->blocks, \$blocks));\\n
|
||||
}\\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
%d. Twig_Template->render() ==> Twig_Template->display(): {
|
||||
src: {
|
||||
%sTemplate.php:%d: """
|
||||
try {\\n
|
||||
\$this->display(\$context);\\n
|
||||
} catch (Exception \$e) {\\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
%d. %slosure%s() ==> Twig_Template->render(): {
|
||||
src: {
|
||||
%sCliDumperTest.php:{$line}: """
|
||||
}\\n
|
||||
};'),\\n
|
||||
));\\n
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EOTXT
|
||||
@@ -321,13 +426,10 @@ EOTXT
|
||||
$dumper->setColors(false);
|
||||
$cloner = new VarCloner();
|
||||
|
||||
$out = fopen('php://memory', 'r+b');
|
||||
$data = $cloner->cloneVar($var);
|
||||
$dumper->dump($data, $out);
|
||||
rewind($out);
|
||||
$out = stream_get_contents($out);
|
||||
$out = $dumper->dump($data, true);
|
||||
|
||||
$r = defined('HHVM_VERSION') ? '' : '#%d';
|
||||
$r = \defined('HHVM_VERSION') ? '' : '#%d';
|
||||
$this->assertStringMatchesFormat(
|
||||
<<<EOTXT
|
||||
{{$r}
|
||||
@@ -351,7 +453,7 @@ EOTXT
|
||||
$var = $this->getSpecialVars();
|
||||
|
||||
$this->assertDumpEquals(
|
||||
<<<EOTXT
|
||||
<<<'EOTXT'
|
||||
array:3 [
|
||||
0 => array:1 [
|
||||
0 => &1 array:1 [
|
||||
@@ -397,7 +499,7 @@ EOTXT
|
||||
$dumper->dump($data);
|
||||
|
||||
$this->assertSame(
|
||||
<<<EOTXT
|
||||
<<<'EOTXT'
|
||||
array:2 [
|
||||
1 => array:1 [
|
||||
"GLOBALS" => &1 array:1 [
|
||||
@@ -419,7 +521,7 @@ EOTXT
|
||||
*/
|
||||
public function testBuggyRefs()
|
||||
{
|
||||
if (PHP_VERSION_ID >= 50600) {
|
||||
if (\PHP_VERSION_ID >= 50600) {
|
||||
$this->markTestSkipped('PHP 5.6 fixed refs counting');
|
||||
}
|
||||
|
||||
@@ -439,7 +541,7 @@ EOTXT
|
||||
});
|
||||
|
||||
$this->assertSame(
|
||||
<<<EOTXT
|
||||
<<<'EOTXT'
|
||||
array:1 [
|
||||
0 => array:1 [
|
||||
0 => array:1 [
|
||||
@@ -454,6 +556,21 @@ EOTXT
|
||||
);
|
||||
}
|
||||
|
||||
public function testIncompleteClass()
|
||||
{
|
||||
$unserializeCallbackHandler = ini_set('unserialize_callback_func', null);
|
||||
$var = unserialize('O:8:"Foo\Buzz":0:{}');
|
||||
ini_set('unserialize_callback_func', $unserializeCallbackHandler);
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<EOTXT
|
||||
__PHP_Incomplete_Class(Foo\Buzz) {}
|
||||
EOTXT
|
||||
,
|
||||
$var
|
||||
);
|
||||
}
|
||||
|
||||
private function getSpecialVars()
|
||||
{
|
||||
foreach (array_keys($GLOBALS) as $var) {
|
@@ -9,19 +9,24 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarDumper\Tests;
|
||||
namespace Symfony\Component\VarDumper\Tests\Dumper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class HtmlDumperTest extends \PHPUnit_Framework_TestCase
|
||||
class HtmlDumperTest extends TestCase
|
||||
{
|
||||
public function testGet()
|
||||
{
|
||||
require __DIR__.'/Fixtures/dumb-var.php';
|
||||
if (ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) {
|
||||
$this->markTestSkipped('A custom file_link_format is defined.');
|
||||
}
|
||||
|
||||
require __DIR__.'/../Fixtures/dumb-var.php';
|
||||
|
||||
$dumper = new HtmlDumper('php://output');
|
||||
$dumper->setDumpHeader('<foo></foo>');
|
||||
@@ -46,7 +51,7 @@ class HtmlDumperTest extends \PHPUnit_Framework_TestCase
|
||||
$dumpId = $dumpId[0];
|
||||
$res = (int) $var['res'];
|
||||
|
||||
$r = defined('HHVM_VERSION') ? '' : '<a class=sf-dump-ref>#%d</a>';
|
||||
$r = \defined('HHVM_VERSION') ? '' : '<a class=sf-dump-ref>#%d</a>';
|
||||
$this->assertStringMatchesFormat(
|
||||
<<<EOTXT
|
||||
<foo></foo><bar><span class=sf-dump-note>array:24</span> [<samp>
|
||||
@@ -59,8 +64,8 @@ class HtmlDumperTest extends \PHPUnit_Framework_TestCase
|
||||
<span class=sf-dump-key>4</span> => <span class=sf-dump-num>INF</span>
|
||||
<span class=sf-dump-key>5</span> => <span class=sf-dump-num>-INF</span>
|
||||
<span class=sf-dump-key>6</span> => <span class=sf-dump-num>{$intMax}</span>
|
||||
"<span class=sf-dump-key>str</span>" => "<span class=sf-dump-str title="5 characters">d&%s;j&%s;</span>\\n"
|
||||
<span class=sf-dump-key>7</span> => b"<span class=sf-dump-str title="2 binary or non-UTF-8 characters">&%s;</span>\\x00"
|
||||
"<span class=sf-dump-key>str</span>" => "<span class=sf-dump-str title="5 characters">d&%s;j&%s;<span class=sf-dump-default>\\n</span></span>"
|
||||
<span class=sf-dump-key>7</span> => b"<span class=sf-dump-str title="2 binary or non-UTF-8 characters">&%s;<span class=sf-dump-default>\\x00</span></span>"
|
||||
"<span class=sf-dump-key>[]</span>" => []
|
||||
"<span class=sf-dump-key>res</span>" => <span class=sf-dump-note>stream resource</span> <a class=sf-dump-ref>@{$res}</a><samp>
|
||||
%A <span class=sf-dump-meta>wrapper_type</span>: "<span class=sf-dump-str title="9 characters">plainfile</span>"
|
||||
@@ -75,8 +80,9 @@ class HtmlDumperTest extends \PHPUnit_Framework_TestCase
|
||||
+"<span class=sf-dump-public title="Runtime added dynamic property">bar</span>": "<span class=sf-dump-str title="3 characters">bar</span>"
|
||||
</samp>}
|
||||
"<span class=sf-dump-key>closure</span>" => <span class=sf-dump-note>Closure</span> {{$r}<samp>
|
||||
<span class=sf-dump-meta>class</span>: "<span class=sf-dump-str title="48 characters">Symfony\Component\VarDumper\Tests\HtmlDumperTest</span>"
|
||||
<span class=sf-dump-meta>this</span>: <abbr title="Symfony\Component\VarDumper\Tests\HtmlDumperTest" class=sf-dump-note>HtmlDumperTest</abbr> {{$r} &%s;}
|
||||
<span class=sf-dump-meta>class</span>: "<span class=sf-dump-str title="Symfony\Component\VarDumper\Tests\Dumper\HtmlDumperTest
|
||||
55 characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-class">Symfony\Component\VarDumper\Tests\Dumper</span><span class=sf-dump-ellipsis>\</span>HtmlDumperTest</span>"
|
||||
<span class=sf-dump-meta>this</span>: <abbr title="Symfony\Component\VarDumper\Tests\Dumper\HtmlDumperTest" class=sf-dump-note>HtmlDumperTest</abbr> {{$r} &%s;}
|
||||
<span class=sf-dump-meta>parameters</span>: {<samp>
|
||||
<span class=sf-dump-meta>\$a</span>: {}
|
||||
<span class=sf-dump-meta>&\$b</span>: {<samp>
|
||||
@@ -84,7 +90,8 @@ class HtmlDumperTest extends \PHPUnit_Framework_TestCase
|
||||
<span class=sf-dump-meta>default</span>: <span class=sf-dump-const>null</span>
|
||||
</samp>}
|
||||
</samp>}
|
||||
<span class=sf-dump-meta>file</span>: "<span class=sf-dump-str title="%d characters">{$var['file']}</span>"
|
||||
<span class=sf-dump-meta>file</span>: "<span class=sf-dump-str title="{$var['file']}
|
||||
%d characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class=sf-dump-ellipsis>%e</span>Tests%eFixtures%edumb-var.php</span>"
|
||||
<span class=sf-dump-meta>line</span>: "<span class=sf-dump-str title="%d characters">{$var['line']} to {$var['line']}</span>"
|
||||
</samp>}
|
||||
"<span class=sf-dump-key>line</span>" => <span class=sf-dump-num>{$var['line']}</span>
|
||||
@@ -120,19 +127,41 @@ EOTXT
|
||||
$cloner = new VarCloner();
|
||||
|
||||
$data = $cloner->cloneVar($var);
|
||||
$out = fopen('php://memory', 'r+b');
|
||||
$dumper->dump($data, $out);
|
||||
rewind($out);
|
||||
$out = stream_get_contents($out);
|
||||
$out = $dumper->dump($data, true);
|
||||
|
||||
$this->assertStringMatchesFormat(
|
||||
<<<EOTXT
|
||||
<<<'EOTXT'
|
||||
<foo></foo><bar>b"<span class=sf-dump-str title="7 binary or non-UTF-8 characters">Словарь</span>"
|
||||
</bar>
|
||||
|
||||
EOTXT
|
||||
,
|
||||
$out
|
||||
);
|
||||
}
|
||||
|
||||
public function testAppend()
|
||||
{
|
||||
$out = fopen('php://memory', 'r+b');
|
||||
|
||||
$dumper = new HtmlDumper();
|
||||
$dumper->setDumpHeader('<foo></foo>');
|
||||
$dumper->setDumpBoundaries('<bar>', '</bar>');
|
||||
$cloner = new VarCloner();
|
||||
|
||||
$dumper->dump($cloner->cloneVar(123), $out);
|
||||
$dumper->dump($cloner->cloneVar(456), $out);
|
||||
|
||||
$out = stream_get_contents($out, -1, 0);
|
||||
|
||||
$this->assertSame(<<<'EOTXT'
|
||||
<foo></foo><bar><span class=sf-dump-num>123</span>
|
||||
</bar>
|
||||
<bar><span class=sf-dump-num>456</span>
|
||||
</bar>
|
||||
|
||||
EOTXT
|
||||
,
|
||||
$out
|
||||
);
|
||||
}
|
11
vendor/symfony/var-dumper/Tests/Fixtures/FooInterface.php
vendored
Normal file
11
vendor/symfony/var-dumper/Tests/Fixtures/FooInterface.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\VarDumper\Tests\Fixtures;
|
||||
|
||||
interface FooInterface
|
||||
{
|
||||
/**
|
||||
* Hello.
|
||||
*/
|
||||
public function foo();
|
||||
}
|
@@ -1,16 +1,18 @@
|
||||
<?php
|
||||
|
||||
/* foo.twig */
|
||||
class __TwigTemplate_VarDumperFixture_u75a09 extends Twig_Template
|
||||
class __TwigTemplate_VarDumperFixture_u75a09 extends Twig\Template
|
||||
{
|
||||
public function __construct(Twig_Environment $env)
|
||||
private $path;
|
||||
|
||||
public function __construct(Twig\Environment $env = null, $path = null)
|
||||
{
|
||||
parent::__construct($env);
|
||||
|
||||
if (null !== $env) {
|
||||
parent::__construct($env);
|
||||
}
|
||||
$this->parent = false;
|
||||
|
||||
$this->blocks = array(
|
||||
);
|
||||
$this->blocks = array();
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
protected function doDisplay(array $context, array $blocks = array())
|
||||
@@ -26,9 +28,11 @@ class __TwigTemplate_VarDumperFixture_u75a09 extends Twig_Template
|
||||
|
||||
public function getDebugInfo()
|
||||
{
|
||||
return array (19 => 2);
|
||||
return array(20 => 1, 21 => 2);
|
||||
}
|
||||
|
||||
public function getSourceContext()
|
||||
{
|
||||
return new Twig\Source(" foo bar\n twig source\n\n", 'foo.twig', $this->path ?: __FILE__);
|
||||
}
|
||||
}
|
||||
/* foo bar*/
|
||||
/* twig source*/
|
||||
/* */
|
||||
|
10
vendor/symfony/var-dumper/Tests/Fixtures/xml_reader.xml
vendored
Normal file
10
vendor/symfony/var-dumper/Tests/Fixtures/xml_reader.xml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<foo>
|
||||
<bar></bar>
|
||||
<bar />
|
||||
<bar>With text</bar>
|
||||
<bar foo="bar" baz="fubar"></bar>
|
||||
<bar xmlns:baz="http://symfony.com">
|
||||
<baz:baz></baz:baz>
|
||||
</bar>
|
||||
</foo>
|
@@ -11,9 +11,10 @@
|
||||
|
||||
namespace Symfony\Component\VarDumper\Tests\Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
|
||||
|
||||
class VarDumperTestTraitTest extends \PHPUnit_Framework_TestCase
|
||||
class VarDumperTestTraitTest extends TestCase
|
||||
{
|
||||
use VarDumperTestTrait;
|
||||
|
||||
|
253
vendor/symfony/var-dumper/Tests/VarClonerTest.php
vendored
253
vendor/symfony/var-dumper/Tests/VarClonerTest.php
vendored
@@ -1,253 +0,0 @@
|
||||
<?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;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class VarClonerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testMaxIntBoundary()
|
||||
{
|
||||
$data = array(PHP_INT_MAX => 123);
|
||||
|
||||
$cloner = new VarCloner();
|
||||
$clone = $cloner->cloneVar($data);
|
||||
|
||||
$expected = <<<EOTXT
|
||||
Symfony\Component\VarDumper\Cloner\Data Object
|
||||
(
|
||||
[data:Symfony\Component\VarDumper\Cloner\Data:private] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => Symfony\Component\VarDumper\Cloner\Stub Object
|
||||
(
|
||||
[type] => array
|
||||
[class] => assoc
|
||||
[value] => 1
|
||||
[cut] => 0
|
||||
[handle] => 0
|
||||
[refCount] => 0
|
||||
[position] => 1
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[%s] => 123
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[maxDepth:Symfony\Component\VarDumper\Cloner\Data:private] => 20
|
||||
[maxItemsPerDepth:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
[useRefHandles:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
)
|
||||
|
||||
EOTXT;
|
||||
$this->assertSame(sprintf($expected, PHP_INT_MAX), print_r($clone, true));
|
||||
}
|
||||
|
||||
public function testClone()
|
||||
{
|
||||
$json = json_decode('{"1":{"var":"val"},"2":{"var":"val"}}');
|
||||
|
||||
$cloner = new VarCloner();
|
||||
$clone = $cloner->cloneVar($json);
|
||||
|
||||
$expected = <<<EOTXT
|
||||
Symfony\Component\VarDumper\Cloner\Data Object
|
||||
(
|
||||
[data:Symfony\Component\VarDumper\Cloner\Data:private] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => Symfony\Component\VarDumper\Cloner\Stub Object
|
||||
(
|
||||
[type] => object
|
||||
[class] => stdClass
|
||||
[value] =>
|
||||
[cut] => 0
|
||||
[handle] => %i
|
||||
[refCount] => 0
|
||||
[position] => 1
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[\000+\0001] => Symfony\Component\VarDumper\Cloner\Stub Object
|
||||
(
|
||||
[type] => object
|
||||
[class] => stdClass
|
||||
[value] =>
|
||||
[cut] => 0
|
||||
[handle] => %i
|
||||
[refCount] => 0
|
||||
[position] => 2
|
||||
)
|
||||
|
||||
[\000+\0002] => Symfony\Component\VarDumper\Cloner\Stub Object
|
||||
(
|
||||
[type] => object
|
||||
[class] => stdClass
|
||||
[value] =>
|
||||
[cut] => 0
|
||||
[handle] => %i
|
||||
[refCount] => 0
|
||||
[position] => 3
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[2] => Array
|
||||
(
|
||||
[\000+\000var] => val
|
||||
)
|
||||
|
||||
[3] => Array
|
||||
(
|
||||
[\000+\000var] => val
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[maxDepth:Symfony\Component\VarDumper\Cloner\Data:private] => 20
|
||||
[maxItemsPerDepth:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
[useRefHandles:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
)
|
||||
|
||||
EOTXT;
|
||||
$this->assertStringMatchesFormat($expected, print_r($clone, true));
|
||||
}
|
||||
|
||||
public function testJsonCast()
|
||||
{
|
||||
$data = (array) json_decode('{"1":{}}');
|
||||
|
||||
$cloner = new VarCloner();
|
||||
$clone = $cloner->cloneVar($data);
|
||||
|
||||
$expected = <<<'EOTXT'
|
||||
object(Symfony\Component\VarDumper\Cloner\Data)#%i (4) {
|
||||
["data":"Symfony\Component\VarDumper\Cloner\Data":private]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
object(Symfony\Component\VarDumper\Cloner\Stub)#%i (7) {
|
||||
["type"]=>
|
||||
string(5) "array"
|
||||
["class"]=>
|
||||
string(5) "assoc"
|
||||
["value"]=>
|
||||
int(1)
|
||||
["cut"]=>
|
||||
int(0)
|
||||
["handle"]=>
|
||||
int(0)
|
||||
["refCount"]=>
|
||||
int(0)
|
||||
["position"]=>
|
||||
int(1)
|
||||
}
|
||||
}
|
||||
[1]=>
|
||||
array(1) {
|
||||
["1"]=>
|
||||
object(Symfony\Component\VarDumper\Cloner\Stub)#%i (7) {
|
||||
["type"]=>
|
||||
string(6) "object"
|
||||
["class"]=>
|
||||
string(8) "stdClass"
|
||||
["value"]=>
|
||||
NULL
|
||||
["cut"]=>
|
||||
int(0)
|
||||
["handle"]=>
|
||||
int(%i)
|
||||
["refCount"]=>
|
||||
int(0)
|
||||
["position"]=>
|
||||
int(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
["maxDepth":"Symfony\Component\VarDumper\Cloner\Data":private]=>
|
||||
int(20)
|
||||
["maxItemsPerDepth":"Symfony\Component\VarDumper\Cloner\Data":private]=>
|
||||
int(-1)
|
||||
["useRefHandles":"Symfony\Component\VarDumper\Cloner\Data":private]=>
|
||||
int(-1)
|
||||
}
|
||||
|
||||
EOTXT;
|
||||
ob_start();
|
||||
var_dump($clone);
|
||||
$this->assertStringMatchesFormat($expected, ob_get_clean());
|
||||
}
|
||||
|
||||
public function testCaster()
|
||||
{
|
||||
$cloner = new VarCloner(array(
|
||||
'*' => function ($obj, $array) {
|
||||
return array('foo' => 123);
|
||||
},
|
||||
__CLASS__ => function ($obj, $array) {
|
||||
++$array['foo'];
|
||||
|
||||
return $array;
|
||||
},
|
||||
));
|
||||
$clone = $cloner->cloneVar($this);
|
||||
|
||||
$expected = <<<EOTXT
|
||||
Symfony\Component\VarDumper\Cloner\Data Object
|
||||
(
|
||||
[data:Symfony\Component\VarDumper\Cloner\Data:private] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => Symfony\Component\VarDumper\Cloner\Stub Object
|
||||
(
|
||||
[type] => object
|
||||
[class] => %s
|
||||
[value] =>
|
||||
[cut] => 0
|
||||
[handle] => %i
|
||||
[refCount] => 0
|
||||
[position] => 1
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[foo] => 124
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[maxDepth:Symfony\Component\VarDumper\Cloner\Data:private] => 20
|
||||
[maxItemsPerDepth:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
[useRefHandles:Symfony\Component\VarDumper\Cloner\Data:private] => -1
|
||||
)
|
||||
|
||||
EOTXT;
|
||||
$this->assertStringMatchesFormat($expected, print_r($clone, true));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user