Skip to content
Snippets Groups Projects
Commit cfabfbe8 authored by catch's avatar catch
Browse files

Issue #3419288 by longwave: Remove withConsecutive() in RouteBuilderTest

parent 10322daf
No related branches found
No related tags found
No related merge requests found
......@@ -3382,11 +3382,6 @@ parameters:
count: 1
path: tests/Drupal/Tests/Core/Render/ElementTest.php
-
message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
count: 3
path: tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php
-
message: """
#^Call to deprecated method expectWarning\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\:
......
......@@ -11,6 +11,7 @@
use Drupal\Core\Routing\RouteCompiler;
use Drupal\Core\Routing\RoutingEvents;
use Drupal\Tests\UnitTestCase;
use Prophecy\Argument;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
......@@ -44,7 +45,7 @@ class RouteBuilderTest extends UnitTestCase {
/**
* The mocked event dispatcher.
*
* @var \Symfony\Contracts\EventDispatcher\EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject
* @var \Symfony\Contracts\EventDispatcher\EventDispatcherInterface|\Prophecy\Prophecy\ObjectProphecy
*/
protected $dispatcher;
......@@ -82,7 +83,8 @@ protected function setUp(): void {
$this->dumper = $this->createMock('Drupal\Core\Routing\MatcherDumperInterface');
$this->lock = $this->createMock('Drupal\Core\Lock\LockBackendInterface');
$this->dispatcher = $this->createMock('\Symfony\Contracts\EventDispatcher\EventDispatcherInterface');
$this->dispatcher = $this->prophesize('\Symfony\Contracts\EventDispatcher\EventDispatcherInterface');
$this->dispatcher->dispatch(Argument::cetera(), Argument::cetera())->willReturnArgument(0);
$this->moduleHandler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->controllerResolver = $this->createMock('Drupal\Core\Controller\ControllerResolverInterface');
$this->yamlDiscovery = $this->getMockBuilder('\Drupal\Core\Discovery\YamlDiscovery')
......@@ -90,7 +92,7 @@ protected function setUp(): void {
->getMock();
$this->checkProvider = $this->createMock('\Drupal\Core\Access\CheckProviderInterface');
$this->routeBuilder = new TestRouteBuilder($this->dumper, $this->lock, $this->dispatcher, $this->moduleHandler, $this->controllerResolver, $this->checkProvider);
$this->routeBuilder = new TestRouteBuilder($this->dumper, $this->lock, $this->dispatcher->reveal(), $this->moduleHandler, $this->controllerResolver, $this->checkProvider);
$this->routeBuilder->setYamlDiscovery($this->yamlDiscovery);
}
......@@ -161,12 +163,10 @@ public function testRebuildWithStaticModuleRoutes() {
$route_build_event = new RouteBuildEvent($route_collection);
// Ensure that the alter routes events are fired.
$this->dispatcher->expects($this->atLeast(2))
->method('dispatch')
->withConsecutive(
[$route_build_event, RoutingEvents::DYNAMIC],
[$route_build_event, RoutingEvents::ALTER],
);
$this->dispatcher->dispatch($route_build_event, RoutingEvents::DYNAMIC)
->shouldBeCalled();
$this->dispatcher->dispatch($route_build_event, RoutingEvents::ALTER)
->shouldBeCalled();
// Ensure that access checks are set.
$this->checkProvider->expects($this->once())
......@@ -231,12 +231,10 @@ public function testRebuildWithProviderBasedRoutes() {
$route_build_event = new RouteBuildEvent($route_collection_filled);
// Ensure that the alter routes events are fired.
$this->dispatcher->expects($this->atLeast(2))
->method('dispatch')
->withConsecutive(
[$route_build_event, RoutingEvents::DYNAMIC],
[$route_build_event, RoutingEvents::ALTER],
);
$this->dispatcher->dispatch($route_build_event, RoutingEvents::DYNAMIC)
->shouldBeCalled();
$this->dispatcher->dispatch($route_build_event, RoutingEvents::ALTER)
->shouldBeCalled();
// Ensure that access checks are set.
$this->checkProvider->expects($this->once())
......@@ -313,12 +311,10 @@ public function testRebuildWithOverriddenRouteClass() {
$route_collection_filled->add('test_route.override', new Route('/test_route_override', [], [], ['compiler_class' => 'Class\Does\Not\Exist']));
$route_collection_filled->add('test_route', new Route('/test_route', [], [], ['compiler_class' => RouteCompiler::class]));
$route_build_event = new RouteBuildEvent($route_collection_filled);
$this->dispatcher->expects($this->atLeast(2))
->method('dispatch')
->withConsecutive(
[$route_build_event, RoutingEvents::DYNAMIC],
[$route_build_event, RoutingEvents::ALTER],
);
$this->dispatcher->dispatch($route_build_event, RoutingEvents::DYNAMIC)
->shouldBeCalled();
$this->dispatcher->dispatch($route_build_event, RoutingEvents::ALTER)
->shouldBeCalled();
$this->assertTrue($this->routeBuilder->rebuild());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment