public function SerializationTest::testPageBlockVariantPlugin in Page Manager 8.4
Same name and namespace in other branches
- 8 tests/src/Kernel/SerializationTest.php \Drupal\Tests\page_manager\Kernel\SerializationTest::testPageBlockVariantPlugin()
Test serialization of a block_display variant plugin.
File
- tests/
src/ Kernel/ SerializationTest.php, line 205
Class
- SerializationTest
- Tests the serialization of the entities we provide.
Namespace
Drupal\Tests\page_manager\KernelCode
public function testPageBlockVariantPlugin() {
$configuration = [
'page_title' => 'Test variant',
];
/* @var \Drupal\page_manager\Plugin\DisplayVariant\PageBlockDisplayVariant $variant_plugin */
$variant_plugin = $this->container
->get('plugin.manager.display_variant')
->createInstance('block_display', $configuration);
$this
->assertInstanceOf(PageBlockDisplayVariant::class, $variant_plugin);
// Test that a very simple variant successfully serializes.
/* @var \Drupal\page_manager\Plugin\DisplayVariant\PageBlockDisplayVariant $unserialized */
$unserialized = $this
->assertSerialization($variant_plugin);
$this
->assertEquals($variant_plugin
->getConfiguration(), $unserialized
->getConfiguration());
// Set some context.
$context = new Context(new ContextDefinition('integer', 'ID'), 1);
$variant_plugin
->setContexts([
'id' => $context,
]);
$unserialized = $this
->assertSerialization($variant_plugin);
$this
->assertEquals([], $unserialized
->getContexts());
}