function ComponentNegotiatorTest::testNegotiate

Same name in this branch
  1. 11.x core/modules/sdc/tests/src/Kernel/ComponentNegotiatorTest.php \Drupal\Tests\sdc\Kernel\ComponentNegotiatorTest::testNegotiate()
  2. 11.x core/tests/Drupal/Tests/Core/Theme/Component/ComponentNegotiatorTest.php \Drupal\Tests\Core\Theme\Component\ComponentNegotiatorTest::testNegotiate()
Same name in other branches
  1. 10 core/modules/sdc/tests/src/Kernel/ComponentNegotiatorTest.php \Drupal\Tests\sdc\Kernel\ComponentNegotiatorTest::testNegotiate()
  2. 10 core/tests/Drupal/Tests/Core/Theme/Component/ComponentNegotiatorTest.php \Drupal\Tests\Core\Theme\Component\ComponentNegotiatorTest::testNegotiate()

@covers ::negotiate

File

core/tests/Drupal/KernelTests/Components/ComponentNegotiatorTest.php, line 35

Class

ComponentNegotiatorTest
Tests the component negotiator.

Namespace

Drupal\KernelTests\Components

Code

public function testNegotiate() : void {
    $data = [
        [
            'sdc_test:my-banner',
            NULL,
        ],
        [
            'sdc_theme_test:my-card',
            'sdc_theme_test_enforce_schema:my-card',
        ],
        [
            'sdc_test:my-button',
            'sdc_test_replacements:my-button',
        ],
        [
            'invalid:component',
            NULL,
        ],
        [
            'invalid^component',
            NULL,
        ],
        [
            '',
            NULL,
        ],
    ];
    array_walk($data, function ($test_input) {
        [
            $requested_id,
            $expected_id,
        ] = $test_input;
        $negotiated_id = $this->negotiator
            ->negotiate($requested_id, $this->manager
            ->getDefinitions());
        $this->assertSame($expected_id, $negotiated_id);
    });
}

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