Laravel 5.6 updates

Travis config update

Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
Manish Verma
2018-08-06 20:08:55 +05:30
parent 126fbb0255
commit 1ac0f42a58
2464 changed files with 65239 additions and 46734 deletions

View File

@@ -151,9 +151,6 @@ class CasterTest extends TestCase
);
}
/**
* @requires PHP 7.0
*/
public function testAnonymousClass()
{
$c = eval('return new class extends stdClass { private $foo = "foo"; };');

View File

@@ -29,10 +29,6 @@ class DateCasterTest extends TestCase
*/
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
@@ -49,10 +45,6 @@ EODUMP;
*/
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);
@@ -181,35 +173,32 @@ EODUMP;
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('PT0S', 0.1, 0, '+ 00:00:00.100', '%is'),
array('PT1S', 0, 0, '+ 00:00:01.0', '%is'),
array('PT2M', 0, 0, '+ 00:02:00.0', '%is'),
array('PT3H', 0, 0, '+ 03:00:00.0', '%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('P1Y2M3DT4H5M6S', 0, 0, '+ 1y 2m 3d 04:05:06.0', null),
array('PT1M60S', 0, 0, '+ 00:02:00.0', null),
array('PT1H60M', 0, 0, '+ 02:00:00.0', 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('PT0S', 0.1, 1, '- 00:00:00.100', '%is'),
array('PT1S', 0, 1, '- 00:00:01.0', '%is'),
array('PT2M', 0, 1, '- 00:02:00.0', '%is'),
array('PT3H', 0, 1, '- 03:00:00.0', '%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('P1Y2M3DT4H5M6S', 0, 1, '- 1y 2m 3d 04:05:06.0', null),
array('PT1M60S', 0, 1, '- 00:02:00.0', null),
array('PT1H60M', 0, 1, '- 02:00:00.0', null),
array('P1DT24H', 0, 1, '- 2d', null),
array('P1M32D', 0, 1, '- 1m 32d', null),
);
@@ -220,10 +209,6 @@ EODUMP;
*/
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
@@ -240,10 +225,6 @@ EODUMP;
*/
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
@@ -260,10 +241,6 @@ EODUMP;
*/
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();
@@ -325,10 +302,6 @@ EODUMP;
*/
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
@@ -345,10 +318,6 @@ EODUMP;
*/
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();
@@ -380,9 +349,6 @@ EODUMP;
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'),
@@ -399,8 +365,8 @@ EODUMP;
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', 'P1DT1H', '2017-01-03', 0, 'every + 1d 01:00:00.0, from 2017-01-01 00:00:00.0 (included) to 2017-01-03 00:00:00.0', '1) 2017-01-01 00:00:00.0%a2) 2017-01-02 01:00:00.0'),
array('2017-01-01', 'P1DT1H', 1, 0, 'every + 1d 01:00:00.0, from 2017-01-01 00:00:00.0 (included) recurring 2 time/s', '1) 2017-01-01 00:00:00.0%a2) 2017-01-02 01:00:00.0'),
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'),
@@ -416,9 +382,7 @@ EODUMP;
private function createInterval($intervalSpec, $ms, $invert)
{
$interval = new \DateInterval($intervalSpec);
if (\PHP_VERSION_ID >= 70100 && isset($interval->f)) {
$interval->f = $ms;
}
$interval->f = $ms;
$interval->invert = $invert;
return $interval;

View File

@@ -0,0 +1,48 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\VarDumper\Tests\Caster;
use PHPUnit\Framework\TestCase;
use Symfony\Component\VarDumper\Caster\GmpCaster;
use Symfony\Component\VarDumper\Cloner\Stub;
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
class GmpCasterTest extends TestCase
{
use VarDumperTestTrait;
/**
* @requires extension gmp
*/
public function testCastGmp()
{
$gmpString = gmp_init('1234');
$gmpOctal = gmp_init(010);
$gmp = gmp_init('01101');
$gmpDump = <<<EODUMP
array:1 [
"\\x00~\\x00value" => %s
]
EODUMP;
$this->assertDumpEquals(sprintf($gmpDump, $gmpString), GmpCaster::castGmp($gmpString, array(), new Stub(), false, 0));
$this->assertDumpEquals(sprintf($gmpDump, $gmpOctal), GmpCaster::castGmp($gmpOctal, array(), new Stub(), false, 0));
$this->assertDumpEquals(sprintf($gmpDump, $gmp), GmpCaster::castGmp($gmp, array(), new Stub(), false, 0));
$dump = <<<EODUMP
GMP {
value: 577
}
EODUMP;
$this->assertDumpEquals($dump, $gmp);
}
}

View File

@@ -26,20 +26,11 @@ class RedisCasterTest extends TestCase
{
$redis = new \Redis();
if (\defined('HHVM_VERSION_ID')) {
$xCast = <<<'EODUMP'
Redis {
#host: ""
%A
}
EODUMP;
} else {
$xCast = <<<'EODUMP'
$xCast = <<<'EODUMP'
Redis {
isConnected: false
}
EODUMP;
}
$this->assertDumpMatchesFormat($xCast, $redis);
}
@@ -52,15 +43,7 @@ EODUMP;
self::markTestSkipped($e['message']);
}
if (\defined('HHVM_VERSION_ID')) {
$xCast = <<<'EODUMP'
Redis {
#host: "127.0.0.1"
%A
}
EODUMP;
} else {
$xCast = <<<'EODUMP'
$xCast = <<<'EODUMP'
Redis {%A
isConnected: true
host: "127.0.0.1"
@@ -77,7 +60,6 @@ Redis {%A
}
}
EODUMP;
}
$this->assertDumpMatchesFormat($xCast, $redis);
}

View File

@@ -116,9 +116,6 @@ EOTXT
);
}
/**
* @requires PHP 7.0
*/
public function testReflectionParameterScalar()
{
$f = eval('return function (int $a) {};');
@@ -136,9 +133,6 @@ EOTXT
);
}
/**
* @requires PHP 7.0
*/
public function testReturnType()
{
$f = eval('return function ():int {};');
@@ -158,9 +152,6 @@ EOTXT
);
}
/**
* @requires PHP 7.0
*/
public function testGenerator()
{
if (\extension_loaded('xdebug')) {

View File

@@ -166,9 +166,6 @@ EOTXT;
public function testCastArrayObject()
{
if (\defined('HHVM_VERSION')) {
$this->markTestSkipped('HHVM as different internal details.');
}
$var = new \ArrayObject(array(123));
$var->foo = 234;
@@ -188,9 +185,6 @@ EOTXT;
public function testArrayIterator()
{
if (\defined('HHVM_VERSION')) {
$this->markTestSkipped('HHVM as different internal details.');
}
$var = new MyArrayIterator(array(234));
$expected = <<<EOTXT

View File

@@ -48,7 +48,6 @@ class CliDumperTest extends TestCase
$intMax = PHP_INT_MAX;
$res = (int) $var['res'];
$r = \defined('HHVM_VERSION') ? '' : '#%d';
$this->assertStringMatchesFormat(
<<<EOTXT
array:24 [
@@ -76,9 +75,9 @@ array:24 [
+foo: "foo"
+"bar": "bar"
}
"closure" => Closure {{$r}
"closure" => Closure {#%d
class: "Symfony\Component\VarDumper\Tests\Dumper\CliDumperTest"
this: Symfony\Component\VarDumper\Tests\Dumper\CliDumperTest {{$r} …}
this: Symfony\Component\VarDumper\Tests\Dumper\CliDumperTest {#%d …}
parameters: {
\$a: {}
&\$b: {
@@ -290,10 +289,6 @@ EOTXT
public function testClosedResource()
{
if (\defined('HHVM_VERSION') && HHVM_VERSION_ID < 30600) {
$this->markTestSkipped();
}
$var = fopen(__FILE__, 'r');
fclose($var);
@@ -384,11 +379,10 @@ EOTXT
$dumper->dump($data, $out);
$out = stream_get_contents($out, -1, 0);
$r = \defined('HHVM_VERSION') ? '' : '#%d';
$this->assertStringMatchesFormat(
<<<EOTXT
stream resource {@{$ref}
⚠: Symfony\Component\VarDumper\Exception\ThrowingCasterException {{$r}
⚠: Symfony\Component\VarDumper\Exception\ThrowingCasterException {#%d
#message: "Unexpected Exception thrown from a caster: Foobar"
trace: {
%sTwig.php:2 {
@@ -429,10 +423,9 @@ EOTXT
$data = $cloner->cloneVar($var);
$out = $dumper->dump($data, true);
$r = \defined('HHVM_VERSION') ? '' : '#%d';
$this->assertStringMatchesFormat(
<<<EOTXT
{{$r}
{#%d
+"foo": &1 "foo"
+"bar": &1 "foo"
}
@@ -446,7 +439,6 @@ EOTXT
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
* @requires PHP 5.6
*/
public function testSpecialVars56()
{
@@ -477,7 +469,7 @@ EOTXT
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testGlobalsNoExt()
public function testGlobals()
{
$var = $this->getSpecialVars();
unset($var[0]);
@@ -491,10 +483,6 @@ EOTXT
$dumper->setColors(false);
$cloner = new VarCloner();
$refl = new \ReflectionProperty($cloner, 'useExt');
$refl->setAccessible(true);
$refl->setValue($cloner, false);
$data = $cloner->cloneVar($var);
$dumper->dump($data);
@@ -509,47 +497,6 @@ array:2 [
2 => &1 array:1 [&1]
]
EOTXT
,
$out
);
}
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testBuggyRefs()
{
if (\PHP_VERSION_ID >= 50600) {
$this->markTestSkipped('PHP 5.6 fixed refs counting');
}
$var = $this->getSpecialVars();
$var = $var[0];
$dumper = new CliDumper();
$dumper->setColors(false);
$cloner = new VarCloner();
$data = $cloner->cloneVar($var)->withMaxDepth(3);
$out = '';
$dumper->dump($data, function ($line, $depth) use (&$out) {
if ($depth >= 0) {
$out .= str_repeat(' ', $depth).$line."\n";
}
});
$this->assertSame(
<<<'EOTXT'
array:1 [
0 => array:1 [
0 => array:1 [
0 => array:1 [ …1]
]
]
]
EOTXT
,
$out

View File

@@ -51,7 +51,6 @@ class HtmlDumperTest extends TestCase
$dumpId = $dumpId[0];
$res = (int) $var['res'];
$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>
@@ -79,10 +78,10 @@ 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> {{$r}<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-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>this</span>: <abbr title="Symfony\Component\VarDumper\Tests\Dumper\HtmlDumperTest" class=sf-dump-note>HtmlDumperTest</abbr> {<a class=sf-dump-ref>#%d</a> &%s;}
<span class=sf-dump-meta>parameters</span>: {<samp>
<span class=sf-dump-meta>\$a</span>: {}
<span class=sf-dump-meta>&amp;\$b</span>: {<samp>

View File

@@ -0,0 +1,95 @@
<?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\Dumper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\PhpProcess;
use Symfony\Component\Process\Process;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\ContextProvider\ContextProviderInterface;
use Symfony\Component\VarDumper\Dumper\DataDumperInterface;
use Symfony\Component\VarDumper\Dumper\ServerDumper;
class ServerDumperTest extends TestCase
{
private const VAR_DUMPER_SERVER = 'tcp://127.0.0.1:9913';
public function testDumpForwardsToWrappedDumperWhenServerIsUnavailable()
{
$wrappedDumper = $this->getMockBuilder(DataDumperInterface::class)->getMock();
$dumper = new ServerDumper(self::VAR_DUMPER_SERVER, $wrappedDumper);
$cloner = new VarCloner();
$data = $cloner->cloneVar('foo');
$wrappedDumper->expects($this->once())->method('dump')->with($data);
$dumper->dump($data);
}
public function testDump()
{
$wrappedDumper = $this->getMockBuilder(DataDumperInterface::class)->getMock();
$wrappedDumper->expects($this->never())->method('dump'); // test wrapped dumper is not used
$cloner = new VarCloner();
$data = $cloner->cloneVar('foo');
$dumper = new ServerDumper(self::VAR_DUMPER_SERVER, $wrappedDumper, array(
'foo_provider' => new class() implements ContextProviderInterface {
public function getContext(): ?array
{
return array('foo');
}
},
));
$dumped = null;
$process = $this->getServerProcess();
$process->start(function ($type, $buffer) use ($process, &$dumped, $dumper, $data) {
if (Process::ERR === $type) {
$process->stop();
$this->fail();
} elseif ("READY\n" === $buffer) {
$dumper->dump($data);
} else {
$dumped .= $buffer;
}
});
$process->wait();
$this->assertTrue($process->isSuccessful());
$this->assertStringMatchesFormat(<<<'DUMP'
(3) "foo"
[
"timestamp" => %d.%d
"foo_provider" => [
(3) "foo"
]
]
%d
DUMP
, $dumped);
}
private function getServerProcess(): Process
{
$process = new PhpProcess(file_get_contents(__DIR__.'/../Fixtures/dump_server.php'), null, array(
'COMPONENT_ROOT' => __DIR__.'/../../',
'VAR_DUMPER_SERVER' => self::VAR_DUMPER_SERVER,
));
$process->inheritEnvironmentVariables(true);
return $process->setTimeout(9);
}
}

View File

@@ -0,0 +1,38 @@
<?php
use Symfony\Component\VarDumper\Cloner\Data;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;
use Symfony\Component\VarDumper\Server\DumpServer;
use Symfony\Component\VarDumper\VarDumper;
$componentRoot = $_SERVER['COMPONENT_ROOT'];
if (!is_file($file = $componentRoot.'/vendor/autoload.php')) {
$file = $componentRoot.'/../../../../vendor/autoload.php';
}
require $file;
$cloner = new VarCloner();
$cloner->setMaxItems(-1);
$dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_STRING_LENGTH);
$dumper->setColors(false);
VarDumper::setHandler(function ($var) use ($cloner, $dumper) {
$data = $cloner->cloneVar($var)->withRefHandles(false);
$dumper->dump($data);
});
$server = new DumpServer(getenv('VAR_DUMPER_SERVER'));
$server->start();
echo "READY\n";
$server->listen(function (Data $data, array $context, $clientId) {
dump((string) $data, $context, $clientId);
exit(0);
});

View File

@@ -0,0 +1,88 @@
<?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\Server;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\PhpProcess;
use Symfony\Component\Process\Process;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\ContextProvider\ContextProviderInterface;
use Symfony\Component\VarDumper\Server\Connection;
class ConnectionTest extends TestCase
{
private const VAR_DUMPER_SERVER = 'tcp://127.0.0.1:9913';
public function testDump()
{
$cloner = new VarCloner();
$data = $cloner->cloneVar('foo');
$connection = new Connection(self::VAR_DUMPER_SERVER, array(
'foo_provider' => new class() implements ContextProviderInterface {
public function getContext(): ?array
{
return array('foo');
}
},
));
$dumped = null;
$process = $this->getServerProcess();
$process->start(function ($type, $buffer) use ($process, &$dumped, $connection, $data) {
if (Process::ERR === $type) {
$process->stop();
$this->fail();
} elseif ("READY\n" === $buffer) {
$connection->write($data);
} else {
$dumped .= $buffer;
}
});
$process->wait();
$this->assertTrue($process->isSuccessful());
$this->assertStringMatchesFormat(<<<'DUMP'
(3) "foo"
[
"timestamp" => %d.%d
"foo_provider" => [
(3) "foo"
]
]
%d
DUMP
, $dumped);
}
public function testNoServer()
{
$cloner = new VarCloner();
$data = $cloner->cloneVar('foo');
$connection = new Connection(self::VAR_DUMPER_SERVER);
$start = microtime(true);
$this->assertFalse($connection->write($data));
$this->assertLessThan(1, microtime(true) - $start);
}
private function getServerProcess(): Process
{
$process = new PhpProcess(file_get_contents(__DIR__.'/../Fixtures/dump_server.php'), null, array(
'COMPONENT_ROOT' => __DIR__.'/../../',
'VAR_DUMPER_SERVER' => self::VAR_DUMPER_SERVER,
));
$process->inheritEnvironmentVariables(true);
return $process->setTimeout(9);
}
}

View File

@@ -38,4 +38,9 @@ EODUMP;
$this->assertDumpEquals($expected, $data);
}
public function testAllowsNonScalarExpectation()
{
$this->assertDumpEquals(new \ArrayObject(array('bim' => 'bam')), new \ArrayObject(array('bim' => 'bam')));
}
}