function ContextHandlerTest::testCheckRequirements

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php \Drupal\Tests\Core\Plugin\ContextHandlerTest::testCheckRequirements()
  2. 8.9.x core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php \Drupal\Tests\Core\Plugin\ContextHandlerTest::testCheckRequirements()
  3. 11.x core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php \Drupal\Tests\Core\Plugin\ContextHandlerTest::testCheckRequirements()

@covers ::checkRequirements

@dataProvider providerTestCheckRequirements

File

core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php, line 73

Class

ContextHandlerTest
@coversDefaultClass \Drupal\Core\Plugin\Context\ContextHandler @group Plugin

Namespace

Drupal\Tests\Core\Plugin

Code

public function testCheckRequirements($contexts, $requirements, $expected) : void {
    $contexts = array_map(function ($context) {
        $mock = $this->createMock('Drupal\\Core\\Plugin\\Context\\ContextInterface');
        $mock->expects($this->atLeastOnce())
            ->method('getContextDefinition')
            ->willReturn($context);
        return $mock;
    }, $contexts);
    $this->assertSame($expected, $this->contextHandler
        ->checkRequirements($contexts, $requirements));
}

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