You are here

public function EntityContextDefinitionDeprecationTest::testSerialization in Drupal 8

Test that the BC layer survives serialization and unserialization.

@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 81

Class

EntityContextDefinitionDeprecationTest
Test deprecated use of ContextDefinition as an EntityContextDefinition.

Namespace

Drupal\Tests\Core\Plugin\Context

Code

public function testSerialization() {
  $this->definition
    ->addConstraint('foo');
  $definition = unserialize(serialize($this->definition));
  $this
    ->assertEquals([
    'foo' => NULL,
  ], $definition
    ->getConstraints());
  $bc_layer = $this->compatibilityLayer
    ->getValue($definition);
  $this
    ->assertInstanceOf(EntityContextDefinition::class, $bc_layer);
}