public function ViewUIObjectTest::testSerialization in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php \Drupal\Tests\views_ui\Unit\ViewUIObjectTest::testSerialization()
Tests serialization of the ViewUI object.
File
- core/
modules/ views_ui/ tests/ src/ Unit/ ViewUIObjectTest.php, line 120 - Contains \Drupal\Tests\views_ui\Unit\ViewUIObjectTest.
Class
- ViewUIObjectTest
- @coversDefaultClass \Drupal\views_ui\ViewUI @group views_ui
Namespace
Drupal\Tests\views_ui\UnitCode
public function testSerialization() {
// Set a container so the DependencySerializationTrait has it.
$container = new ContainerBuilder();
\Drupal::setContainer($container);
$storage = new View([], 'view');
$executable = $this
->getMockBuilder('Drupal\\views\\ViewExecutable')
->disableOriginalConstructor()
->setConstructorArgs([
$storage,
])
->getMock();
$storage
->set('executable', $executable);
$view_ui = new ViewUI($storage);
// Make sure the executable is returned before serializing.
$this
->assertInstanceOf('Drupal\\views\\ViewExecutable', $view_ui
->getExecutable());
$serialized = serialize($view_ui);
// Make sure the ViewExecutable class is not found in the serialized string.
$this
->assertSame(strpos($serialized, '"Drupal\\views\\ViewExecutable"'), FALSE);
$unserialized = unserialize($serialized);
$this
->assertInstanceOf('Drupal\\views_ui\\ViewUI', $unserialized);
}