// Test the view storage object is not present in the actual serialized
// string.
$this->
assertStringNotContainsString('"Drupal\views\Entity\View"',
$serialized, 'The Drupal\views\Entity\View class was not found in the serialized string.'
);
/** @var \Drupal\views\ViewExecutable $unserialized */
$unserialized =
unserialize($serialized);
$this->
assertInstanceOf(ViewExecutable::
class,
$unserialized);
$this->
assertSame($unserialized->storage->
id(),
$view->storage->
id(), 'The expected storage entity was loaded on the unserialized view.'
);
$this->
assertSame('page_1',
$unserialized->current_display, 'The expected display was set on the unserialized view.'
);
$this->
assertSame(['test'
],
$unserialized->args, 'The expected argument was set on the unserialized view.'
);
$this->
assertSame(2,
$unserialized->
getCurrentPage(), 'The expected current page was set on the unserialized view.'
);
// Get the definition of node's nid field, for example. Only get it not from
// the field manager directly, but from the item data definition. It should
// be the same base field definition object (the field and item definitions
// refer to each other).
// See https://bugs.php.net/bug.php?id=66052
$field_manager =
$this->container->
get('entity_field.manager'
);
$nid_definition_before =
$field_manager->
getBaseFieldDefinitions('node'
)['nid'
] ->
getItemDefinition() ->
getFieldDefinition();