Laravel 5.6 updates

Travis config update

Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
Manish Verma
2018-08-06 20:08:55 +05:30
parent 126fbb0255
commit 1ac0f42a58
2464 changed files with 65239 additions and 46734 deletions

View File

@@ -13,15 +13,20 @@ namespace Symfony\Component\HttpKernel\Tests\Controller;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver;
class ContainerControllerResolverTest extends ControllerResolverTest
{
public function testGetControllerService()
/**
* @group legacy
* @expectedDeprecation Referencing controllers with a single colon is deprecated since Symfony 4.1. Use foo::action instead.
*/
public function testGetControllerServiceWithSingleColon()
{
$service = new ControllerTestService('foo');
$container = $this->createMockContainer();
$container->expects($this->once())
->method('has')
@@ -30,22 +35,47 @@ class ContainerControllerResolverTest extends ControllerResolverTest
$container->expects($this->once())
->method('get')
->with('foo')
->will($this->returnValue($this))
->will($this->returnValue($service))
;
$resolver = $this->createControllerResolver(null, $container);
$request = Request::create('/');
$request->attributes->set('_controller', 'foo:controllerMethod1');
$request->attributes->set('_controller', 'foo:action');
$controller = $resolver->getController($request);
$this->assertInstanceOf(\get_class($this), $controller[0]);
$this->assertSame('controllerMethod1', $controller[1]);
$this->assertSame($service, $controller[0]);
$this->assertSame('action', $controller[1]);
}
public function testGetControllerService()
{
$service = new ControllerTestService('foo');
$container = $this->createMockContainer();
$container->expects($this->once())
->method('has')
->with('foo')
->will($this->returnValue(true));
$container->expects($this->once())
->method('get')
->with('foo')
->will($this->returnValue($service))
;
$resolver = $this->createControllerResolver(null, $container);
$request = Request::create('/');
$request->attributes->set('_controller', 'foo::action');
$controller = $resolver->getController($request);
$this->assertSame($service, $controller[0]);
$this->assertSame('action', $controller[1]);
}
public function testGetControllerInvokableService()
{
$invokableController = new InvokableController('bar');
$service = new InvokableControllerService('bar');
$container = $this->createMockContainer();
$container->expects($this->once())
@@ -56,7 +86,7 @@ class ContainerControllerResolverTest extends ControllerResolverTest
$container->expects($this->once())
->method('get')
->with('foo')
->will($this->returnValue($invokableController))
->will($this->returnValue($service))
;
$resolver = $this->createControllerResolver(null, $container);
@@ -65,128 +95,72 @@ class ContainerControllerResolverTest extends ControllerResolverTest
$controller = $resolver->getController($request);
$this->assertEquals($invokableController, $controller);
$this->assertSame($service, $controller);
}
public function testGetControllerInvokableServiceWithClassNameAsName()
{
$invokableController = new InvokableController('bar');
$className = __NAMESPACE__.'\InvokableController';
$service = new InvokableControllerService('bar');
$container = $this->createMockContainer();
$container->expects($this->once())
->method('has')
->with($className)
->with(InvokableControllerService::class)
->will($this->returnValue(true))
;
$container->expects($this->once())
->method('get')
->with($className)
->will($this->returnValue($invokableController))
->with(InvokableControllerService::class)
->will($this->returnValue($service))
;
$resolver = $this->createControllerResolver(null, $container);
$request = Request::create('/');
$request->attributes->set('_controller', $className);
$request->attributes->set('_controller', InvokableControllerService::class);
$controller = $resolver->getController($request);
$this->assertEquals($invokableController, $controller);
}
public function testNonInstantiableController()
{
$container = $this->createMockContainer();
$container->expects($this->once())
->method('has')
->with(NonInstantiableController::class)
->will($this->returnValue(false))
;
$resolver = $this->createControllerResolver(null, $container);
$request = Request::create('/');
$request->attributes->set('_controller', array(NonInstantiableController::class, 'action'));
$controller = $resolver->getController($request);
$this->assertSame(array(NonInstantiableController::class, 'action'), $controller);
$this->assertSame($service, $controller);
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage Controller "Symfony\Component\HttpKernel\Tests\Controller\ImpossibleConstructController" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?
* Tests where the fallback instantiation fails due to required constructor arguments.
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?
*/
public function testNonConstructController()
public function testExceptionWhenUsingRemovedControllerServiceWithClassNameAsName()
{
$container = $this->getMockBuilder(Container::class)->getMock();
$container->expects($this->at(0))
$container->expects($this->once())
->method('has')
->with(ImpossibleConstructController::class)
->will($this->returnValue(true))
;
$container->expects($this->at(1))
->method('has')
->with(ImpossibleConstructController::class)
->with(ControllerTestService::class)
->will($this->returnValue(false))
;
$container->expects($this->atLeastOnce())
->method('getRemovedIds')
->with()
->will($this->returnValue(array(ImpossibleConstructController::class => true)))
->will($this->returnValue(array(ControllerTestService::class => true)))
;
$resolver = $this->createControllerResolver(null, $container);
$request = Request::create('/');
$request->attributes->set('_controller', array(ImpossibleConstructController::class, 'action'));
$request->attributes->set('_controller', array(ControllerTestService::class, 'action'));
if (\PHP_VERSION_ID < 70100) {
ErrorHandler::register();
try {
$resolver->getController($request);
} finally {
restore_error_handler();
restore_exception_handler();
}
} else {
$resolver->getController($request);
}
}
public function testNonInstantiableControllerWithCorrespondingService()
{
$service = new \stdClass();
$container = $this->createMockContainer();
$container->expects($this->atLeastOnce())
->method('has')
->with(NonInstantiableController::class)
->will($this->returnValue(true))
;
$container->expects($this->atLeastOnce())
->method('get')
->with(NonInstantiableController::class)
->will($this->returnValue($service))
;
$resolver = $this->createControllerResolver(null, $container);
$request = Request::create('/');
$request->attributes->set('_controller', array(NonInstantiableController::class, 'action'));
$controller = $resolver->getController($request);
$this->assertSame(array($service, 'action'), $controller);
$resolver->getController($request);
}
/**
* @expectedException \LogicException
* Tests where the fallback instantiation fails due to non-existing class.
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Controller "app.my_controller" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?
*/
public function testExceptionWhenUsingRemovedControllerService()
{
$container = $this->getMockBuilder(Container::class)->getMock();
$container->expects($this->at(0))
$container->expects($this->once())
->method('has')
->with('app.my_controller')
->will($this->returnValue(false))
@@ -205,62 +179,28 @@ class ContainerControllerResolverTest extends ControllerResolverTest
$resolver->getController($request);
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage Controller "app.my_controller" cannot be called without a method name. Did you forget an "__invoke" method?
*/
public function testExceptionWhenUsingControllerWithoutAnInvokeMethod()
{
$container = $this->getMockBuilder(Container::class)->getMock();
$container->expects($this->once())
->method('has')
->with('app.my_controller')
->will($this->returnValue(true))
;
$container->expects($this->once())
->method('get')
->with('app.my_controller')
->will($this->returnValue(new ImpossibleConstructController('toto', 'controller')))
;
$resolver = $this->createControllerResolver(null, $container);
$request = Request::create('/');
$request->attributes->set('_controller', 'app.my_controller');
$resolver->getController($request);
}
/**
* @dataProvider getUndefinedControllers
*/
public function testGetControllerOnNonUndefinedFunction($controller, $exceptionName = null, $exceptionMessage = null)
{
// All this logic needs to be duplicated, since calling parent::testGetControllerOnNonUndefinedFunction will override the expected excetion and not use the regex
$resolver = $this->createControllerResolver();
if (method_exists($this, 'expectException')) {
$this->expectException($exceptionName);
$this->expectExceptionMessageRegExp($exceptionMessage);
} else {
$this->setExpectedExceptionRegExp($exceptionName, $exceptionMessage);
}
$request = Request::create('/');
$request->attributes->set('_controller', $controller);
$resolver->getController($request);
}
public function getUndefinedControllers()
{
return array(
array('foo', \LogicException::class, '/Controller not found: service "foo" does not exist\./'),
array('oof::bar', \InvalidArgumentException::class, '/Class "oof" does not exist\./'),
array('stdClass', \LogicException::class, '/Controller not found: service "stdClass" does not exist\./'),
array(
'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest::bar',
\InvalidArgumentException::class,
'/.?[cC]ontroller(.*?) for URI "\/" is not callable\.( Expected method(.*) Available methods)?/',
),
$tests = parent::getUndefinedControllers();
$tests[0] = array('foo', \InvalidArgumentException::class, 'Controller "foo" does neither exist as service nor as class');
$tests[1] = array('oof::bar', \InvalidArgumentException::class, 'Controller "oof" does neither exist as service nor as class');
$tests[2] = array(array('oof', 'bar'), \InvalidArgumentException::class, 'Controller "oof" does neither exist as service nor as class');
$tests[] = array(
array(ControllerTestService::class, 'action'),
\InvalidArgumentException::class,
'Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" has required constructor arguments and does not exist in the container. Did you forget to define such a service?',
);
$tests[] = array(
ControllerTestService::class.'::action',
\InvalidArgumentException::class, 'Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" has required constructor arguments and does not exist in the container. Did you forget to define such a service?',
);
$tests[] = array(
InvokableControllerService::class,
\InvalidArgumentException::class,
'Controller "Symfony\Component\HttpKernel\Tests\Controller\InvokableControllerService" has required constructor arguments and does not exist in the container. Did you forget to define such a service?',
);
return $tests;
}
protected function createControllerResolver(LoggerInterface $logger = null, ContainerInterface $container = null)
@@ -278,7 +218,7 @@ class ContainerControllerResolverTest extends ControllerResolverTest
}
}
class InvokableController
class InvokableControllerService
{
public function __construct($bar) // mandatory argument to prevent automatic instantiation
{
@@ -289,16 +229,9 @@ class InvokableController
}
}
abstract class NonInstantiableController
class ControllerTestService
{
public static function action()
{
}
}
class ImpossibleConstructController
{
public function __construct($toto, $controller)
public function __construct($foo)
{
}