function EntityContextDefinitionDeprecationTest::testGetConstraint
Test that getConstraint() proxies to the compatibility layer.
@covers ::getConstraint @expectedDeprecation Constructing a ContextDefinition object for an entity type is deprecated in Drupal 8.6.0. Use Drupal\Core\Plugin\Context\EntityContextDefinition instead. See https://www.drupal.org/node/2976400 for more information.
File
-
core/
tests/ Drupal/ Tests/ Core/ Plugin/ Context/ EntityContextDefinitionDeprecationTest.php, line 115
Class
- EntityContextDefinitionDeprecationTest
- Test deprecated use of ContextDefinition as an EntityContextDefinition.
Namespace
Drupal\Tests\Core\Plugin\ContextCode
public function testGetConstraint() {
$bc_mock = $this->getMockBuilder(EntityContextDefinition::class)
->setMethods([
'getConstraint',
])
->getMock();
$bc_mock->expects($this->once())
->method('getConstraint')
->with('constraint_name')
->willReturn('test_constraint');
$this->compatibilityLayer
->setValue($this->definition, $bc_mock);
$this->assertSame('test_constraint', $this->definition
->getConstraint('constraint_name'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.