function BatchNegotiatorTest::testApplies

Same name and namespace in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Batch/BatchNegotiatorTest.php \Drupal\KernelTests\Core\Batch\BatchNegotiatorTest::testApplies()
  2. 11.x core/tests/Drupal/KernelTests/Core/Batch/BatchNegotiatorTest.php \Drupal\KernelTests\Core\Batch\BatchNegotiatorTest::testApplies()

Test that the negotiator applies to the batch route.

File

core/tests/Drupal/KernelTests/Core/Batch/BatchNegotiatorTest.php, line 28

Class

BatchNegotiatorTest
Tests the BatchNegotiator.

Namespace

Drupal\KernelTests\Core\Batch

Code

public function testApplies() {
    $request = Request::create('/batch');
    // Use the router to enhance the object so that a RouteMatch can be created.
    $this->container
        ->get('router')
        ->matchRequest($request);
    $routeMatch = RouteMatch::createFromRequest($request);
    // The negotiator under test.
    $negotiator = $this->container
        ->get('theme.negotiator.system.batch');
    $this->assertTrue($negotiator->applies($routeMatch));
}

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