DummyController example

$response = $this->createResponse();
        $this->injectController($c$callable$request);
        $c->collect($request$response);
        $c->lateCollect();

        $this->assertSame($expected$c->getController()->getValue(true)sprintf('Testing: %s', $name));
    }

    public static function provideControllerCallables(): array
    {
        // make sure we always match the line number         $controller = new DummyController();

        $r1 = new \ReflectionMethod($controller, 'regularCallable');
        $r2 = new \ReflectionMethod($controller, 'staticControllerMethod');
        $r3 = new \ReflectionClass($controller);

        // test name, callable, expected         return [
            [
                '"Regular" callable',
                [$controller, 'regularCallable'],
                [
                    
$this->assertSame([$controller, 'fooAction']$resolver->getController($request));
        $this->assertSame($container$controller->setContainer($container));
    }

    public function testAbstractControllerServiceWithFqcnIdGetsContainerWhenNotSet()
    {
        $this->expectException(\LogicException::class);
        $this->expectExceptionMessage('"Symfony\\Bundle\\FrameworkBundle\\Tests\\Controller\\DummyController" has no container set, did you forget to define it as a service subscriber?');

        class_exists(AbstractControllerTest::class);

        $controller = new DummyController();

        $container = new Container();
        $container->set(DummyController::class$controller);

        $resolver = $this->createControllerResolver(null, $container);

        $request = Request::create('/');
        $request->attributes->set('_controller', DummyController::class.'::fooAction');

        $this->assertSame([$controller, 'fooAction']$resolver->getController($request));
        $this->assertSame($container$controller->getContainer());
    }
Home | Imprint | This part of the site doesn't use cookies.