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