composer update

This commit is contained in:
Oliver Davies 2019-01-24 08:00:03 +00:00
parent f6abc3dce2
commit 71dfaca858
1753 changed files with 45274 additions and 14619 deletions

View file

@ -223,6 +223,23 @@ Exception {
#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,299 @@
<?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 = $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 = $var->getAttribute(\NumberFormatter::MIN_SIGNIFICANT_DIGITS);
$expectedAttribute19 = $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();
$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 = $expectedCalendarObjectTimeZone->getDSTSavings();
$expectedTimeZone = $var->getTimeZone();
$expectedTimeZoneDisplayName = $expectedTimeZone->getDisplayName();
$expectedTimeZoneID = $expectedTimeZone->getID();
$expectedTimeZoneRawOffset = $expectedTimeZone->getRawOffset();
$expectedTimeZoneDSTSavings = $expectedTimeZone->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
dst_savings: $expectedCalendarObjectTimeZoneDSTSavings
}
}
time_zone: IntlTimeZone {
display_name: "$expectedTimeZoneDisplayName"
id: "$expectedTimeZoneID"
raw_offset: $expectedTimeZoneRawOffset
dst_savings: $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

@ -49,11 +49,15 @@ Redis {%A
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

View file

@ -68,14 +68,14 @@ EOTXT
$var = function ($x) use ($a, &$b) {};
$this->assertDumpMatchesFormat(
<<<EOTXT
Closure {
<<<'EOTXT'
Closure($x) {
%Aparameters: {
\$x: {}
$x: {}
}
use: {
\$a: 123
\$b: & 123
$a: 123
$b: & 123
}
file: "%sReflectionCasterTest.php"
line: "68 to 68"
@ -85,18 +85,39 @@ EOTXT
);
}
public function testFromCallableClosureCaster()
{
if (\defined('HHVM_VERSION_ID')) {
$this->markTestSkipped('Not for HHVM.');
}
$var = array(
(new \ReflectionMethod($this, __FUNCTION__))->getClosure($this),
(new \ReflectionMethod(__CLASS__, 'tearDownAfterClass'))->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 => %sTestCase::tearDownAfterClass() {
file: "%sTestCase.php"
line: "%d to %d"
}
]
EOTXT
, $var
);
}
public function testClosureCasterExcludingVerbosity()
{
$var = function () {};
$var = function &($a = 5) {};
$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);
$this->assertDumpEquals('Closure&($a = 5) { …6}', $var, Caster::EXCLUDE_VERBOSE);
}
public function testReflectionParameter()
@ -140,7 +161,7 @@ EOTXT
$this->assertDumpMatchesFormat(
<<<EOTXT
Closure {
Closure(): int {
returnType: "int"
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { }

View file

@ -35,7 +35,7 @@ SplFileInfo {
aTime: %s-%s-%d %d:%d:%d
mTime: %s-%s-%d %d:%d:%d
cTime: %s-%s-%d %d:%d:%d
inode: %d
inode: %i
size: %d
perms: 0%d
owner: %d
@ -85,7 +85,7 @@ SplFileObject {
aTime: %s-%s-%d %d:%d:%d
mTime: %s-%s-%d %d:%d:%d
cTime: %s-%s-%d %d:%d:%d
inode: %d
inode: %i
size: %d
perms: 0%d
owner: %d
@ -105,7 +105,7 @@ SplFileObject {
maxLineLen: 0
fstat: array:26 [
"dev" => %d
"ino" => %d
"ino" => %i
"nlink" => %d
"rdev" => 0
"blksize" => %i

View file

@ -141,7 +141,7 @@ EODUMP;
$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>"
<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;
@ -185,6 +185,27 @@ EODUMP;
<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 = array(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, 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="%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,134 @@
<?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\Command\Descriptor;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\VarDumper\Cloner\Data;
use Symfony\Component\VarDumper\Command\Descriptor\CliDescriptor;
use Symfony\Component\VarDumper\Dumper\CliDumper;
class CliDescriptorTest extends TestCase
{
private static $timezone;
public static function setUpBeforeClass()
{
self::$timezone = date_default_timezone_get();
date_default_timezone_set('UTC');
}
public static function tearDownAfterClass()
{
date_default_timezone_set(self::$timezone);
}
/**
* @dataProvider provideContext
*/
public function testDescribe(array $context, string $expectedOutput)
{
$output = new BufferedOutput();
$descriptor = new CliDescriptor(new CliDumper(function ($s) {
return $s;
}));
$descriptor->describe($output, new Data(array(array(123))), $context + array('timestamp' => 1544804268.3668), 1);
$this->assertStringMatchesFormat(trim($expectedOutput), str_replace(PHP_EOL, "\n", trim($output->fetch())));
}
public function provideContext()
{
yield 'source' => array(
array(
'source' => array(
'name' => 'CliDescriptorTest.php',
'line' => 30,
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
),
),
<<<TXT
Received from client #1
-----------------------
-------- ---------------------------------------------------------------------------------------------------
date Fri, 14 Dec 2018 16:17:48 +0000
source CliDescriptorTest.php on line 30
file /Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php
-------- ---------------------------------------------------------------------------------------------------
TXT
);
yield 'source full' => array(
array(
'source' => array(
'name' => 'CliDescriptorTest.php',
'line' => 30,
'file_relative' => 'src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
'file_link' => 'phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30',
),
),
<<<TXT
Received from client #1
-----------------------
-------- --------------------------------------------------------------------------------
date Fri, 14 Dec 2018 16:17:48 +0000
source CliDescriptorTest.php on line 30
file src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php
-------- --------------------------------------------------------------------------------
Open source in your IDE/browser:
phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30
TXT
);
yield 'cli' => array(
array(
'cli' => array(
'identifier' => 'd8bece1c',
'command_line' => 'bin/phpunit',
),
),
<<<TXT
$ bin/phpunit
-------------
------ ---------------------------------
date Fri, 14 Dec 2018 16:17:48 +0000
------ ---------------------------------
TXT
);
yield 'request' => array(
array(
'request' => array(
'identifier' => 'd8bece1c',
'controller' => new Data(array(array('FooController.php'))),
'method' => 'GET',
'uri' => 'http://localhost/foo',
),
),
<<<TXT
GET http://localhost/foo
------------------------
------------ ---------------------------------
date Fri, 14 Dec 2018 16:17:48 +0000
controller "FooController.php"
------------ ---------------------------------
TXT
);
}
}

View file

@ -0,0 +1,195 @@
<?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\Command\Descriptor;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\VarDumper\Cloner\Data;
use Symfony\Component\VarDumper\Command\Descriptor\HtmlDescriptor;
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
class HtmlDescriptorTest extends TestCase
{
private static $timezone;
public static function setUpBeforeClass()
{
self::$timezone = date_default_timezone_get();
date_default_timezone_set('UTC');
}
public static function tearDownAfterClass()
{
date_default_timezone_set(self::$timezone);
}
public function testItOutputsStylesAndScriptsOnFirstDescribeCall()
{
$output = new BufferedOutput();
$dumper = $this->createMock(HtmlDumper::class);
$dumper->method('dump')->willReturn('[DUMPED]');
$descriptor = new HtmlDescriptor($dumper);
$descriptor->describe($output, new Data(array(array(123))), array('timestamp' => 1544804268.3668), 1);
$this->assertStringMatchesFormat('<style>%A</style><script>%A</script>%A', $output->fetch(), 'styles & scripts are output');
$descriptor->describe($output, new Data(array(array(123))), array('timestamp' => 1544804268.3668), 1);
$this->assertStringNotMatchesFormat('<style>%A</style><script>%A</script>%A', $output->fetch(), 'styles & scripts are output only once');
}
/**
* @dataProvider provideContext
*/
public function testDescribe(array $context, string $expectedOutput)
{
$output = new BufferedOutput();
$dumper = $this->createMock(HtmlDumper::class);
$dumper->method('dump')->willReturn('[DUMPED]');
$descriptor = new HtmlDescriptor($dumper);
$descriptor->describe($output, new Data(array(array(123))), $context + array('timestamp' => 1544804268.3668), 1);
$this->assertStringMatchesFormat(trim($expectedOutput), trim(preg_replace('@<style>.*</style><script>.*</script>@s', '', $output->fetch())));
}
public function provideContext()
{
yield 'source' => array(
array(
'source' => array(
'name' => 'CliDescriptorTest.php',
'line' => 30,
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
),
),
<<<TXT
<article data-dedup-id="%s">
<header>
<div class="row">
<h2 class="col">-</h2>
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
Fri, 14 Dec 2018 16:17:48 +0000
</time>
</div>
</header>
<section class="body">
<p class="text-small">
CliDescriptorTest.php on line 30
</p>
[DUMPED]
</section>
</article>
TXT
);
yield 'source full' => array(
array(
'source' => array(
'name' => 'CliDescriptorTest.php',
'project_dir' => 'src/Symfony/',
'line' => 30,
'file_relative' => 'src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
'file_link' => 'phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30',
),
),
<<<TXT
<article data-dedup-id="%s">
<header>
<div class="row">
<h2 class="col">-</h2>
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
Fri, 14 Dec 2018 16:17:48 +0000
</time>
</div>
<div class="row">
<ul class="tags">
<li><span class="badge">project dir</span>src/Symfony/</li>
</ul>
</div>
</header>
<section class="body">
<p class="text-small">
<a href="phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30">CliDescriptorTest.php on line 30</a>
</p>
[DUMPED]
</section>
</article>
TXT
);
yield 'cli' => array(
array(
'cli' => array(
'identifier' => 'd8bece1c',
'command_line' => 'bin/phpunit',
),
),
<<<TXT
<article data-dedup-id="d8bece1c">
<header>
<div class="row">
<h2 class="col"><code>$ </code>bin/phpunit</h2>
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
Fri, 14 Dec 2018 16:17:48 +0000
</time>
</div>
</header>
<section class="body">
<p class="text-small">
</p>
[DUMPED]
</section>
</article>
TXT
);
yield 'request' => array(
array(
'request' => array(
'identifier' => 'd8bece1c',
'controller' => new Data(array(array('FooController.php'))),
'method' => 'GET',
'uri' => 'http://localhost/foo',
),
),
<<<TXT
<article data-dedup-id="d8bece1c">
<header>
<div class="row">
<h2 class="col"><code>GET</code> <a href="http://localhost/foo">http://localhost/foo</a></h2>
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
Fri, 14 Dec 2018 16:17:48 +0000
</time>
</div>
<div class="row">
<ul class="tags">
<li><span class="badge">controller</span><span class='dumped-tag'>[DUMPED]</span></li>
</ul>
</div>
</header>
<section class="body">
<p class="text-small">
</p>
[DUMPED]
</section>
</article>
TXT
);
}
}

View file

@ -61,7 +61,10 @@ array:24 [
5 => -INF
6 => {$intMax}
"str" => "déjà\\n"
7 => b"é\\x00"
7 => b"""
é\\x00test\\t\\n
ing
"""
"[]" => []
"res" => stream resource {@{$res}
%A wrapper_type: "plainfile"
@ -75,7 +78,7 @@ array:24 [
+foo: "foo"
+"bar": "bar"
}
"closure" => Closure {#%d
"closure" => Closure(\$a, PDO &\$b = null) {#%d
class: "Symfony\Component\VarDumper\Tests\Dumper\CliDumperTest"
this: Symfony\Component\VarDumper\Tests\Dumper\CliDumperTest {#%d …}
parameters: {

View file

@ -63,8 +63,11 @@ class HtmlDumperTest extends 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 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>str</span>" => "<span class=sf-dump-str title="5 characters">d&%s;j&%s;<span class="sf-dump-default sf-dump-ns">\\n</span></span>"
<span class=sf-dump-key>7</span> => b"""
<span class=sf-dump-str title="11 binary or non-UTF-8 characters">&eacute;<span class="sf-dump-default">\\x00</span>test<span class="sf-dump-default">\\t</span><span class="sf-dump-default sf-dump-ns">\\n</span></span>
<span class=sf-dump-str title="11 binary or non-UTF-8 characters">ing</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>"
@ -78,7 +81,7 @@ class HtmlDumperTest extends TestCase
+<span class=sf-dump-public title="Public property">foo</span>: "<span class=sf-dump-str title="3 characters">foo</span>"
+"<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> {<a class=sf-dump-ref>#%d</a><samp>
"<span class=sf-dump-key>closure</span>" => <span class=sf-dump-note>Closure(\$a, PDO &amp;\$b = null)</span> {<a class=sf-dump-ref>#%d</a><samp>
<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> {<a class=sf-dump-ref>#%d</a> &%s;}

View file

@ -7,5 +7,5 @@ interface FooInterface
/**
* Hello.
*/
public function foo();
public function foo(?\stdClass $a, \stdClass $b = null);
}

View file

@ -17,7 +17,7 @@ $g = fopen(__FILE__, 'r');
$var = array(
'number' => 1, null,
'const' => 1.1, true, false, NAN, INF, -INF, PHP_INT_MAX,
'str' => "déjà\n", "\xE9\x00",
'str' => "déjà\n", "\xE9\x00test\t\ning",
'[]' => array(),
'res' => $g,
'obj' => $foo,