Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
88
vendor/symfony/var-dumper/Tests/Server/ConnectionTest.php
vendored
Normal file
88
vendor/symfony/var-dumper/Tests/Server/ConnectionTest.php
vendored
Normal 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);
|
||||
}
|
||||
}
|
Reference in a new issue