function EntityMaskTest::testSerialization

Same name in other branches
  1. 8.x-3.x modules/ctools_entity_mask/tests/src/Kernel/EntityMaskTest.php \Drupal\Tests\ctools_entity_mask\Kernel\EntityMaskTest::testSerialization()

Asserts that a mask entity can be serialized and de-serialized coherently.

@depends testFields

File

modules/ctools_entity_mask/tests/src/Kernel/EntityMaskTest.php, line 144

Class

EntityMaskTest
Basic test of entity type masking.

Namespace

Drupal\Tests\ctools_entity_mask\Kernel

Code

public function testSerialization() {
    $body = $this->getRandomGenerator()
        ->paragraphs(2);
    $link = 'https://www.drupal.org/project/ctools';
    
    /** @var \Drupal\Core\Entity\EntityInterface $block */
    $block = BlockContent::create([
        'type' => 'basic',
        'body' => $body,
        'field_link' => $link,
    ]);
    $block = serialize($block);
    $block = unserialize($block);
    $this->assertSame($body, $block->body->value);
    $this->assertSame($link, $block->field_link->uri);
}