Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
4
vendor/symfony/http-kernel/Tests/DataCollector/Compiler.log
vendored
Normal file
4
vendor/symfony/http-kernel/Tests/DataCollector/Compiler.log
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
Symfony\Component\DependencyInjection\Compiler\RemovePrivateAliasesPass: Removed service "Psr\Container\ContainerInterface"; reason: private alias.
|
||||
Symfony\Component\DependencyInjection\Compiler\RemovePrivateAliasesPass: Removed service "Symfony\Component\DependencyInjection\ContainerInterface"; reason: private alias.
|
||||
Some custom logging message
|
||||
With ending :
|
66
vendor/symfony/http-kernel/Tests/DataCollector/ConfigDataCollectorTest.php
vendored
Normal file
66
vendor/symfony/http-kernel/Tests/DataCollector/ConfigDataCollectorTest.php
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?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\HttpKernel\Tests\DataCollector;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
class ConfigDataCollectorTest extends TestCase
|
||||
{
|
||||
public function testCollect()
|
||||
{
|
||||
$kernel = new KernelForTest('test', true);
|
||||
$c = new ConfigDataCollector();
|
||||
$c->setKernel($kernel);
|
||||
$c->collect(new Request(), new Response());
|
||||
|
||||
$this->assertSame('test', $c->getEnv());
|
||||
$this->assertTrue($c->isDebug());
|
||||
$this->assertSame('config', $c->getName());
|
||||
$this->assertSame('testkernel', $c->getAppName());
|
||||
$this->assertRegExp('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION);
|
||||
$this->assertRegExp('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION);
|
||||
$this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture());
|
||||
$this->assertSame(class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale());
|
||||
$this->assertSame(date_default_timezone_get(), $c->getPhpTimezone());
|
||||
$this->assertSame(Kernel::VERSION, $c->getSymfonyVersion());
|
||||
$this->assertNull($c->getToken());
|
||||
$this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug());
|
||||
$this->assertSame(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache());
|
||||
$this->assertSame(\extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN), $c->hasApcu());
|
||||
}
|
||||
}
|
||||
|
||||
class KernelForTest extends Kernel
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'testkernel';
|
||||
}
|
||||
|
||||
public function registerBundles()
|
||||
{
|
||||
}
|
||||
|
||||
public function getBundles()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function registerContainerConfiguration(LoaderInterface $loader)
|
||||
{
|
||||
}
|
||||
}
|
38
vendor/symfony/http-kernel/Tests/DataCollector/DataCollectorTest.php
vendored
Normal file
38
vendor/symfony/http-kernel/Tests/DataCollector/DataCollectorTest.php
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?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\HttpKernel\Tests\DataCollector;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Tests\Fixtures\DataCollector\CloneVarDataCollector;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
|
||||
class DataCollectorTest extends TestCase
|
||||
{
|
||||
public function testCloneVarStringWithScheme()
|
||||
{
|
||||
$c = new CloneVarDataCollector('scheme://foo');
|
||||
$c->collect(new Request(), new Response());
|
||||
$cloner = new VarCloner();
|
||||
|
||||
$this->assertEquals($cloner->cloneVar('scheme://foo'), $c->getData());
|
||||
}
|
||||
|
||||
public function testCloneVarExistingFilePath()
|
||||
{
|
||||
$c = new CloneVarDataCollector(array($filePath = tempnam(sys_get_temp_dir(), 'clone_var_data_collector_')));
|
||||
$c->collect(new Request(), new Response());
|
||||
|
||||
$this->assertSame($filePath, $c->getData()[0]);
|
||||
}
|
||||
}
|
138
vendor/symfony/http-kernel/Tests/DataCollector/DumpDataCollectorTest.php
vendored
Normal file
138
vendor/symfony/http-kernel/Tests/DataCollector/DumpDataCollectorTest.php
vendored
Normal file
|
@ -0,0 +1,138 @@
|
|||
<?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\HttpKernel\Tests\DataCollector;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector;
|
||||
use Symfony\Component\VarDumper\Cloner\Data;
|
||||
use Symfony\Component\VarDumper\Dumper\CliDumper;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class DumpDataCollectorTest extends TestCase
|
||||
{
|
||||
public function testDump()
|
||||
{
|
||||
$data = new Data(array(array(123)));
|
||||
|
||||
$collector = new DumpDataCollector();
|
||||
|
||||
$this->assertSame('dump', $collector->getName());
|
||||
|
||||
$collector->dump($data);
|
||||
$line = __LINE__ - 1;
|
||||
$this->assertSame(1, $collector->getDumpsCount());
|
||||
|
||||
$dump = $collector->getDumps('html');
|
||||
$this->assertArrayHasKey('data', $dump[0]);
|
||||
$dump[0]['data'] = preg_replace('/^.*?<pre/', '<pre', $dump[0]['data']);
|
||||
$dump[0]['data'] = preg_replace('/sf-dump-\d+/', 'sf-dump', $dump[0]['data']);
|
||||
|
||||
$xDump = array(
|
||||
array(
|
||||
'data' => "<pre class=sf-dump id=sf-dump data-indent-pad=\" \"><span class=sf-dump-num>123</span>\n</pre><script>Sfdump(\"sf-dump\")</script>\n",
|
||||
'name' => 'DumpDataCollectorTest.php',
|
||||
'file' => __FILE__,
|
||||
'line' => $line,
|
||||
'fileExcerpt' => false,
|
||||
),
|
||||
);
|
||||
$this->assertEquals($xDump, $dump);
|
||||
|
||||
$this->assertStringMatchesFormat('a:3:{i:0;a:5:{s:4:"data";%c:39:"Symfony\Component\VarDumper\Cloner\Data":%a', $collector->serialize());
|
||||
$this->assertSame(0, $collector->getDumpsCount());
|
||||
$this->assertSame('a:2:{i:0;b:0;i:1;s:5:"UTF-8";}', $collector->serialize());
|
||||
}
|
||||
|
||||
public function testCollectDefault()
|
||||
{
|
||||
$data = new Data(array(array(123)));
|
||||
|
||||
$collector = new DumpDataCollector();
|
||||
|
||||
$collector->dump($data);
|
||||
$line = __LINE__ - 1;
|
||||
|
||||
ob_start();
|
||||
$collector->collect(new Request(), new Response());
|
||||
$output = preg_replace("/\033\[[^m]*m/", '', ob_get_clean());
|
||||
|
||||
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n123\n", $output);
|
||||
$this->assertSame(1, $collector->getDumpsCount());
|
||||
$collector->serialize();
|
||||
}
|
||||
|
||||
public function testCollectHtml()
|
||||
{
|
||||
$data = new Data(array(array(123)));
|
||||
|
||||
$collector = new DumpDataCollector(null, 'test://%f:%l');
|
||||
|
||||
$collector->dump($data);
|
||||
$line = __LINE__ - 1;
|
||||
$file = __FILE__;
|
||||
$xOutput = <<<EOTXT
|
||||
<pre class=sf-dump id=sf-dump data-indent-pad=" "><a href="test://{$file}:{$line}" title="{$file}"><span class=sf-dump-meta>DumpDataCollectorTest.php</span></a> on line <span class=sf-dump-meta>{$line}</span>:
|
||||
<span class=sf-dump-num>123</span>
|
||||
</pre>
|
||||
EOTXT;
|
||||
|
||||
ob_start();
|
||||
$response = new Response();
|
||||
$response->headers->set('Content-Type', 'text/html');
|
||||
$collector->collect(new Request(), $response);
|
||||
$output = ob_get_clean();
|
||||
$output = preg_replace('#<(script|style).*?</\1>#s', '', $output);
|
||||
$output = preg_replace('/sf-dump-\d+/', 'sf-dump', $output);
|
||||
|
||||
$this->assertSame($xOutput, trim($output));
|
||||
$this->assertSame(1, $collector->getDumpsCount());
|
||||
$collector->serialize();
|
||||
}
|
||||
|
||||
public function testFlush()
|
||||
{
|
||||
$data = new Data(array(array(456)));
|
||||
$collector = new DumpDataCollector();
|
||||
$collector->dump($data);
|
||||
$line = __LINE__ - 1;
|
||||
|
||||
ob_start();
|
||||
$collector->__destruct();
|
||||
$output = preg_replace("/\033\[[^m]*m/", '', ob_get_clean());
|
||||
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", $output);
|
||||
}
|
||||
|
||||
public function testFlushNothingWhenDataDumperIsProvided()
|
||||
{
|
||||
$data = new Data(array(array(456)));
|
||||
$dumper = new CliDumper('php://output');
|
||||
$collector = new DumpDataCollector(null, null, null, null, $dumper);
|
||||
|
||||
ob_start();
|
||||
$collector->dump($data);
|
||||
$line = __LINE__ - 1;
|
||||
$output = preg_replace("/\033\[[^m]*m/", '', ob_get_clean());
|
||||
if (\PHP_VERSION_ID >= 50400) {
|
||||
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", $output);
|
||||
} else {
|
||||
$this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", $output);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$collector->__destruct();
|
||||
$this->assertEmpty(ob_get_clean());
|
||||
}
|
||||
}
|
59
vendor/symfony/http-kernel/Tests/DataCollector/ExceptionDataCollectorTest.php
vendored
Normal file
59
vendor/symfony/http-kernel/Tests/DataCollector/ExceptionDataCollectorTest.php
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?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\HttpKernel\Tests\DataCollector;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\DataCollector\ExceptionDataCollector;
|
||||
|
||||
class ExceptionDataCollectorTest extends TestCase
|
||||
{
|
||||
public function testCollect()
|
||||
{
|
||||
$e = new \Exception('foo', 500);
|
||||
$c = new ExceptionDataCollector();
|
||||
$flattened = FlattenException::create($e);
|
||||
$trace = $flattened->getTrace();
|
||||
|
||||
$this->assertFalse($c->hasException());
|
||||
|
||||
$c->collect(new Request(), new Response(), $e);
|
||||
|
||||
$this->assertTrue($c->hasException());
|
||||
$this->assertEquals($flattened, $c->getException());
|
||||
$this->assertSame('foo', $c->getMessage());
|
||||
$this->assertSame(500, $c->getCode());
|
||||
$this->assertSame('exception', $c->getName());
|
||||
$this->assertSame($trace, $c->getTrace());
|
||||
}
|
||||
|
||||
public function testCollectWithoutException()
|
||||
{
|
||||
$c = new ExceptionDataCollector();
|
||||
$c->collect(new Request(), new Response());
|
||||
|
||||
$this->assertFalse($c->hasException());
|
||||
}
|
||||
|
||||
public function testReset()
|
||||
{
|
||||
$c = new ExceptionDataCollector();
|
||||
|
||||
$c->collect(new Request(), new Response(), new \Exception());
|
||||
$c->reset();
|
||||
$c->collect(new Request(), new Response());
|
||||
|
||||
$this->assertFalse($c->hasException());
|
||||
}
|
||||
}
|
144
vendor/symfony/http-kernel/Tests/DataCollector/LoggerDataCollectorTest.php
vendored
Normal file
144
vendor/symfony/http-kernel/Tests/DataCollector/LoggerDataCollectorTest.php
vendored
Normal file
|
@ -0,0 +1,144 @@
|
|||
<?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\HttpKernel\Tests\DataCollector;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Debug\Exception\SilencedErrorContext;
|
||||
use Symfony\Component\HttpKernel\DataCollector\LoggerDataCollector;
|
||||
|
||||
class LoggerDataCollectorTest extends TestCase
|
||||
{
|
||||
public function testCollectWithUnexpectedFormat()
|
||||
{
|
||||
$logger = $this
|
||||
->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface')
|
||||
->setMethods(array('countErrors', 'getLogs', 'clear'))
|
||||
->getMock();
|
||||
$logger->expects($this->once())->method('countErrors')->will($this->returnValue('foo'));
|
||||
$logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue(array()));
|
||||
|
||||
$c = new LoggerDataCollector($logger, __DIR__.'/');
|
||||
$c->lateCollect();
|
||||
$compilerLogs = $c->getCompilerLogs()->getValue('message');
|
||||
|
||||
$this->assertSame(array(
|
||||
array('message' => 'Removed service "Psr\Container\ContainerInterface"; reason: private alias.'),
|
||||
array('message' => 'Removed service "Symfony\Component\DependencyInjection\ContainerInterface"; reason: private alias.'),
|
||||
), $compilerLogs['Symfony\Component\DependencyInjection\Compiler\RemovePrivateAliasesPass']);
|
||||
|
||||
$this->assertSame(array(
|
||||
array('message' => 'Some custom logging message'),
|
||||
array('message' => 'With ending :'),
|
||||
), $compilerLogs['Unknown Compiler Pass']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getCollectTestData
|
||||
*/
|
||||
public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount, $expectedPriorities = null)
|
||||
{
|
||||
$logger = $this
|
||||
->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface')
|
||||
->setMethods(array('countErrors', 'getLogs', 'clear'))
|
||||
->getMock();
|
||||
$logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb));
|
||||
$logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs));
|
||||
|
||||
$c = new LoggerDataCollector($logger);
|
||||
$c->lateCollect();
|
||||
|
||||
$this->assertEquals('logger', $c->getName());
|
||||
$this->assertEquals($nb, $c->countErrors());
|
||||
|
||||
$logs = array_map(function ($v) {
|
||||
if (isset($v['context']['exception'])) {
|
||||
$e = &$v['context']['exception'];
|
||||
$e = isset($e["\0*\0message"]) ? array($e["\0*\0message"], $e["\0*\0severity"]) : array($e["\0Symfony\Component\Debug\Exception\SilencedErrorContext\0severity"]);
|
||||
}
|
||||
|
||||
return $v;
|
||||
}, $c->getLogs()->getValue(true));
|
||||
$this->assertEquals($expectedLogs, $logs);
|
||||
$this->assertEquals($expectedDeprecationCount, $c->countDeprecations());
|
||||
$this->assertEquals($expectedScreamCount, $c->countScreams());
|
||||
|
||||
if (isset($expectedPriorities)) {
|
||||
$this->assertSame($expectedPriorities, $c->getPriorities()->getValue(true));
|
||||
}
|
||||
}
|
||||
|
||||
public function testReset()
|
||||
{
|
||||
$logger = $this
|
||||
->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface')
|
||||
->setMethods(array('countErrors', 'getLogs', 'clear'))
|
||||
->getMock();
|
||||
$logger->expects($this->once())->method('clear');
|
||||
|
||||
$c = new LoggerDataCollector($logger);
|
||||
$c->reset();
|
||||
}
|
||||
|
||||
public function getCollectTestData()
|
||||
{
|
||||
yield 'simple log' => array(
|
||||
1,
|
||||
array(array('message' => 'foo', 'context' => array(), 'priority' => 100, 'priorityName' => 'DEBUG')),
|
||||
array(array('message' => 'foo', 'context' => array(), 'priority' => 100, 'priorityName' => 'DEBUG')),
|
||||
0,
|
||||
0,
|
||||
);
|
||||
|
||||
yield 'log with a context' => array(
|
||||
1,
|
||||
array(array('message' => 'foo', 'context' => array('foo' => 'bar'), 'priority' => 100, 'priorityName' => 'DEBUG')),
|
||||
array(array('message' => 'foo', 'context' => array('foo' => 'bar'), 'priority' => 100, 'priorityName' => 'DEBUG')),
|
||||
0,
|
||||
0,
|
||||
);
|
||||
|
||||
if (!class_exists(SilencedErrorContext::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
yield 'logs with some deprecations' => array(
|
||||
1,
|
||||
array(
|
||||
array('message' => 'foo3', 'context' => array('exception' => new \ErrorException('warning', 0, E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG'),
|
||||
array('message' => 'foo', 'context' => array('exception' => new \ErrorException('deprecated', 0, E_DEPRECATED)), 'priority' => 100, 'priorityName' => 'DEBUG'),
|
||||
array('message' => 'foo2', 'context' => array('exception' => new \ErrorException('deprecated', 0, E_USER_DEPRECATED)), 'priority' => 100, 'priorityName' => 'DEBUG'),
|
||||
),
|
||||
array(
|
||||
array('message' => 'foo3', 'context' => array('exception' => array('warning', E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG'),
|
||||
array('message' => 'foo', 'context' => array('exception' => array('deprecated', E_DEPRECATED)), 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => false),
|
||||
array('message' => 'foo2', 'context' => array('exception' => array('deprecated', E_USER_DEPRECATED)), 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => false),
|
||||
),
|
||||
2,
|
||||
0,
|
||||
array(100 => array('count' => 3, 'name' => 'DEBUG')),
|
||||
);
|
||||
|
||||
yield 'logs with some silent errors' => array(
|
||||
1,
|
||||
array(
|
||||
array('message' => 'foo3', 'context' => array('exception' => new \ErrorException('warning', 0, E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG'),
|
||||
array('message' => 'foo3', 'context' => array('exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)), 'priority' => 100, 'priorityName' => 'DEBUG'),
|
||||
),
|
||||
array(
|
||||
array('message' => 'foo3', 'context' => array('exception' => array('warning', E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG'),
|
||||
array('message' => 'foo3', 'context' => array('exception' => array(E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true),
|
||||
),
|
||||
0,
|
||||
1,
|
||||
);
|
||||
}
|
||||
}
|
59
vendor/symfony/http-kernel/Tests/DataCollector/MemoryDataCollectorTest.php
vendored
Normal file
59
vendor/symfony/http-kernel/Tests/DataCollector/MemoryDataCollectorTest.php
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?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\HttpKernel\Tests\DataCollector;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\DataCollector\MemoryDataCollector;
|
||||
|
||||
class MemoryDataCollectorTest extends TestCase
|
||||
{
|
||||
public function testCollect()
|
||||
{
|
||||
$collector = new MemoryDataCollector();
|
||||
$collector->collect(new Request(), new Response());
|
||||
|
||||
$this->assertInternalType('integer', $collector->getMemory());
|
||||
$this->assertInternalType('integer', $collector->getMemoryLimit());
|
||||
$this->assertSame('memory', $collector->getName());
|
||||
}
|
||||
|
||||
/** @dataProvider getBytesConversionTestData */
|
||||
public function testBytesConversion($limit, $bytes)
|
||||
{
|
||||
$collector = new MemoryDataCollector();
|
||||
$method = new \ReflectionMethod($collector, 'convertToBytes');
|
||||
$method->setAccessible(true);
|
||||
$this->assertEquals($bytes, $method->invoke($collector, $limit));
|
||||
}
|
||||
|
||||
public function getBytesConversionTestData()
|
||||
{
|
||||
return array(
|
||||
array('2k', 2048),
|
||||
array('2 k', 2048),
|
||||
array('8m', 8 * 1024 * 1024),
|
||||
array('+2 k', 2048),
|
||||
array('+2???k', 2048),
|
||||
array('0x10', 16),
|
||||
array('0xf', 15),
|
||||
array('010', 8),
|
||||
array('+0x10 k', 16 * 1024),
|
||||
array('1g', 1024 * 1024 * 1024),
|
||||
array('1G', 1024 * 1024 * 1024),
|
||||
array('-1', -1),
|
||||
array('0', 0),
|
||||
array('2mk', 2048), // the unit must be the last char, so in this case 'k', not 'm'
|
||||
);
|
||||
}
|
||||
}
|
334
vendor/symfony/http-kernel/Tests/DataCollector/RequestDataCollectorTest.php
vendored
Normal file
334
vendor/symfony/http-kernel/Tests/DataCollector/RequestDataCollectorTest.php
vendored
Normal file
|
@ -0,0 +1,334 @@
|
|||
<?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\HttpKernel\Tests\DataCollector;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
|
||||
use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector;
|
||||
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernel;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
class RequestDataCollectorTest extends TestCase
|
||||
{
|
||||
public function testCollect()
|
||||
{
|
||||
$c = new RequestDataCollector();
|
||||
|
||||
$c->collect($request = $this->createRequest(), $this->createResponse());
|
||||
$c->lateCollect();
|
||||
|
||||
$attributes = $c->getRequestAttributes();
|
||||
|
||||
$this->assertSame('request', $c->getName());
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestHeaders());
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestServer());
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestCookies());
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $attributes);
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestRequest());
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestQuery());
|
||||
$this->assertInstanceOf(ParameterBag::class, $c->getResponseCookies());
|
||||
$this->assertSame('html', $c->getFormat());
|
||||
$this->assertEquals('foobar', $c->getRoute());
|
||||
$this->assertEquals(array('name' => 'foo'), $c->getRouteParams());
|
||||
$this->assertSame(array(), $c->getSessionAttributes());
|
||||
$this->assertSame('en', $c->getLocale());
|
||||
$this->assertContains(__FILE__, $attributes->get('resource'));
|
||||
$this->assertSame('stdClass', $attributes->get('object')->getType());
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getResponseHeaders());
|
||||
$this->assertSame('OK', $c->getStatusText());
|
||||
$this->assertSame(200, $c->getStatusCode());
|
||||
$this->assertSame('application/json', $c->getContentType());
|
||||
}
|
||||
|
||||
public function testCollectWithoutRouteParams()
|
||||
{
|
||||
$request = $this->createRequest(array());
|
||||
|
||||
$c = new RequestDataCollector();
|
||||
$c->collect($request, $this->createResponse());
|
||||
$c->lateCollect();
|
||||
|
||||
$this->assertEquals(array(), $c->getRouteParams());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideControllerCallables
|
||||
*/
|
||||
public function testControllerInspection($name, $callable, $expected)
|
||||
{
|
||||
$c = new RequestDataCollector();
|
||||
$request = $this->createRequest();
|
||||
$response = $this->createResponse();
|
||||
$this->injectController($c, $callable, $request);
|
||||
$c->collect($request, $response);
|
||||
$c->lateCollect();
|
||||
|
||||
$this->assertSame($expected, $c->getController()->getValue(true), sprintf('Testing: %s', $name));
|
||||
}
|
||||
|
||||
public function provideControllerCallables()
|
||||
{
|
||||
// make sure we always match the line number
|
||||
$r1 = new \ReflectionMethod($this, 'testControllerInspection');
|
||||
$r2 = new \ReflectionMethod($this, 'staticControllerMethod');
|
||||
$r3 = new \ReflectionClass($this);
|
||||
|
||||
// test name, callable, expected
|
||||
return array(
|
||||
array(
|
||||
'"Regular" callable',
|
||||
array($this, 'testControllerInspection'),
|
||||
array(
|
||||
'class' => __NAMESPACE__.'\RequestDataCollectorTest',
|
||||
'method' => 'testControllerInspection',
|
||||
'file' => __FILE__,
|
||||
'line' => $r1->getStartLine(),
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'Closure',
|
||||
function () { return 'foo'; },
|
||||
array(
|
||||
'class' => __NAMESPACE__.'\{closure}',
|
||||
'method' => null,
|
||||
'file' => __FILE__,
|
||||
'line' => __LINE__ - 5,
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'Static callback as string',
|
||||
__NAMESPACE__.'\RequestDataCollectorTest::staticControllerMethod',
|
||||
array(
|
||||
'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest',
|
||||
'method' => 'staticControllerMethod',
|
||||
'file' => __FILE__,
|
||||
'line' => $r2->getStartLine(),
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'Static callable with instance',
|
||||
array($this, 'staticControllerMethod'),
|
||||
array(
|
||||
'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest',
|
||||
'method' => 'staticControllerMethod',
|
||||
'file' => __FILE__,
|
||||
'line' => $r2->getStartLine(),
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'Static callable with class name',
|
||||
array('Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'staticControllerMethod'),
|
||||
array(
|
||||
'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest',
|
||||
'method' => 'staticControllerMethod',
|
||||
'file' => __FILE__,
|
||||
'line' => $r2->getStartLine(),
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'Callable with instance depending on __call()',
|
||||
array($this, 'magicMethod'),
|
||||
array(
|
||||
'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest',
|
||||
'method' => 'magicMethod',
|
||||
'file' => 'n/a',
|
||||
'line' => 'n/a',
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'Callable with class name depending on __callStatic()',
|
||||
array('Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'magicMethod'),
|
||||
array(
|
||||
'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest',
|
||||
'method' => 'magicMethod',
|
||||
'file' => 'n/a',
|
||||
'line' => 'n/a',
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
'Invokable controller',
|
||||
$this,
|
||||
array(
|
||||
'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest',
|
||||
'method' => null,
|
||||
'file' => __FILE__,
|
||||
'line' => $r3->getStartLine(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function testItIgnoresInvalidCallables()
|
||||
{
|
||||
$request = $this->createRequestWithSession();
|
||||
$response = new RedirectResponse('/');
|
||||
|
||||
$c = new RequestDataCollector();
|
||||
$c->collect($request, $response);
|
||||
|
||||
$this->assertSame('n/a', $c->getController());
|
||||
}
|
||||
|
||||
public function testItAddsRedirectedAttributesWhenRequestContainsSpecificCookie()
|
||||
{
|
||||
$request = $this->createRequest();
|
||||
$request->cookies->add(array(
|
||||
'sf_redirect' => '{}',
|
||||
));
|
||||
|
||||
$kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
|
||||
|
||||
$c = new RequestDataCollector();
|
||||
$c->onKernelResponse(new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $this->createResponse()));
|
||||
|
||||
$this->assertTrue($request->attributes->get('_redirected'));
|
||||
}
|
||||
|
||||
public function testItSetsARedirectCookieIfTheResponseIsARedirection()
|
||||
{
|
||||
$c = new RequestDataCollector();
|
||||
|
||||
$response = $this->createResponse();
|
||||
$response->setStatusCode(302);
|
||||
$response->headers->set('Location', '/somewhere-else');
|
||||
|
||||
$c->collect($request = $this->createRequest(), $response);
|
||||
$c->lateCollect();
|
||||
|
||||
$cookie = $this->getCookieByName($response, 'sf_redirect');
|
||||
|
||||
$this->assertNotEmpty($cookie->getValue());
|
||||
}
|
||||
|
||||
public function testItCollectsTheRedirectionAndClearTheCookie()
|
||||
{
|
||||
$c = new RequestDataCollector();
|
||||
|
||||
$request = $this->createRequest();
|
||||
$request->attributes->set('_redirected', true);
|
||||
$request->cookies->add(array(
|
||||
'sf_redirect' => '{"method": "POST"}',
|
||||
));
|
||||
|
||||
$c->collect($request, $response = $this->createResponse());
|
||||
$c->lateCollect();
|
||||
|
||||
$this->assertEquals('POST', $c->getRedirect()['method']);
|
||||
|
||||
$cookie = $this->getCookieByName($response, 'sf_redirect');
|
||||
$this->assertNull($cookie->getValue());
|
||||
}
|
||||
|
||||
protected function createRequest($routeParams = array('name' => 'foo'))
|
||||
{
|
||||
$request = Request::create('http://test.com/foo?bar=baz');
|
||||
$request->attributes->set('foo', 'bar');
|
||||
$request->attributes->set('_route', 'foobar');
|
||||
$request->attributes->set('_route_params', $routeParams);
|
||||
$request->attributes->set('resource', fopen(__FILE__, 'r'));
|
||||
$request->attributes->set('object', new \stdClass());
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
private function createRequestWithSession()
|
||||
{
|
||||
$request = $this->createRequest();
|
||||
$request->attributes->set('_controller', 'Foo::bar');
|
||||
$request->setSession(new Session(new MockArraySessionStorage()));
|
||||
$request->getSession()->start();
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
protected function createResponse()
|
||||
{
|
||||
$response = new Response();
|
||||
$response->setStatusCode(200);
|
||||
$response->headers->set('Content-Type', 'application/json');
|
||||
$response->headers->set('X-Foo-Bar', null);
|
||||
$response->headers->setCookie(new Cookie('foo', 'bar', 1, '/foo', 'localhost', true, true));
|
||||
$response->headers->setCookie(new Cookie('bar', 'foo', new \DateTime('@946684800')));
|
||||
$response->headers->setCookie(new Cookie('bazz', 'foo', '2000-12-12'));
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject the given controller callable into the data collector.
|
||||
*/
|
||||
protected function injectController($collector, $controller, $request)
|
||||
{
|
||||
$resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock();
|
||||
$httpKernel = new HttpKernel(new EventDispatcher(), $resolver, null, $this->getMockBuilder(ArgumentResolverInterface::class)->getMock());
|
||||
$event = new FilterControllerEvent($httpKernel, $controller, $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
$collector->onKernelController($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy method used as controller callable.
|
||||
*/
|
||||
public static function staticControllerMethod()
|
||||
{
|
||||
throw new \LogicException('Unexpected method call');
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to allow non existing methods to be called and delegated.
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
throw new \LogicException('Unexpected method call');
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method to allow non existing methods to be called and delegated.
|
||||
*/
|
||||
public static function __callStatic($method, $args)
|
||||
{
|
||||
throw new \LogicException('Unexpected method call');
|
||||
}
|
||||
|
||||
public function __invoke()
|
||||
{
|
||||
throw new \LogicException('Unexpected method call');
|
||||
}
|
||||
|
||||
private function getCookieByName(Response $response, $name)
|
||||
{
|
||||
foreach ($response->headers->getCookies() as $cookie) {
|
||||
if ($cookie->getName() == $name) {
|
||||
return $cookie;
|
||||
}
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('Cookie named "%s" is not in response', $name));
|
||||
}
|
||||
}
|
55
vendor/symfony/http-kernel/Tests/DataCollector/TimeDataCollectorTest.php
vendored
Normal file
55
vendor/symfony/http-kernel/Tests/DataCollector/TimeDataCollectorTest.php
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?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\HttpKernel\Tests\DataCollector;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\DataCollector\TimeDataCollector;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class TimeDataCollectorTest extends TestCase
|
||||
{
|
||||
public function testCollect()
|
||||
{
|
||||
$c = new TimeDataCollector();
|
||||
|
||||
$request = new Request();
|
||||
$request->server->set('REQUEST_TIME', 1);
|
||||
|
||||
$c->collect($request, new Response());
|
||||
|
||||
$this->assertEquals(0, $c->getStartTime());
|
||||
|
||||
$request->server->set('REQUEST_TIME_FLOAT', 2);
|
||||
|
||||
$c->collect($request, new Response());
|
||||
|
||||
$this->assertEquals(2000, $c->getStartTime());
|
||||
|
||||
$request = new Request();
|
||||
$c->collect($request, new Response());
|
||||
$this->assertEquals(0, $c->getStartTime());
|
||||
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
|
||||
$kernel->expects($this->once())->method('getStartTime')->will($this->returnValue(123456));
|
||||
|
||||
$c = new TimeDataCollector($kernel);
|
||||
$request = new Request();
|
||||
$request->server->set('REQUEST_TIME', 1);
|
||||
|
||||
$c->collect($request, new Response());
|
||||
$this->assertEquals(123456000, $c->getStartTime());
|
||||
}
|
||||
}
|
51
vendor/symfony/http-kernel/Tests/DataCollector/Util/ValueExporterTest.php
vendored
Normal file
51
vendor/symfony/http-kernel/Tests/DataCollector/Util/ValueExporterTest.php
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?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\HttpKernel\Tests\DataCollector\Util;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class ValueExporterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ValueExporter
|
||||
*/
|
||||
private $valueExporter;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->valueExporter = new ValueExporter();
|
||||
}
|
||||
|
||||
public function testDateTime()
|
||||
{
|
||||
$dateTime = new \DateTime('2014-06-10 07:35:40', new \DateTimeZone('UTC'));
|
||||
$this->assertSame('Object(DateTime) - 2014-06-10T07:35:40+00:00', $this->valueExporter->exportValue($dateTime));
|
||||
}
|
||||
|
||||
public function testDateTimeImmutable()
|
||||
{
|
||||
$dateTime = new \DateTimeImmutable('2014-06-10 07:35:40', new \DateTimeZone('UTC'));
|
||||
$this->assertSame('Object(DateTimeImmutable) - 2014-06-10T07:35:40+00:00', $this->valueExporter->exportValue($dateTime));
|
||||
}
|
||||
|
||||
public function testIncompleteClass()
|
||||
{
|
||||
$foo = new \__PHP_Incomplete_Class();
|
||||
$array = new \ArrayObject($foo);
|
||||
$array['__PHP_Incomplete_Class_Name'] = 'AppBundle/Foo';
|
||||
$this->assertSame('__PHP_Incomplete_Class(AppBundle/Foo)', $this->valueExporter->exportValue($foo));
|
||||
}
|
||||
}
|
Reference in a new issue