function ControllerResolverTest::assertCallableController

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php \Drupal\Tests\Core\Controller\ControllerResolverTest::assertCallableController()
  2. 10 core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php \Drupal\Tests\Core\Controller\ControllerResolverTest::assertCallableController()
  3. 11.x core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php \Drupal\Tests\Core\Controller\ControllerResolverTest::assertCallableController()

Asserts that the controller is callable and produces the correct output.

@internal

Parameters

callable $controller: A callable controller.

string|null $class: Either the name of the class the controller represents, or NULL if it is not an object.

string|null $output: The output expected for this controller.

3 calls to ControllerResolverTest::assertCallableController()
ControllerResolverTest::testCreateController in core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php
Tests createController().
ControllerResolverTest::testGetController in core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php
Tests getController().
ControllerResolverTest::testGetControllerFromDefinition in core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php
Tests getControllerFromDefinition().

File

core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php, line 188

Class

ControllerResolverTest
@coversDefaultClass \Drupal\Core\Controller\ControllerResolver @group Controller

Namespace

Drupal\Tests\Core\Controller

Code

protected function assertCallableController(callable $controller, ?string $class, ?string $output) : void {
    if ($class) {
        $this->assertIsObject($controller[0]);
        $this->assertInstanceOf($class, $controller[0]);
    }
    $this->assertIsCallable($controller);
    $this->assertSame($output, call_user_func($controller));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.