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()
Same name and namespace 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/Tests/Core/Theme/Component/ComponentNegotiatorTest.php, line 35

Class

ComponentNegotiatorTest
Tests the component negotiator.

Namespace

Drupal\Tests\Core\Theme\Component

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.