mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
N°2651 rollback gitignore for lib tests dirs
Too dangerous ! We'll work properly on this but for 2.8
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
abstract class AbstractWebTestCase extends BaseWebTestCase
|
||||
{
|
||||
public static function assertRedirect($response, $location)
|
||||
{
|
||||
self::assertTrue($response->isRedirect(), 'Response is not a redirect, got status code: '.$response->getStatusCode());
|
||||
self::assertEquals('http://localhost'.$location, $response->headers->get('Location'));
|
||||
}
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
static::deleteTmpDir();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
static::deleteTmpDir();
|
||||
}
|
||||
|
||||
protected static function deleteTmpDir()
|
||||
{
|
||||
if (!file_exists($dir = sys_get_temp_dir().'/'.static::getVarDir())) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fs = new Filesystem();
|
||||
$fs->remove($dir);
|
||||
}
|
||||
|
||||
protected static function getKernelClass()
|
||||
{
|
||||
require_once __DIR__.'/app/AppKernel.php';
|
||||
|
||||
return 'Symfony\Bundle\FrameworkBundle\Tests\Functional\app\AppKernel';
|
||||
}
|
||||
|
||||
protected static function createKernel(array $options = [])
|
||||
{
|
||||
$class = self::getKernelClass();
|
||||
|
||||
if (!isset($options['test_case'])) {
|
||||
throw new \InvalidArgumentException('The option "test_case" must be set.');
|
||||
}
|
||||
|
||||
return new $class(
|
||||
static::getVarDir(),
|
||||
$options['test_case'],
|
||||
isset($options['root_config']) ? $options['root_config'] : 'config.yml',
|
||||
isset($options['environment']) ? $options['environment'] : strtolower(static::getVarDir().$options['test_case']),
|
||||
isset($options['debug']) ? $options['debug'] : false
|
||||
);
|
||||
}
|
||||
|
||||
protected static function getVarDir()
|
||||
{
|
||||
return 'FB'.substr(strrchr(\get_called_class(), '\\'), 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
class AnnotatedControllerTest extends AbstractWebTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getRoutes
|
||||
*/
|
||||
public function testAnnotatedController($path, $expectedValue)
|
||||
{
|
||||
$client = $this->createClient(['test_case' => 'AnnotatedController', 'root_config' => 'config.yml']);
|
||||
$client->request('GET', '/annotated'.$path);
|
||||
|
||||
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
||||
$this->assertSame($expectedValue, $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
public function getRoutes()
|
||||
{
|
||||
return [
|
||||
['/null_request', 'Symfony\Component\HttpFoundation\Request'],
|
||||
['/null_argument', ''],
|
||||
['/null_argument_with_route_param', ''],
|
||||
['/null_argument_with_route_param/value', 'value'],
|
||||
['/argument_with_route_param_and_default', 'value'],
|
||||
['/argument_with_route_param_and_default/custom', 'custom'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\CachedReader;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
|
||||
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
|
||||
|
||||
class AutowiringTypesTest extends AbstractWebTestCase
|
||||
{
|
||||
public function testAnnotationReaderAutowiring()
|
||||
{
|
||||
static::bootKernel(['root_config' => 'no_annotations_cache.yml', 'environment' => 'no_annotations_cache']);
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$annotationReader = $container->get('test.autowiring_types.autowired_services')->getAnnotationReader();
|
||||
$this->assertInstanceOf(AnnotationReader::class, $annotationReader);
|
||||
}
|
||||
|
||||
public function testCachedAnnotationReaderAutowiring()
|
||||
{
|
||||
static::bootKernel();
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$annotationReader = $container->get('test.autowiring_types.autowired_services')->getAnnotationReader();
|
||||
$this->assertInstanceOf(CachedReader::class, $annotationReader);
|
||||
}
|
||||
|
||||
public function testTemplatingAutowiring()
|
||||
{
|
||||
static::bootKernel();
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
|
||||
$this->assertInstanceOf(FrameworkBundleEngineInterface::class, $autowiredServices->getFrameworkBundleEngine());
|
||||
$this->assertInstanceOf(ComponentEngineInterface::class, $autowiredServices->getEngine());
|
||||
}
|
||||
|
||||
public function testEventDispatcherAutowiring()
|
||||
{
|
||||
static::bootKernel(['debug' => false]);
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
|
||||
|
||||
if (class_exists(ContainerAwareEventDispatcher::class)) {
|
||||
$this->assertInstanceOf(ContainerAwareEventDispatcher::class, $autowiredServices->getDispatcher(), 'The event_dispatcher service should be injected if the debug is not enabled');
|
||||
} else {
|
||||
$this->assertInstanceOf(EventDispatcher::class, $autowiredServices->getDispatcher(), 'The event_dispatcher service should be injected if the debug is not enabled');
|
||||
}
|
||||
|
||||
static::bootKernel(['debug' => true]);
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
|
||||
$this->assertInstanceOf(TraceableEventDispatcher::class, $autowiredServices->getDispatcher(), 'The debug.event_dispatcher service should be injected if the debug is enabled');
|
||||
}
|
||||
|
||||
public function testCacheAutowiring()
|
||||
{
|
||||
static::bootKernel();
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
|
||||
$this->assertInstanceOf(FilesystemAdapter::class, $autowiredServices->getCachePool());
|
||||
}
|
||||
|
||||
protected static function createKernel(array $options = [])
|
||||
{
|
||||
return parent::createKernel(['test_case' => 'AutowiringTypes'] + $options);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes;
|
||||
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
|
||||
class AutowiredServices
|
||||
{
|
||||
private $annotationReader;
|
||||
private $frameworkBundleEngine;
|
||||
private $engine;
|
||||
private $dispatcher;
|
||||
private $cachePool;
|
||||
|
||||
public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine, EventDispatcherInterface $dispatcher, CacheItemPoolInterface $cachePool)
|
||||
{
|
||||
$this->annotationReader = $annotationReader;
|
||||
$this->frameworkBundleEngine = $frameworkBundleEngine;
|
||||
$this->engine = $engine;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->cachePool = $cachePool;
|
||||
}
|
||||
|
||||
public function getAnnotationReader()
|
||||
{
|
||||
return $this->annotationReader;
|
||||
}
|
||||
|
||||
public function getFrameworkBundleEngine()
|
||||
{
|
||||
return $this->frameworkBundleEngine;
|
||||
}
|
||||
|
||||
public function getEngine()
|
||||
{
|
||||
return $this->engine;
|
||||
}
|
||||
|
||||
public function getDispatcher()
|
||||
{
|
||||
return $this->dispatcher;
|
||||
}
|
||||
|
||||
public function getCachePool()
|
||||
{
|
||||
return $this->cachePool;
|
||||
}
|
||||
}
|
||||
@@ -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\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class AnnotatedController
|
||||
{
|
||||
/**
|
||||
* @Route("/null_request", name="null_request")
|
||||
*/
|
||||
public function requestDefaultNullAction(Request $request = null)
|
||||
{
|
||||
return new Response($request ? \get_class($request) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/null_argument", name="null_argument")
|
||||
*/
|
||||
public function argumentDefaultNullWithoutRouteParamAction($value = null)
|
||||
{
|
||||
return new Response($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/null_argument_with_route_param/{value}", name="null_argument_with_route_param")
|
||||
*/
|
||||
public function argumentDefaultNullWithRouteParamAction($value = null)
|
||||
{
|
||||
return new Response($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/argument_with_route_param_and_default/{value}", defaults={"value": "value"}, name="argument_with_route_param_and_default")
|
||||
*/
|
||||
public function argumentWithoutDefaultWithRouteParamAndDefaultAction($value)
|
||||
{
|
||||
return new Response($value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class FragmentController implements ContainerAwareInterface
|
||||
{
|
||||
use ContainerAwareTrait;
|
||||
|
||||
public function indexAction(Request $request)
|
||||
{
|
||||
return $this->container->get('templating')->renderResponse('fragment.html.php', ['bar' => new Bar()]);
|
||||
}
|
||||
|
||||
public function inlinedAction($options, $_format)
|
||||
{
|
||||
return new Response($options['bar']->getBar().' '.$_format);
|
||||
}
|
||||
|
||||
public function customFormatAction($_format)
|
||||
{
|
||||
return new Response($_format);
|
||||
}
|
||||
|
||||
public function customLocaleAction(Request $request)
|
||||
{
|
||||
return new Response($request->getLocale());
|
||||
}
|
||||
|
||||
public function forwardLocaleAction(Request $request)
|
||||
{
|
||||
return new Response($request->getLocale());
|
||||
}
|
||||
}
|
||||
|
||||
class Bar
|
||||
{
|
||||
private $bar = 'bar';
|
||||
|
||||
public function getBar()
|
||||
{
|
||||
return $this->bar;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class ProfilerController implements ContainerAwareInterface
|
||||
{
|
||||
use ContainerAwareTrait;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
return new Response('Hello');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class SessionController implements ContainerAwareInterface
|
||||
{
|
||||
use ContainerAwareTrait;
|
||||
|
||||
public function welcomeAction(Request $request, $name = null)
|
||||
{
|
||||
$session = $request->getSession();
|
||||
|
||||
// new session case
|
||||
if (!$session->has('name')) {
|
||||
if (!$name) {
|
||||
return new Response('You are new here and gave no name.');
|
||||
}
|
||||
|
||||
// remember name
|
||||
$session->set('name', $name);
|
||||
|
||||
return new Response(sprintf('Hello %s, nice to meet you.', $name));
|
||||
}
|
||||
|
||||
// existing session
|
||||
$name = $session->get('name');
|
||||
|
||||
return new Response(sprintf('Welcome back %s, nice to meet you.', $name));
|
||||
}
|
||||
|
||||
public function cacheableAction()
|
||||
{
|
||||
$response = new Response('all good');
|
||||
$response->setSharedMaxAge(100);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function logoutAction(Request $request)
|
||||
{
|
||||
$request->getSession()->invalidate();
|
||||
|
||||
return new Response('Session cleared.');
|
||||
}
|
||||
|
||||
public function setFlashAction(Request $request, $message)
|
||||
{
|
||||
$session = $request->getSession();
|
||||
$session->getFlashBag()->set('notice', $message);
|
||||
|
||||
return new RedirectResponse($this->container->get('router')->generate('session_showflash'));
|
||||
}
|
||||
|
||||
public function showFlashAction(Request $request)
|
||||
{
|
||||
$session = $request->getSession();
|
||||
|
||||
if ($session->getFlashBag()->has('notice')) {
|
||||
list($output) = $session->getFlashBag()->get('notice');
|
||||
} else {
|
||||
$output = 'No flash was set.';
|
||||
}
|
||||
|
||||
return new Response($output);
|
||||
}
|
||||
}
|
||||
@@ -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\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerReference;
|
||||
|
||||
class SubRequestController implements ContainerAwareInterface
|
||||
{
|
||||
use ContainerAwareTrait;
|
||||
|
||||
public function indexAction($handler)
|
||||
{
|
||||
$errorUrl = $this->generateUrl('subrequest_fragment_error', ['_locale' => 'fr', '_format' => 'json']);
|
||||
$altUrl = $this->generateUrl('subrequest_fragment', ['_locale' => 'fr', '_format' => 'json']);
|
||||
|
||||
// simulates a failure during the rendering of a fragment...
|
||||
// should render fr/json
|
||||
$content = $handler->render($errorUrl, 'inline', ['alt' => $altUrl]);
|
||||
|
||||
// ...to check that the FragmentListener still references the right Request
|
||||
// when rendering another fragment after the error occurred
|
||||
// should render en/html instead of fr/json
|
||||
$content .= $handler->render(new ControllerReference('TestBundle:SubRequest:fragment'));
|
||||
|
||||
// forces the LocaleListener to set fr for the locale...
|
||||
// should render fr/json
|
||||
$content .= $handler->render($altUrl);
|
||||
|
||||
// ...and check that after the rendering, the original Request is back
|
||||
// and en is used as a locale
|
||||
// should use en/html instead of fr/json
|
||||
$content .= '--'.$this->generateUrl('subrequest_fragment');
|
||||
|
||||
// The RouterListener is also tested as if it does not keep the right
|
||||
// Request in the context, a 301 would be generated
|
||||
return new Response($content);
|
||||
}
|
||||
|
||||
public function fragmentAction(Request $request)
|
||||
{
|
||||
return new Response('--'.$request->getLocale().'/'.$request->getRequestFormat());
|
||||
}
|
||||
|
||||
public function fragmentErrorAction()
|
||||
{
|
||||
throw new \RuntimeException('error');
|
||||
}
|
||||
|
||||
protected function generateUrl($name, $arguments = [])
|
||||
{
|
||||
return $this->container->get('router')->generate($name, $arguments);
|
||||
}
|
||||
}
|
||||
@@ -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\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
class SubRequestServiceResolutionController implements ContainerAwareInterface
|
||||
{
|
||||
use ContainerAwareTrait;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$request = $this->container->get('request_stack')->getCurrentRequest();
|
||||
$path['_forwarded'] = $request->attributes;
|
||||
$path['_controller'] = 'TestBundle:SubRequestServiceResolution:fragment';
|
||||
$subRequest = $request->duplicate([], null, $path);
|
||||
|
||||
return $this->container->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
|
||||
}
|
||||
|
||||
public function fragmentAction(LoggerInterface $logger)
|
||||
{
|
||||
return new Response('---');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
class AnnotationReaderPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
// simulate using "annotation_reader" in a compiler pass
|
||||
$container->get('test.annotation_reader');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\Config;
|
||||
|
||||
class CustomConfig
|
||||
{
|
||||
public function addConfiguration($rootNode)
|
||||
{
|
||||
$rootNode
|
||||
->children()
|
||||
->scalarNode('custom')->end()
|
||||
->arrayNode('array')
|
||||
->children()
|
||||
->scalarNode('child1')->end()
|
||||
->scalarNode('child2')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
private $customConfig;
|
||||
|
||||
public function __construct($customConfig = null)
|
||||
{
|
||||
$this->customConfig = $customConfig;
|
||||
}
|
||||
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
$rootNode = $treeBuilder->root('test');
|
||||
|
||||
if ($this->customConfig) {
|
||||
$this->customConfig->addConfiguration($rootNode);
|
||||
}
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\Extension;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
|
||||
class TestExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
private $customConfig;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$configuration = $this->getConfiguration($configs, $container);
|
||||
$this->processConfiguration($configuration, $configs);
|
||||
|
||||
$container->setAlias('test.annotation_reader', new Alias('annotation_reader', true));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('test', ['custom' => 'foo']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfiguration(array $config, ContainerBuilder $container)
|
||||
{
|
||||
return new Configuration($this->customConfig);
|
||||
}
|
||||
|
||||
public function setCustomConfig($customConfig)
|
||||
{
|
||||
$this->customConfig = $customConfig;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
session_welcome:
|
||||
path: /session
|
||||
defaults: { _controller: TestBundle:Session:welcome }
|
||||
|
||||
session_cacheable:
|
||||
path: /cacheable
|
||||
defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SessionController::cacheableAction }
|
||||
|
||||
session_welcome_name:
|
||||
path: /session/{name}
|
||||
defaults: { _controller: TestBundle:Session:welcome }
|
||||
|
||||
session_logout:
|
||||
path: /session_logout
|
||||
defaults: { _controller: TestBundle:Session:logout}
|
||||
|
||||
session_setflash:
|
||||
path: /session_setflash/{message}
|
||||
defaults: { _controller: TestBundle:Session:setFlash}
|
||||
|
||||
session_showflash:
|
||||
path: /session_showflash
|
||||
defaults: { _controller: TestBundle:Session:showFlash}
|
||||
|
||||
profiler:
|
||||
path: /profiler
|
||||
defaults: { _controller: TestBundle:Profiler:index }
|
||||
|
||||
subrequest_index:
|
||||
path: /subrequest/{_locale}.{_format}
|
||||
defaults: { _controller: TestBundle:SubRequest:index, _format: "html" }
|
||||
schemes: [https]
|
||||
|
||||
subrequest_fragment_error:
|
||||
path: /subrequest/fragment/error/{_locale}.{_format}
|
||||
defaults: { _controller: TestBundle:SubRequest:fragmentError, _format: "html" }
|
||||
schemes: [http]
|
||||
|
||||
subrequest_fragment:
|
||||
path: /subrequest/fragment/{_locale}.{_format}
|
||||
defaults: { _controller: TestBundle:SubRequest:fragment, _format: "html" }
|
||||
schemes: [http]
|
||||
|
||||
fragment_home:
|
||||
path: /fragment_home
|
||||
defaults: { _controller: TestBundle:Fragment:index, _format: txt }
|
||||
|
||||
fragment_inlined:
|
||||
path: /fragment_inlined
|
||||
defaults: { _controller: TestBundle:Fragment:inlined }
|
||||
|
||||
array_controller:
|
||||
path: /array_controller
|
||||
defaults: { _controller: [ArrayController, someAction] }
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\AnnotationReaderPass;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\Config\CustomConfig;
|
||||
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class TestBundle extends Bundle
|
||||
{
|
||||
public function build(ContainerBuilder $container)
|
||||
{
|
||||
parent::build($container);
|
||||
|
||||
/** @var $extension DependencyInjection\TestExtension */
|
||||
$extension = $container->getExtension('test');
|
||||
|
||||
$extension->setCustomConfig(new CustomConfig());
|
||||
|
||||
$container->addCompilerPass(new AnnotationReaderPass(), PassConfig::TYPE_AFTER_REMOVING);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class CachePoolClearCommandTest extends AbstractWebTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
static::bootKernel(['test_case' => 'CachePoolClear', 'root_config' => 'config.yml']);
|
||||
}
|
||||
|
||||
public function testClearPrivatePool()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$tester->execute(['pools' => ['cache.private_pool']], ['decorated' => false]);
|
||||
|
||||
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
|
||||
$this->assertStringContainsString('Clearing cache pool: cache.private_pool', $tester->getDisplay());
|
||||
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testClearPublicPool()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$tester->execute(['pools' => ['cache.public_pool']], ['decorated' => false]);
|
||||
|
||||
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
|
||||
$this->assertStringContainsString('Clearing cache pool: cache.public_pool', $tester->getDisplay());
|
||||
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testClearPoolWithCustomClearer()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$tester->execute(['pools' => ['cache.pool_with_clearer']], ['decorated' => false]);
|
||||
|
||||
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
|
||||
$this->assertStringContainsString('Clearing cache pool: cache.pool_with_clearer', $tester->getDisplay());
|
||||
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testCallClearer()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$tester->execute(['pools' => ['cache.app_clearer']], ['decorated' => false]);
|
||||
|
||||
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:clear exits with 0 in case of success');
|
||||
$this->assertStringContainsString('Calling cache clearer: cache.app_clearer', $tester->getDisplay());
|
||||
$this->assertStringContainsString('[OK] Cache was successfully cleared.', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testClearUnexistingPool()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException');
|
||||
$this->expectExceptionMessage('You have requested a non-existent service "unknown_pool"');
|
||||
$this->createCommandTester()
|
||||
->execute(['pools' => ['unknown_pool']], ['decorated' => false]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand::__construct() expects an instance of "Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer" as first argument since Symfony 3.4. Not passing it is deprecated and will throw a TypeError in 4.0.
|
||||
*/
|
||||
public function testLegacyClearCommand()
|
||||
{
|
||||
$application = new Application(static::$kernel);
|
||||
$application->add(new CachePoolClearCommand());
|
||||
|
||||
$tester = new CommandTester($application->find('cache:pool:clear'));
|
||||
|
||||
$tester->execute(['pools' => []]);
|
||||
|
||||
$this->assertStringContainsString('Cache was successfully cleared', $tester->getDisplay());
|
||||
}
|
||||
|
||||
private function createCommandTester()
|
||||
{
|
||||
$container = static::$kernel->getContainer();
|
||||
$application = new Application(static::$kernel);
|
||||
$application->add(new CachePoolClearCommand($container->get('cache.global_clearer')));
|
||||
|
||||
return new CommandTester($application->find('cache:pool:clear'));
|
||||
}
|
||||
}
|
||||
103
lib/symfony/framework-bundle/Tests/Functional/CachePoolsTest.php
Normal file
103
lib/symfony/framework-bundle/Tests/Functional/CachePoolsTest.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Component\Cache\Adapter\AdapterInterface;
|
||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||
use Symfony\Component\Cache\Exception\InvalidArgumentException;
|
||||
|
||||
class CachePoolsTest extends AbstractWebTestCase
|
||||
{
|
||||
public function testCachePools()
|
||||
{
|
||||
$this->doTestCachePools([], AdapterInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension redis
|
||||
*/
|
||||
public function testRedisCachePools()
|
||||
{
|
||||
try {
|
||||
$this->doTestCachePools(['root_config' => 'redis_config.yml', 'environment' => 'redis_cache'], RedisAdapter::class);
|
||||
} catch (\PHPUnit\Framework\Error\Warning $e) {
|
||||
if (0 !== strpos($e->getMessage(), 'unable to connect to')) {
|
||||
throw $e;
|
||||
}
|
||||
$this->markTestSkipped($e->getMessage());
|
||||
} catch (\PHPUnit\Framework\Error\Warning $e) {
|
||||
if (0 !== strpos($e->getMessage(), 'unable to connect to')) {
|
||||
throw $e;
|
||||
}
|
||||
$this->markTestSkipped($e->getMessage());
|
||||
} catch (InvalidArgumentException $e) {
|
||||
if (0 !== strpos($e->getMessage(), 'Redis connection failed')) {
|
||||
throw $e;
|
||||
}
|
||||
$this->markTestSkipped($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension redis
|
||||
*/
|
||||
public function testRedisCustomCachePools()
|
||||
{
|
||||
try {
|
||||
$this->doTestCachePools(['root_config' => 'redis_custom_config.yml', 'environment' => 'custom_redis_cache'], RedisAdapter::class);
|
||||
} catch (\PHPUnit\Framework\Error\Warning $e) {
|
||||
if (0 !== strpos($e->getMessage(), 'unable to connect to')) {
|
||||
throw $e;
|
||||
}
|
||||
$this->markTestSkipped($e->getMessage());
|
||||
} catch (\PHPUnit\Framework\Error\Warning $e) {
|
||||
if (0 !== strpos($e->getMessage(), 'unable to connect to')) {
|
||||
throw $e;
|
||||
}
|
||||
$this->markTestSkipped($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private function doTestCachePools($options, $adapterClass)
|
||||
{
|
||||
static::bootKernel($options);
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$pool1 = $container->get('cache.pool1');
|
||||
$this->assertInstanceOf($adapterClass, $pool1);
|
||||
|
||||
$key = 'foobar';
|
||||
$pool1->deleteItem($key);
|
||||
$item = $pool1->getItem($key);
|
||||
$this->assertFalse($item->isHit());
|
||||
|
||||
$item->set('baz');
|
||||
$pool1->save($item);
|
||||
$item = $pool1->getItem($key);
|
||||
$this->assertTrue($item->isHit());
|
||||
|
||||
$pool2 = $container->get('cache.pool2');
|
||||
$pool2->save($item);
|
||||
|
||||
$container->get('cache_clearer')->clear($container->getParameter('kernel.cache_dir'));
|
||||
$item = $pool1->getItem($key);
|
||||
$this->assertFalse($item->isHit());
|
||||
|
||||
$item = $pool2->getItem($key);
|
||||
$this->assertTrue($item->isHit());
|
||||
}
|
||||
|
||||
protected static function createKernel(array $options = [])
|
||||
{
|
||||
return parent::createKernel(['test_case' => 'CachePools'] + $options);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class ConfigDebugCommandTest extends AbstractWebTestCase
|
||||
{
|
||||
private $application;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$kernel = static::createKernel(['test_case' => 'ConfigDump', 'root_config' => 'config.yml']);
|
||||
$this->application = new Application($kernel);
|
||||
$this->application->doRun(new ArrayInput([]), new NullOutput());
|
||||
}
|
||||
|
||||
public function testDumpBundleName()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$ret = $tester->execute(['name' => 'TestBundle']);
|
||||
|
||||
$this->assertSame(0, $ret, 'Returns 0 in case of success');
|
||||
$this->assertStringContainsString('custom: foo', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testDumpBundleOption()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$ret = $tester->execute(['name' => 'TestBundle', 'path' => 'custom']);
|
||||
|
||||
$this->assertSame(0, $ret, 'Returns 0 in case of success');
|
||||
$this->assertStringContainsString('foo', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testParametersValuesAreResolved()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$ret = $tester->execute(['name' => 'framework']);
|
||||
|
||||
$this->assertSame(0, $ret, 'Returns 0 in case of success');
|
||||
$this->assertStringContainsString("locale: '%env(LOCALE)%'", $tester->getDisplay());
|
||||
$this->assertStringContainsString('secret: test', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testDumpUndefinedBundleOption()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$tester->execute(['name' => 'TestBundle', 'path' => 'foo']);
|
||||
|
||||
$this->assertStringContainsString('Unable to find configuration for "test.foo"', $tester->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CommandTester
|
||||
*/
|
||||
private function createCommandTester()
|
||||
{
|
||||
$command = $this->application->find('debug:config');
|
||||
|
||||
return new CommandTester($command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class ConfigDumpReferenceCommandTest extends AbstractWebTestCase
|
||||
{
|
||||
private $application;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$kernel = static::createKernel(['test_case' => 'ConfigDump', 'root_config' => 'config.yml']);
|
||||
$this->application = new Application($kernel);
|
||||
$this->application->doRun(new ArrayInput([]), new NullOutput());
|
||||
}
|
||||
|
||||
public function testDumpBundleName()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$ret = $tester->execute(['name' => 'TestBundle']);
|
||||
|
||||
$this->assertSame(0, $ret, 'Returns 0 in case of success');
|
||||
$this->assertStringContainsString('test:', $tester->getDisplay());
|
||||
$this->assertStringContainsString(' custom:', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testDumpAtPath()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$ret = $tester->execute([
|
||||
'name' => 'test',
|
||||
'path' => 'array',
|
||||
]);
|
||||
|
||||
$this->assertSame(0, $ret, 'Returns 0 in case of success');
|
||||
$this->assertSame(<<<'EOL'
|
||||
# Default configuration for extension with alias: "test" at path "array"
|
||||
array:
|
||||
child1: ~
|
||||
child2: ~
|
||||
|
||||
|
||||
EOL
|
||||
, $tester->getDisplay(true));
|
||||
}
|
||||
|
||||
public function testDumpAtPathXml()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$ret = $tester->execute([
|
||||
'name' => 'test',
|
||||
'path' => 'array',
|
||||
'--format' => 'xml',
|
||||
]);
|
||||
|
||||
$this->assertSame(1, $ret);
|
||||
$this->assertStringContainsString('[ERROR] The "path" option is only available for the "yaml" format.', $tester->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CommandTester
|
||||
*/
|
||||
private function createCommandTester()
|
||||
{
|
||||
$command = $this->application->find('config:dump-reference');
|
||||
|
||||
return new CommandTester($command);
|
||||
}
|
||||
}
|
||||
@@ -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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Tester\ApplicationTester;
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class ContainerDebugCommandTest extends AbstractWebTestCase
|
||||
{
|
||||
public function testDumpContainerIfNotExists()
|
||||
{
|
||||
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml', 'debug' => true]);
|
||||
|
||||
$application = new Application(static::$kernel);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
@unlink(static::$kernel->getContainer()->getParameter('debug.container.dump'));
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(['command' => 'debug:container']);
|
||||
|
||||
$this->assertFileExists(static::$kernel->getContainer()->getParameter('debug.container.dump'));
|
||||
}
|
||||
|
||||
public function testNoDebug()
|
||||
{
|
||||
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml', 'debug' => false]);
|
||||
|
||||
$application = new Application(static::$kernel);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(['command' => 'debug:container']);
|
||||
|
||||
$this->assertStringContainsString('public', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testPrivateAlias()
|
||||
{
|
||||
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);
|
||||
|
||||
$application = new Application(static::$kernel);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(['command' => 'debug:container', '--show-private' => true]);
|
||||
$this->assertStringContainsString('public', $tester->getDisplay());
|
||||
$this->assertStringContainsString('private_alias', $tester->getDisplay());
|
||||
|
||||
$tester->run(['command' => 'debug:container']);
|
||||
$this->assertStringContainsString('public', $tester->getDisplay());
|
||||
$this->assertStringNotContainsString('private_alias', $tester->getDisplay());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
/**
|
||||
* Checks that the container compiles correctly when all the bundle features are enabled.
|
||||
*/
|
||||
class ContainerDumpTest extends AbstractWebTestCase
|
||||
{
|
||||
public function testContainerCompilationInDebug()
|
||||
{
|
||||
$client = $this->createClient(['test_case' => 'ContainerDump', 'root_config' => 'config.yml']);
|
||||
|
||||
$this->assertTrue($client->getContainer()->has('serializer'));
|
||||
}
|
||||
|
||||
public function testContainerCompilation()
|
||||
{
|
||||
$client = $this->createClient(['test_case' => 'ContainerDump', 'root_config' => 'config.yml', 'debug' => false]);
|
||||
|
||||
$this->assertTrue($client->getContainer()->has('serializer'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Tester\ApplicationTester;
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class DebugAutowiringCommandTest extends AbstractWebTestCase
|
||||
{
|
||||
public function testBasicFunctionality()
|
||||
{
|
||||
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);
|
||||
|
||||
$application = new Application(static::$kernel);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(['command' => 'debug:autowiring']);
|
||||
|
||||
$this->assertStringContainsString('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
|
||||
$this->assertStringContainsString('alias to http_kernel', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testSearchArgument()
|
||||
{
|
||||
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);
|
||||
|
||||
$application = new Application(static::$kernel);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(['command' => 'debug:autowiring', 'search' => 'kern']);
|
||||
|
||||
$this->assertStringContainsString('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
|
||||
$this->assertStringNotContainsString('Symfony\Component\Routing\RouterInterface', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testSearchNoResults()
|
||||
{
|
||||
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);
|
||||
|
||||
$application = new Application(static::$kernel);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(['command' => 'debug:autowiring', 'search' => 'foo_fake'], ['capture_stderr_separately' => true]);
|
||||
|
||||
$this->assertStringContainsString('No autowirable classes or interfaces found matching "foo_fake"', $tester->getErrorOutput());
|
||||
$this->assertEquals(1, $tester->getStatusCode());
|
||||
}
|
||||
}
|
||||
@@ -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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
class FragmentTest extends AbstractWebTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getConfigs
|
||||
*/
|
||||
public function testFragment($insulate)
|
||||
{
|
||||
$client = $this->createClient(['test_case' => 'Fragment', 'root_config' => 'config.yml']);
|
||||
if ($insulate) {
|
||||
$client->insulate();
|
||||
}
|
||||
|
||||
$client->request('GET', '/fragment_home');
|
||||
|
||||
$this->assertEquals('bar txt--html--es--fr', $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
public function getConfigs()
|
||||
{
|
||||
return [
|
||||
[false],
|
||||
[true],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
class ProfilerTest extends AbstractWebTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider getConfigs
|
||||
*/
|
||||
public function testProfilerIsDisabled($insulate)
|
||||
{
|
||||
$client = $this->createClient(['test_case' => 'Profiler', 'root_config' => 'config.yml']);
|
||||
if ($insulate) {
|
||||
$client->insulate();
|
||||
}
|
||||
|
||||
$client->request('GET', '/profiler');
|
||||
$this->assertNull($client->getProfile());
|
||||
|
||||
// enable the profiler for the next request
|
||||
$client->enableProfiler();
|
||||
$this->assertNull($client->getProfile());
|
||||
$client->request('GET', '/profiler');
|
||||
$this->assertIsObject($client->getProfile());
|
||||
|
||||
$client->request('GET', '/profiler');
|
||||
$this->assertNull($client->getProfile());
|
||||
}
|
||||
|
||||
public function getConfigs()
|
||||
{
|
||||
return [
|
||||
[false],
|
||||
[true],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
use Symfony\Component\PropertyInfo\Type;
|
||||
|
||||
class PropertyInfoTest extends AbstractWebTestCase
|
||||
{
|
||||
public function testPhpDocPriority()
|
||||
{
|
||||
static::bootKernel(['test_case' => 'Serializer']);
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$this->assertEquals([new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_INT))], $container->get('test.property_info')->getTypes('Symfony\Bundle\FrameworkBundle\Tests\Functional\Dummy', 'codes'));
|
||||
}
|
||||
}
|
||||
|
||||
class Dummy
|
||||
{
|
||||
/**
|
||||
* @param int[] $codes
|
||||
*/
|
||||
public function setCodes(array $codes)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class SerializerTest extends AbstractWebTestCase
|
||||
{
|
||||
public function testDeserializeArrayOfObject()
|
||||
{
|
||||
static::bootKernel(['test_case' => 'Serializer']);
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$result = $container->get('serializer')->deserialize('{"bars": [{"id": 1}, {"id": 2}]}', Foo::class, 'json');
|
||||
|
||||
$bar1 = new Bar();
|
||||
$bar1->id = 1;
|
||||
$bar2 = new Bar();
|
||||
$bar2->id = 2;
|
||||
|
||||
$expected = new Foo();
|
||||
$expected->bars = [$bar1, $bar2];
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
||||
|
||||
class Foo
|
||||
{
|
||||
/**
|
||||
* @var Bar[]
|
||||
*/
|
||||
public $bars;
|
||||
}
|
||||
|
||||
class Bar
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $id;
|
||||
}
|
||||
153
lib/symfony/framework-bundle/Tests/Functional/SessionTest.php
Normal file
153
lib/symfony/framework-bundle/Tests/Functional/SessionTest.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
class SessionTest extends AbstractWebTestCase
|
||||
{
|
||||
/**
|
||||
* Tests session attributes persist.
|
||||
*
|
||||
* @dataProvider getConfigs
|
||||
*/
|
||||
public function testWelcome($config, $insulate)
|
||||
{
|
||||
$client = $this->createClient(['test_case' => 'Session', 'root_config' => $config]);
|
||||
if ($insulate) {
|
||||
$client->insulate();
|
||||
}
|
||||
|
||||
// no session
|
||||
$crawler = $client->request('GET', '/session');
|
||||
$this->assertStringContainsString('You are new here and gave no name.', $crawler->text());
|
||||
|
||||
// remember name
|
||||
$crawler = $client->request('GET', '/session/drak');
|
||||
$this->assertStringContainsString('Hello drak, nice to meet you.', $crawler->text());
|
||||
|
||||
// prove remembered name
|
||||
$crawler = $client->request('GET', '/session');
|
||||
$this->assertStringContainsString('Welcome back drak, nice to meet you.', $crawler->text());
|
||||
|
||||
// clear session
|
||||
$crawler = $client->request('GET', '/session_logout');
|
||||
$this->assertStringContainsString('Session cleared.', $crawler->text());
|
||||
|
||||
// prove cleared session
|
||||
$crawler = $client->request('GET', '/session');
|
||||
$this->assertStringContainsString('You are new here and gave no name.', $crawler->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests flash messages work in practice.
|
||||
*
|
||||
* @dataProvider getConfigs
|
||||
*/
|
||||
public function testFlash($config, $insulate)
|
||||
{
|
||||
$client = $this->createClient(['test_case' => 'Session', 'root_config' => $config]);
|
||||
if ($insulate) {
|
||||
$client->insulate();
|
||||
}
|
||||
|
||||
// set flash
|
||||
$client->request('GET', '/session_setflash/Hello%20world.');
|
||||
|
||||
// check flash displays on redirect
|
||||
$this->assertStringContainsString('Hello world.', $client->followRedirect()->text());
|
||||
|
||||
// check flash is gone
|
||||
$crawler = $client->request('GET', '/session_showflash');
|
||||
$this->assertStringContainsString('No flash was set.', $crawler->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* See if two separate insulated clients can run without
|
||||
* polluting each other's session data.
|
||||
*
|
||||
* @dataProvider getConfigs
|
||||
*/
|
||||
public function testTwoClients($config, $insulate)
|
||||
{
|
||||
// start first client
|
||||
$client1 = $this->createClient(['test_case' => 'Session', 'root_config' => $config]);
|
||||
if ($insulate) {
|
||||
$client1->insulate();
|
||||
}
|
||||
|
||||
// start second client
|
||||
$client2 = $this->createClient(['test_case' => 'Session', 'root_config' => $config]);
|
||||
if ($insulate) {
|
||||
$client2->insulate();
|
||||
}
|
||||
|
||||
// new session, so no name set.
|
||||
$crawler1 = $client1->request('GET', '/session');
|
||||
$this->assertStringContainsString('You are new here and gave no name.', $crawler1->text());
|
||||
|
||||
// set name of client1
|
||||
$crawler1 = $client1->request('GET', '/session/client1');
|
||||
$this->assertStringContainsString('Hello client1, nice to meet you.', $crawler1->text());
|
||||
|
||||
// no session for client2
|
||||
$crawler2 = $client2->request('GET', '/session');
|
||||
$this->assertStringContainsString('You are new here and gave no name.', $crawler2->text());
|
||||
|
||||
// remember name client2
|
||||
$crawler2 = $client2->request('GET', '/session/client2');
|
||||
$this->assertStringContainsString('Hello client2, nice to meet you.', $crawler2->text());
|
||||
|
||||
// prove remembered name of client1
|
||||
$crawler1 = $client1->request('GET', '/session');
|
||||
$this->assertStringContainsString('Welcome back client1, nice to meet you.', $crawler1->text());
|
||||
|
||||
// prove remembered name of client2
|
||||
$crawler2 = $client2->request('GET', '/session');
|
||||
$this->assertStringContainsString('Welcome back client2, nice to meet you.', $crawler2->text());
|
||||
|
||||
// clear client1
|
||||
$crawler1 = $client1->request('GET', '/session_logout');
|
||||
$this->assertStringContainsString('Session cleared.', $crawler1->text());
|
||||
|
||||
// prove client1 data is cleared
|
||||
$crawler1 = $client1->request('GET', '/session');
|
||||
$this->assertStringContainsString('You are new here and gave no name.', $crawler1->text());
|
||||
|
||||
// prove remembered name of client2 remains untouched.
|
||||
$crawler2 = $client2->request('GET', '/session');
|
||||
$this->assertStringContainsString('Welcome back client2, nice to meet you.', $crawler2->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getConfigs
|
||||
*/
|
||||
public function testCorrectCacheControlHeadersForCacheableAction($config, $insulate)
|
||||
{
|
||||
$client = $this->createClient(['test_case' => 'Session', 'root_config' => $config]);
|
||||
if ($insulate) {
|
||||
$client->insulate();
|
||||
}
|
||||
|
||||
$client->request('GET', '/cacheable');
|
||||
|
||||
$response = $client->getResponse();
|
||||
$this->assertSame('public, s-maxage=100', $response->headers->get('cache-control'));
|
||||
}
|
||||
|
||||
public function getConfigs()
|
||||
{
|
||||
return [
|
||||
// configfile, insulate
|
||||
['config.yml', true],
|
||||
['config.yml', false],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional;
|
||||
|
||||
class SubRequestsTest extends AbstractWebTestCase
|
||||
{
|
||||
public function testStateAfterSubRequest()
|
||||
{
|
||||
$client = $this->createClient(['test_case' => 'Session', 'root_config' => 'config.yml']);
|
||||
$client->request('GET', 'https://localhost/subrequest/en');
|
||||
|
||||
$this->assertEquals('--fr/json--en/html--fr/json--http://localhost/subrequest/fragment/en', $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
public function testSubRequestControllerServicesAreResolved()
|
||||
{
|
||||
$client = $this->createClient(['test_case' => 'ControllerServiceResolution', 'root_config' => 'config.yml']);
|
||||
$client->request('GET', 'https://localhost/subrequest');
|
||||
|
||||
$this->assertEquals('---', $client->getResponse()->getContent());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
|
||||
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
new TestBundle(),
|
||||
];
|
||||
@@ -0,0 +1,2 @@
|
||||
imports:
|
||||
- { resource: ../config/default.yml }
|
||||
@@ -0,0 +1,4 @@
|
||||
annotated_controller:
|
||||
prefix: /annotated
|
||||
resource: "@TestBundle/Controller/AnnotatedController.php"
|
||||
type: annotation
|
||||
100
lib/symfony/framework-bundle/Tests/Functional/app/AppKernel.php
Normal file
100
lib/symfony/framework-bundle/Tests/Functional/app/AppKernel.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?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\Bundle\FrameworkBundle\Tests\Functional\app;
|
||||
|
||||
use Psr\Log\NullLogger;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
/**
|
||||
* App Test Kernel for functional tests.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class AppKernel extends Kernel
|
||||
{
|
||||
private $varDir;
|
||||
private $testCase;
|
||||
private $rootConfig;
|
||||
|
||||
public function __construct($varDir, $testCase, $rootConfig, $environment, $debug)
|
||||
{
|
||||
if (!is_dir(__DIR__.'/'.$testCase)) {
|
||||
throw new \InvalidArgumentException(sprintf('The test case "%s" does not exist.', $testCase));
|
||||
}
|
||||
$this->varDir = $varDir;
|
||||
$this->testCase = $testCase;
|
||||
|
||||
$fs = new Filesystem();
|
||||
if (!$fs->isAbsolutePath($rootConfig) && !file_exists($rootConfig = __DIR__.'/'.$testCase.'/'.$rootConfig)) {
|
||||
throw new \InvalidArgumentException(sprintf('The root config "%s" does not exist.', $rootConfig));
|
||||
}
|
||||
$this->rootConfig = $rootConfig;
|
||||
|
||||
parent::__construct($environment, $debug);
|
||||
}
|
||||
|
||||
public function registerBundles()
|
||||
{
|
||||
if (!file_exists($filename = $this->getRootDir().'/'.$this->testCase.'/bundles.php')) {
|
||||
throw new \RuntimeException(sprintf('The bundles file "%s" does not exist.', $filename));
|
||||
}
|
||||
|
||||
return include $filename;
|
||||
}
|
||||
|
||||
public function getRootDir()
|
||||
{
|
||||
return __DIR__;
|
||||
}
|
||||
|
||||
public function getCacheDir()
|
||||
{
|
||||
return sys_get_temp_dir().'/'.$this->varDir.'/'.$this->testCase.'/cache/'.$this->environment;
|
||||
}
|
||||
|
||||
public function getLogDir()
|
||||
{
|
||||
return sys_get_temp_dir().'/'.$this->varDir.'/'.$this->testCase.'/logs';
|
||||
}
|
||||
|
||||
public function registerContainerConfiguration(LoaderInterface $loader)
|
||||
{
|
||||
$loader->load($this->rootConfig);
|
||||
}
|
||||
|
||||
protected function build(ContainerBuilder $container)
|
||||
{
|
||||
$container->register('logger', NullLogger::class);
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
{
|
||||
return serialize([$this->varDir, $this->testCase, $this->rootConfig, $this->getEnvironment(), $this->isDebug()]);
|
||||
}
|
||||
|
||||
public function unserialize($str)
|
||||
{
|
||||
$a = unserialize($str);
|
||||
$this->__construct($a[0], $a[1], $a[2], $a[3], $a[4]);
|
||||
}
|
||||
|
||||
protected function getKernelParameters()
|
||||
{
|
||||
$parameters = parent::getKernelParameters();
|
||||
$parameters['kernel.test_case'] = $this->testCase;
|
||||
|
||||
return $parameters;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
|
||||
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
new TestBundle(),
|
||||
];
|
||||
@@ -0,0 +1,11 @@
|
||||
imports:
|
||||
- { resource: ../config/default.yml }
|
||||
|
||||
services:
|
||||
_defaults: { public: true }
|
||||
test.autowiring_types.autowired_services:
|
||||
class: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes\AutowiredServices
|
||||
autowire: true
|
||||
framework:
|
||||
templating:
|
||||
engines: ['php']
|
||||
@@ -0,0 +1,6 @@
|
||||
imports:
|
||||
- { resource: config.yml }
|
||||
|
||||
framework:
|
||||
annotations:
|
||||
cache: none
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
|
||||
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
new TestBundle(),
|
||||
];
|
||||
@@ -0,0 +1,22 @@
|
||||
imports:
|
||||
- { resource: ../config/default.yml }
|
||||
|
||||
services:
|
||||
dummy:
|
||||
class: Symfony\Bundle\FrameworkBundle\Tests\Fixtures\DeclaredClass
|
||||
arguments: ['@cache.private_pool']
|
||||
public: true
|
||||
custom_clearer:
|
||||
parent: cache.default_clearer
|
||||
tags:
|
||||
- name: kernel.cache_clearer
|
||||
|
||||
framework:
|
||||
cache:
|
||||
pools:
|
||||
cache.private_pool: ~
|
||||
cache.public_pool:
|
||||
public: true
|
||||
cache.pool_with_clearer:
|
||||
public: true
|
||||
clearer: custom_clearer
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
|
||||
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
new TestBundle(),
|
||||
];
|
||||
@@ -0,0 +1,14 @@
|
||||
imports:
|
||||
- { resource: ../config/default.yml }
|
||||
|
||||
framework:
|
||||
cache:
|
||||
pools:
|
||||
cache.pool1:
|
||||
public: true
|
||||
adapter: cache.system
|
||||
cache.pool2:
|
||||
public: true
|
||||
adapter: cache.pool3
|
||||
cache.pool3:
|
||||
clearer: ~
|
||||
@@ -0,0 +1,17 @@
|
||||
imports:
|
||||
- { resource: ../config/default.yml }
|
||||
|
||||
parameters:
|
||||
env(REDIS_HOST): 'localhost'
|
||||
|
||||
framework:
|
||||
cache:
|
||||
app: cache.adapter.redis
|
||||
default_redis_provider: "redis://%env(REDIS_HOST)%"
|
||||
pools:
|
||||
cache.pool1:
|
||||
public: true
|
||||
clearer: cache.system_clearer
|
||||
cache.pool2:
|
||||
public: true
|
||||
clearer: ~
|
||||
@@ -0,0 +1,28 @@
|
||||
imports:
|
||||
- { resource: ../config/default.yml }
|
||||
|
||||
parameters:
|
||||
env(REDIS_HOST): 'localhost'
|
||||
|
||||
services:
|
||||
cache.test_redis_connection:
|
||||
public: false
|
||||
class: Redis
|
||||
calls:
|
||||
- [connect, ['%env(REDIS_HOST)%']]
|
||||
|
||||
cache.app:
|
||||
parent: cache.adapter.redis
|
||||
tags:
|
||||
- name: cache.pool
|
||||
provider: cache.test_redis_connection
|
||||
|
||||
framework:
|
||||
cache:
|
||||
pools:
|
||||
cache.pool1:
|
||||
public: true
|
||||
clearer: cache.system_clearer
|
||||
cache.pool2:
|
||||
public: true
|
||||
clearer: ~
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
|
||||
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
new TestBundle(),
|
||||
];
|
||||
@@ -0,0 +1,10 @@
|
||||
imports:
|
||||
- { resource: ../config/default.yml }
|
||||
|
||||
framework:
|
||||
secret: '%secret%'
|
||||
default_locale: '%env(LOCALE)%'
|
||||
|
||||
parameters:
|
||||
env(LOCALE): en
|
||||
secret: test
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
|
||||
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
new TestBundle(),
|
||||
];
|
||||
@@ -0,0 +1,10 @@
|
||||
imports:
|
||||
- { resource: ../config/default.yml }
|
||||
|
||||
services:
|
||||
_defaults: { public: true }
|
||||
public:
|
||||
class: Symfony\Bundle\FrameworkBundle\Tests\Fixtures\DeclaredClass
|
||||
private_alias:
|
||||
alias: public
|
||||
public: false
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
|
||||
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
new TestBundle(),
|
||||
];
|
||||
@@ -0,0 +1,21 @@
|
||||
imports:
|
||||
- { resource: ../config/default.yml }
|
||||
|
||||
framework:
|
||||
esi: true
|
||||
ssi: true
|
||||
fragments: true
|
||||
profiler: true
|
||||
router: true
|
||||
session: true
|
||||
request: true
|
||||
templating:
|
||||
enabled: true
|
||||
engines: ['php']
|
||||
assets: true
|
||||
translator: true
|
||||
validation: true
|
||||
serializer: true
|
||||
property_info: true
|
||||
csrf_protection: true
|
||||
form: true
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
|
||||
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
new TestBundle(),
|
||||
];
|
||||
@@ -0,0 +1,10 @@
|
||||
imports:
|
||||
- { resource: ../config/default.yml }
|
||||
|
||||
services:
|
||||
Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SubRequestServiceResolutionController:
|
||||
public: true
|
||||
tags: [controller.service_arguments]
|
||||
|
||||
logger: { class: Psr\Log\NullLogger }
|
||||
Psr\Log\LoggerInterface: '@logger'
|
||||
@@ -0,0 +1,4 @@
|
||||
sub_request_page:
|
||||
path: /subrequest
|
||||
defaults:
|
||||
_controller: 'TestBundle:SubRequestServiceResolution:index'
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
|
||||
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
new TestBundle(),
|
||||
];
|
||||
@@ -0,0 +1,7 @@
|
||||
imports:
|
||||
- { resource: ../config/default.yml }
|
||||
|
||||
framework:
|
||||
fragments: ~
|
||||
templating:
|
||||
engines: ['php']
|
||||
@@ -0,0 +1,2 @@
|
||||
_fragmenttest_bundle:
|
||||
resource: '@TestBundle/Resources/config/routing.yml'
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
|
||||
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
new TestBundle(),
|
||||
];
|
||||
@@ -0,0 +1,7 @@
|
||||
imports:
|
||||
- { resource: ../config/default.yml }
|
||||
|
||||
framework:
|
||||
profiler:
|
||||
enabled: true
|
||||
collect: false
|
||||
@@ -0,0 +1,2 @@
|
||||
_sessiontest_bundle:
|
||||
resource: '@TestBundle/Resources/config/routing.yml'
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php echo $this->get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:inlined', [
|
||||
'options' => [
|
||||
'bar' => $bar,
|
||||
'eleven' => 11,
|
||||
],
|
||||
]));
|
||||
?>--<?php
|
||||
echo $this->get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:customformat', ['_format' => 'html']));
|
||||
?>--<?php
|
||||
echo $this->get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:customlocale', ['_locale' => 'es']));
|
||||
?>--<?php
|
||||
$app->getRequest()->setLocale('fr');
|
||||
echo $this->get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:forwardlocale'));
|
||||
?>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
];
|
||||
@@ -0,0 +1,10 @@
|
||||
imports:
|
||||
- { resource: ../config/default.yml }
|
||||
|
||||
services:
|
||||
_defaults: { public: true }
|
||||
test.property_info: '@property_info'
|
||||
|
||||
framework:
|
||||
serializer: { enabled: true }
|
||||
property_info: { enabled: true }
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
|
||||
|
||||
return [
|
||||
new FrameworkBundle(),
|
||||
new TestBundle(),
|
||||
];
|
||||
@@ -0,0 +1,7 @@
|
||||
imports:
|
||||
- { resource: ./../config/default.yml }
|
||||
|
||||
services:
|
||||
Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SubRequestController:
|
||||
tags:
|
||||
- { name: controller.service_arguments, action: indexAction, argument: handler, id: fragment.handler }
|
||||
@@ -0,0 +1,2 @@
|
||||
_sessiontest_bundle:
|
||||
resource: '@TestBundle/Resources/config/routing.yml'
|
||||
@@ -0,0 +1,2 @@
|
||||
imports:
|
||||
- { resource: framework.yml }
|
||||
@@ -0,0 +1,13 @@
|
||||
framework:
|
||||
secret: test
|
||||
router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" }
|
||||
validation: { enabled: true, enable_annotations: true }
|
||||
csrf_protection: true
|
||||
form: true
|
||||
test: ~
|
||||
default_locale: en
|
||||
session:
|
||||
storage_id: session.storage.mock_file
|
||||
|
||||
services:
|
||||
logger: { class: Psr\Log\NullLogger }
|
||||
Reference in New Issue
Block a user