function ContextDefinitionTest::testGetConstraint

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Plugin/Context/ContextDefinitionTest.php \Drupal\Tests\Core\Plugin\Context\ContextDefinitionTest::testGetConstraint()
  2. 8.9.x core/tests/Drupal/Tests/Core/Plugin/Context/ContextDefinitionTest.php \Drupal\Tests\Core\Plugin\Context\ContextDefinitionTest::testGetConstraint()
  3. 10 core/tests/Drupal/Tests/Core/Plugin/Context/ContextDefinitionTest.php \Drupal\Tests\Core\Plugin\Context\ContextDefinitionTest::testGetConstraint()

@dataProvider providerGetConstraint @covers ::getConstraint @uses \Drupal

File

core/tests/Drupal/Tests/Core/Plugin/Context/ContextDefinitionTest.php, line 175

Class

ContextDefinitionTest
Tests the ContextDefinition class.

Namespace

Drupal\Tests\Core\Plugin\Context

Code

public function testGetConstraint($expected, $constraint_array, $constraint) : void {
    $mock_context_definition = $this->getMockBuilder('Drupal\\Core\\Plugin\\Context\\ContextDefinition')
        ->disableOriginalConstructor()
        ->onlyMethods([
        'getConstraints',
    ])
        ->getMock();
    $mock_context_definition->expects($this->once())
        ->method('getConstraints')
        ->willReturn($constraint_array);
    $this->assertEquals($expected, $mock_context_definition->getConstraint($constraint));
}

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