You are here

public function EntityContextDefinitionDeprecationTest::testGetConstraintObjects in Drupal 8

Test that getConstraintObjects() adds the EntityType constraint.

@covers ::getConstraintObjects @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 197

Class

EntityContextDefinitionDeprecationTest
Test deprecated use of ContextDefinition as an EntityContextDefinition.

Namespace

Drupal\Tests\Core\Plugin\Context

Code

public function testGetConstraintObjects() {
  $reflector = new \ReflectionObject($this->definition);
  $method = $reflector
    ->getMethod('getConstraintObjects');
  $method
    ->setAccessible(TRUE);
  $this
    ->assertArrayHasKey('EntityType', $method
    ->invoke($this->definition));
}