composer update

This commit is contained in:
Manish Verma
2018-12-05 10:50:52 +05:30
parent 9eabcacfa7
commit 4addd1e9c6
3328 changed files with 156676 additions and 138988 deletions

View File

@@ -20,7 +20,7 @@ class ChainCacheClearerTest extends TestCase
public static function setUpBeforeClass()
{
self::$cacheDir = tempnam(sys_get_temp_dir(), 'sf2_cache_clearer_dir');
self::$cacheDir = tempnam(sys_get_temp_dir(), 'sf_cache_clearer_dir');
}
public static function tearDownAfterClass()

View File

@@ -20,7 +20,7 @@ class CacheWarmerAggregateTest extends TestCase
public static function setUpBeforeClass()
{
self::$cacheDir = tempnam(sys_get_temp_dir(), 'sf2_cache_warmer_dir');
self::$cacheDir = tempnam(sys_get_temp_dir(), 'sf_cache_warmer_dir');
}
public static function tearDownAfterClass()

View File

@@ -20,7 +20,7 @@ class CacheWarmerTest extends TestCase
public static function setUpBeforeClass()
{
self::$cacheFile = tempnam(sys_get_temp_dir(), 'sf2_cache_warmer_dir');
self::$cacheFile = tempnam(sys_get_temp_dir(), 'sf_cache_warmer_dir');
}
public static function tearDownAfterClass()

View File

@@ -61,13 +61,13 @@ class ClientTest extends TestCase
$m->setAccessible(true);
$response = new Response();
$response->headers->setCookie($cookie1 = new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true));
$response->headers->setCookie($cookie1 = new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true, false, null));
$domResponse = $m->invoke($client, $response);
$this->assertSame((string) $cookie1, $domResponse->getHeader('Set-Cookie'));
$response = new Response();
$response->headers->setCookie($cookie1 = new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true));
$response->headers->setCookie($cookie2 = new Cookie('foo1', 'bar1', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true));
$response->headers->setCookie($cookie1 = new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true, false, null));
$response->headers->setCookie($cookie2 = new Cookie('foo1', 'bar1', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true, false, null));
$domResponse = $m->invoke($client, $response);
$this->assertSame((string) $cookie1, $domResponse->getHeader('Set-Cookie'));
$this->assertSame(array((string) $cookie1, (string) $cookie2), $domResponse->getHeader('Set-Cookie', false));

View File

@@ -68,6 +68,24 @@ class ServiceValueResolverTest extends TestCase
$this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument));
}
public function testExistingControllerWithMethodNameStartUppercase()
{
$resolver = new ServiceValueResolver(new ServiceLocator(array(
'App\\Controller\\Mine::method' => function () {
return new ServiceLocator(array(
'dummy' => function () {
return new DummyService();
},
));
},
)));
$request = $this->requestWithAttributes(array('_controller' => 'App\\Controller\\Mine::Method'));
$argument = new ArgumentMetadata('dummy', DummyService::class, false, false, null);
$this->assertTrue($resolver->supports($request, $argument));
$this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument));
}
public function testControllerNameIsAnArray()
{
$resolver = new ServiceValueResolver(new ServiceLocator(array(

View File

@@ -19,10 +19,6 @@ use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver;
class ContainerControllerResolverTest extends ControllerResolverTest
{
/**
* @group legacy
* @expectedDeprecation Referencing controllers with a single colon is deprecated since Symfony 4.1. Use foo::action instead.
*/
public function testGetControllerServiceWithSingleColon()
{
$service = new ControllerTestService('foo');

View File

@@ -30,7 +30,6 @@ class ConfigDataCollectorTest extends TestCase
$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());
@@ -39,18 +38,29 @@ class ConfigDataCollectorTest extends TestCase
$this->assertSame(Kernel::VERSION, $c->getSymfonyVersion());
$this->assertNull($c->getToken());
$this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug());
$this->assertSame(\extension_loaded('Zend OPcache') && ini_get('opcache.enable'), $c->hasZendOpcache());
$this->assertSame(\extension_loaded('apcu') && ini_get('apc.enabled'), $c->hasApcu());
$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());
}
/**
* @group legacy
* @expectedDeprecation The "$name" argument in method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::__construct()" is deprecated since Symfony 4.2.
* @expectedDeprecation The "$version" argument in method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::__construct()" is deprecated since Symfony 4.2.
* @expectedDeprecation The method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::getApplicationName()" is deprecated since Symfony 4.2.
* @expectedDeprecation The method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::getApplicationVersion()" is deprecated since Symfony 4.2.
*/
public function testLegacy()
{
$c = new ConfigDataCollector('name', null);
$c->collect(new Request(), new Response());
$this->assertSame('name', $c->getApplicationName());
$this->assertNull($c->getApplicationVersion());
}
}
class KernelForTest extends Kernel
{
public function getName()
{
return 'testkernel';
}
public function registerBundles()
{
}

View File

@@ -225,6 +225,8 @@ class RequestDataCollectorTest extends TestCase
$cookie = $this->getCookieByName($response, 'sf_redirect');
$this->assertNotEmpty($cookie->getValue());
$this->assertSame('lax', $cookie->getSameSite());
$this->assertFalse($cookie->isSecure());
}
public function testItCollectsTheRedirectionAndClearTheCookie()
@@ -274,9 +276,9 @@ class RequestDataCollectorTest extends TestCase
$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'));
$response->headers->setCookie(new Cookie('foo', 'bar', 1, '/foo', 'localhost', true, true, false, null));
$response->headers->setCookie(new Cookie('bar', 'foo', new \DateTime('@946684800'), '/', null, false, true, false, null));
$response->headers->setCookie(new Cookie('bazz', 'foo', '2000-12-12', '/', null, false, true, false, null));
return $response;
}

View File

@@ -37,7 +37,6 @@ class FileLinkFormatterTest extends TestCase
public function testWhenFileLinkFormatAndRequest()
{
$file = __DIR__.\DIRECTORY_SEPARATOR.'file.php';
$baseDir = __DIR__;
$requestStack = new RequestStack();
$request = new Request();
$requestStack->push($request);
@@ -56,12 +55,12 @@ class FileLinkFormatterTest extends TestCase
$request->server->set('SERVER_NAME', 'www.example.org');
$request->server->set('SERVER_PORT', 80);
$request->server->set('SCRIPT_NAME', '/app.php');
$request->server->set('SCRIPT_FILENAME', '/web/app.php');
$request->server->set('REQUEST_URI', '/app.php/example');
$request->server->set('SCRIPT_NAME', '/index.php');
$request->server->set('SCRIPT_FILENAME', '/public/index.php');
$request->server->set('REQUEST_URI', '/index.php/example');
$sut = new FileLinkFormatter(null, $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l');
$this->assertSame('http://www.example.org/app.php/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3));
$this->assertSame('http://www.example.org/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3));
}
}

View File

@@ -149,7 +149,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
$this->assertSame(ServiceLocator::class, $locator->getClass());
$this->assertFalse($locator->isPublic());
$expected = array('bar' => new ServiceClosureArgument(new TypedReference(ControllerDummy::class, ControllerDummy::class, ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE)));
$expected = array('bar' => new ServiceClosureArgument(new TypedReference(ControllerDummy::class, ControllerDummy::class, ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE, 'bar')));
$this->assertEquals($expected, $locator->getArgument(0));
}
@@ -309,16 +309,23 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
public function provideBindings()
{
return array(array(ControllerDummy::class), array('$bar'));
return array(
array(ControllerDummy::class.'$bar'),
array(ControllerDummy::class),
array('$bar'),
);
}
public function testBindScalarValueToControllerArgument()
/**
* @dataProvider provideBindScalarValueToControllerArgument
*/
public function testBindScalarValueToControllerArgument($bindingKey)
{
$container = new ContainerBuilder();
$resolver = $container->register('argument_resolver.service')->addArgument(array());
$container->register('foo', ArgumentWithoutTypeController::class)
->setBindings(array('$someArg' => '%foo%'))
->setBindings(array($bindingKey => '%foo%'))
->addTag('controller.service_arguments');
$container->setParameter('foo', 'foo_val');
@@ -341,6 +348,12 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
$this->assertSame('foo_val', $container->get((string) $reference));
}
public function provideBindScalarValueToControllerArgument()
{
yield array('$someArg');
yield array('string $someArg');
}
public function testBindingsOnChildDefinitions()
{
$container = new ContainerBuilder();
@@ -420,7 +433,7 @@ class NonExistentClassOptionalController
class ArgumentWithoutTypeController
{
public function fooAction($someArg)
public function fooAction(string $someArg)
{
}
}

View File

@@ -155,6 +155,25 @@ class ExceptionListenerTest extends TestCase
$this->assertFalse($response->headers->has('content-security-policy'), 'CSP header has been removed');
$this->assertFalse($dispatcher->hasListeners(KernelEvents::RESPONSE), 'CSP removal listener has been removed');
}
public function testNullController()
{
$listener = new ExceptionListener(null);
$kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
$kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) {
$controller = $request->attributes->get('_controller');
return $controller();
}));
$request = Request::create('/');
$event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo'));
$listener->onKernelException($event);
$this->assertNull($event->getResponse());
$listener->onKernelException($event);
$this->assertContains('Whoops, looks like something went wrong.', $event->getResponse()->getContent());
}
}
class TestLogger extends Logger implements DebugLoggerInterface

View File

@@ -106,17 +106,24 @@ class SessionListenerTest extends TestCase
$this->assertFalse($response->headers->has(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER));
}
public function testUninitilizedSession()
public function testUninitializedSession()
{
$event = $this->getMockBuilder(FilterResponseEvent::class)->disableOriginalConstructor()->getMock();
$event->expects($this->once())->method('isMasterRequest')->willReturn(true);
$kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock();
$response = new Response();
$response->setSharedMaxAge(60);
$response->headers->set(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER, 'true');
$container = new ServiceLocator(array(
'initialized_session' => function () {},
));
$listener = new SessionListener($container);
$listener->onKernelResponse($event);
$listener->onKernelResponse(new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response));
$this->assertTrue($response->headers->hasCacheControlDirective('public'));
$this->assertFalse($response->headers->hasCacheControlDirective('private'));
$this->assertFalse($response->headers->hasCacheControlDirective('must-revalidate'));
$this->assertSame('60', $response->headers->getCacheControlDirective('s-maxage'));
$this->assertFalse($response->headers->has(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER));
}
public function testSurrogateMasterRequestIsPublic()

View File

@@ -12,7 +12,6 @@
namespace Symfony\Component\HttpKernel\Tests\EventListener;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
@@ -144,15 +143,6 @@ class TestSessionListenerTest extends TestCase
$this->filterResponse(new Request());
}
public function testDoesNotImplementServiceSubscriberInterface()
{
$this->assertTrue(interface_exists(ServiceSubscriberInterface::class));
$this->assertTrue(class_exists(SessionListener::class));
$this->assertTrue(class_exists(TestSessionListener::class));
$this->assertFalse(is_subclass_of(SessionListener::class, ServiceSubscriberInterface::class), 'Implementing ServiceSubscriberInterface would create a dep on the DI component, which eg Silex cannot afford');
$this->assertFalse(is_subclass_of(TestSessionListener::class, ServiceSubscriberInterface::class, 'Implementing ServiceSubscriberInterface would create a dep on the DI component, which eg Silex cannot afford'));
}
public function testDoesNotThrowIfRequestDoesNotHaveASession()
{
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();

View File

@@ -17,6 +17,7 @@ use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\EventListener\TranslatorListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class TranslatorListenerTest extends TestCase
{
@@ -26,7 +27,7 @@ class TranslatorListenerTest extends TestCase
protected function setUp()
{
$this->translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock();
$this->translator = $this->getMockBuilder(TranslatorInterface::class)->getMock();
$this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock();
$this->listener = new TranslatorListener($this->translator, $this->requestStack);
}

View File

@@ -1,37 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\Tests\Fixtures\_123;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel;
class Kernel123 extends Kernel
{
public function registerBundles()
{
return array();
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
}
public function getCacheDir()
{
return sys_get_temp_dir().'/'.Kernel::VERSION.'/kernel123/cache/'.$this->environment;
}
public function getLogDir()
{
return sys_get_temp_dir().'/'.Kernel::VERSION.'/kernel123/logs';
}
}

View File

@@ -34,4 +34,14 @@ class KernelForTest extends Kernel
{
return $this->booted;
}
public function getCacheDir()
{
return $this->getProjectDir().'/Tests/Fixtures/cache.'.$this->environment;
}
public function getLogDir()
{
return $this->getProjectDir().'/Tests/Fixtures/logs';
}
}

View File

@@ -26,6 +26,11 @@ class KernelWithoutBundles extends Kernel
{
}
public function getProjectDir()
{
return __DIR__;
}
protected function build(ContainerBuilder $container)
{
$container->setParameter('test_executed', true);

View File

@@ -88,7 +88,7 @@ class FragmentHandlerTest extends TestCase
;
if ($arguments) {
\call_user_func_array(array($e, 'with'), $arguments);
$e->with(...$arguments);
}
$handler = new FragmentHandler($this->requestStack);

View File

@@ -145,6 +145,26 @@ class InlineFragmentRendererTest extends TestCase
$this->assertEquals('Foo', ob_get_clean());
}
public function testLocaleAndFormatAreIsKeptInSubrequest()
{
$expectedSubRequest = Request::create('/');
$expectedSubRequest->attributes->set('_format', 'foo');
$expectedSubRequest->setLocale('fr');
if (Request::HEADER_X_FORWARDED_FOR & Request::getTrustedHeaderSet()) {
$expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
$expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
}
$expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http'));
$expectedSubRequest->server->set('HTTP_FORWARDED', 'for="127.0.0.1";host="localhost";proto=http');
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest));
$request = Request::create('/');
$request->attributes->set('_format', 'foo');
$request->setLocale('fr');
$strategy->render('/', $request);
}
public function testESIHeaderIsKeptInSubrequest()
{
$expectedSubRequest = Request::create('/');

View File

@@ -234,7 +234,7 @@ class EsiTest extends TestCase
if (\is_array($response)) {
$cache->expects($this->any())
->method('handle')
->will(\call_user_func_array(array($this, 'onConsecutiveCalls'), $response))
->will($this->onConsecutiveCalls(...$response))
;
} else {
$cache->expects($this->any())

View File

@@ -201,7 +201,7 @@ class SsiTest extends TestCase
if (\is_array($response)) {
$cache->expects($this->any())
->method('handle')
->will(\call_user_func_array(array($this, 'onConsecutiveCalls'), $response))
->will($this->onConsecutiveCalls(...$response))
;
} else {
$cache->expects($this->any())

View File

@@ -23,6 +23,7 @@ use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\HttpKernel\Event\FilterControllerArgumentsEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\ControllerDoesNotReturnResponseException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -211,15 +212,23 @@ class HttpKernelTest extends TestCase
$this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request()));
}
/**
* @expectedException \LogicException
*/
public function testHandleWhenTheControllerDoesNotReturnAResponse()
{
$dispatcher = new EventDispatcher();
$kernel = $this->getHttpKernel($dispatcher, function () { return 'foo'; });
$kernel->handle(new Request());
try {
$kernel->handle(new Request());
$this->fail('The kernel should throw an exception.');
} catch (ControllerDoesNotReturnResponseException $e) {
}
$first = $e->getTrace()[0];
// `file` index the array starting at 0, and __FILE__ starts at 1
$line = file($first['file'])[$first['line'] - 2];
$this->assertContains('// call controller', $line);
}
public function testHandleWhenTheControllerDoesNotReturnAResponseButAViewIsRegistered()
@@ -265,7 +274,7 @@ class HttpKernelTest extends TestCase
$oldArguments = $event->getArguments();
$newController = function ($id) use ($oldController, $oldArguments) {
$response = \call_user_func_array($oldController, $oldArguments);
$response = $oldController(...$oldArguments);
$response->headers->set('X-Id', $id);

View File

@@ -33,7 +33,7 @@ class KernelTest extends TestCase
public static function tearDownAfterClass()
{
$fs = new Filesystem();
$fs->remove(__DIR__.'/Fixtures/cache');
$fs->remove(__DIR__.'/Fixtures/var');
}
public function testConstructor()
@@ -67,15 +67,15 @@ class KernelTest extends TestCase
public function testInitializeContainerClearsOldContainers()
{
$fs = new Filesystem();
$legacyContainerDir = __DIR__.'/Fixtures/cache/custom/ContainerA123456';
$legacyContainerDir = __DIR__.'/Fixtures/var/cache/custom/ContainerA123456';
$fs->mkdir($legacyContainerDir);
touch($legacyContainerDir.'.legacy');
$kernel = new CustomProjectDirKernel();
$kernel->boot();
$containerDir = __DIR__.'/Fixtures/cache/custom/'.substr(\get_class($kernel->getContainer()), 0, 16);
$this->assertTrue(unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta'));
$containerDir = __DIR__.'/Fixtures/var/cache/custom/'.substr(\get_class($kernel->getContainer()), 0, 16);
$this->assertTrue(unlink(__DIR__.'/Fixtures/var/cache/custom/TestsSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta'));
$this->assertFileExists($containerDir);
$this->assertFileNotExists($containerDir.'.legacy');
@@ -295,6 +295,9 @@ EOF;
$this->assertEquals($expected, $output);
}
/**
* @group legacy
*/
public function testGetRootDir()
{
$kernel = new KernelForTest('test', true);
@@ -302,6 +305,9 @@ EOF;
$this->assertEquals(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures', realpath($kernel->getRootDir()));
}
/**
* @group legacy
*/
public function testGetName()
{
$kernel = new KernelForTest('test', true);
@@ -309,6 +315,9 @@ EOF;
$this->assertEquals('Fixtures', $kernel->getName());
}
/**
* @group legacy
*/
public function testOverrideGetName()
{
$kernel = new KernelForOverrideName('test', true);
@@ -506,40 +515,32 @@ EOF;
$this->assertTrue($kernel->getContainer()->getParameter('test_executed'));
}
public function testKernelRootDirNameStartingWithANumber()
{
$dir = __DIR__.'/Fixtures/123';
require_once $dir.'/Kernel123.php';
$kernel = new \Symfony\Component\HttpKernel\Tests\Fixtures\_123\Kernel123('dev', true);
$this->assertEquals('_123', $kernel->getName());
}
public function testProjectDirExtension()
{
$kernel = new CustomProjectDirKernel();
$kernel->boot();
$this->assertSame('foo', $kernel->getProjectDir());
$this->assertSame('foo', $kernel->getContainer()->getParameter('kernel.project_dir'));
$this->assertSame(__DIR__.'/Fixtures', $kernel->getProjectDir());
$this->assertSame(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures', $kernel->getContainer()->getParameter('kernel.project_dir'));
}
public function testKernelReset()
{
(new Filesystem())->remove(__DIR__.'/Fixtures/cache');
(new Filesystem())->remove(__DIR__.'/Fixtures/var/cache');
$kernel = new CustomProjectDirKernel();
$kernel->boot();
$containerClass = \get_class($kernel->getContainer());
$containerFile = (new \ReflectionClass($kernel->getContainer()))->getFileName();
unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta');
unlink(__DIR__.'/Fixtures/var/cache/custom/TestsSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
$kernel = new CustomProjectDirKernel();
$kernel->boot();
$this->assertInstanceOf($containerClass, $kernel->getContainer());
$this->assertFileExists($containerFile);
unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta');
unlink(__DIR__.'/Fixtures/var/cache/custom/TestsSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
$kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass')->setPublic(true); });
$kernel->boot();
@@ -707,11 +708,10 @@ class CustomProjectDirKernel extends Kernel
private $buildContainer;
private $httpKernel;
public function __construct(\Closure $buildContainer = null, HttpKernelInterface $httpKernel = null, $name = 'custom')
public function __construct(\Closure $buildContainer = null, HttpKernelInterface $httpKernel = null, $env = 'custom')
{
parent::__construct($name, true);
parent::__construct($env, true);
$this->baseDir = 'foo';
$this->buildContainer = $buildContainer;
$this->httpKernel = $httpKernel;
}
@@ -726,11 +726,6 @@ class CustomProjectDirKernel extends Kernel
}
public function getProjectDir()
{
return $this->baseDir;
}
public function getRootDir()
{
return __DIR__.'/Fixtures';
}

View File

@@ -22,7 +22,7 @@ class FileProfilerStorageTest extends TestCase
protected function setUp()
{
$this->tmpDir = sys_get_temp_dir().'/sf2_profiler_file_storage';
$this->tmpDir = sys_get_temp_dir().'/sf_profiler_file_storage';
if (is_dir($this->tmpDir)) {
self::cleanDir();
}

View File

@@ -84,7 +84,7 @@ class ProfilerTest extends TestCase
protected function setUp()
{
$this->tmp = tempnam(sys_get_temp_dir(), 'sf2_profiler');
$this->tmp = tempnam(sys_get_temp_dir(), 'sf_profiler');
if (file_exists($this->tmp)) {
@unlink($this->tmp);
}