function EntityContextDefinitionDeprecationTest::testAddConstraint
Test that addConstraint() proxies to the compatibility layer.
@covers ::addConstraint @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 156
Class
- EntityContextDefinitionDeprecationTest
- Test deprecated use of ContextDefinition as an EntityContextDefinition.
Namespace
Drupal\Tests\Core\Plugin\ContextCode
public function testAddConstraint() {
$bc_mock = $this->getMockBuilder(EntityContextDefinition::class)
->setMethods([
'addConstraint',
])
->getMock();
$options = [
'options',
];
$bc_mock->expects($this->once())
->method('addConstraint')
->with('constraint_name', $options)
->willReturnSelf();
$this->compatibilityLayer
->setValue($this->definition, $bc_mock);
$this->assertSame($this->definition, $this->definition
->addConstraint('constraint_name', $options));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.