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:
Pierre Goiffon
2020-01-10 15:15:15 +01:00
parent 881fc2a1de
commit ad821e7d9c
2086 changed files with 151849 additions and 6 deletions

View File

@@ -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;
}
}

View File

@@ -0,0 +1,51 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\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);
}
}

View File

@@ -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;
}
}

View File

@@ -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');
}
}

View File

@@ -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);
}
}

View File

@@ -0,0 +1,66 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\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);
}
}

View File

@@ -0,0 +1,38 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\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('---');
}
}

View File

@@ -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');
}
}

View File

@@ -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()
;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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] }

View File

@@ -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);
}
}