SebastiaanLuca\Router\Tests\ExtendedRouterTest::testItRegistersMiddlewareForMultipleRoutes PHP Method

testItRegistersMiddlewareForMultipleRoutes() public method

    public function testItRegistersMiddlewareForMultipleRoutes()
    {
        $router = $this->createExtendedRouter(false);
        // Pretend the application has fully booted and
        // allow actual registration of middleware
        $this->setValueOfInternalProperty($router, 'isBootstrapped', true);
        // Use the real method instead of mocking it
        $router->shouldReceive('registerNamedRouteMiddleware')->passthru();
        // Auto-mocked method which we're expecting to get called
        $router->shouldReceive('addMiddlewareToRoute')->with('route1', ['middleware'])->once();
        $router->shouldReceive('addMiddlewareToRoute')->with('route2', ['middleware'])->once();
        $router->shouldReceive('addMiddlewareToRoute')->with('route3', ['middleware'])->once();
        // Kick-off
        $router->registerNamedRouteMiddleware(['route1', 'route2', 'route3'], 'middleware');
    }