BatchNegotiatorTest.php

Same filename and directory in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Batch/BatchNegotiatorTest.php
  2. 11.x core/tests/Drupal/KernelTests/Core/Batch/BatchNegotiatorTest.php

Namespace

Drupal\KernelTests\Core\Batch

File

core/tests/Drupal/KernelTests/Core/Batch/BatchNegotiatorTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\KernelTests\Core\Batch;

use Drupal\Core\Routing\RouteMatch;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\HttpFoundation\Request;

/**
 * Tests the BatchNegotiator.
 *
 * @group Batch
 */
class BatchNegotiatorTest extends KernelTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'system',
    ];
    
    /**
     * Test that the negotiator applies to the batch route.
     */
    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));
    }

}

Classes

Title Deprecated Summary
BatchNegotiatorTest Tests the BatchNegotiator.

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