public function EntityContextDefinitionDeprecationTest::testSetConstraints in Drupal 8
Test that setConstraints() proxies to the compatibility layer.
@covers ::setConstraints @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 135
Class
- EntityContextDefinitionDeprecationTest
- Test deprecated use of ContextDefinition as an EntityContextDefinition.
Namespace
Drupal\Tests\Core\Plugin\ContextCode
public function testSetConstraints() {
$bc_mock = $this
->getMockBuilder(EntityContextDefinition::class)
->setMethods([
'setConstraints',
])
->getMock();
$constraints = [
'TestConstraint' => [],
];
$bc_mock
->expects($this
->once())
->method('setConstraints')
->with($constraints)
->willReturnSelf();
$this->compatibilityLayer
->setValue($this->definition, $bc_mock);
$this
->assertSame($this->definition, $this->definition
->setConstraints($constraints));
}