public function ExtensionSerializationTest::testPublicProperties in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Extension/ExtensionSerializationTest.php \Drupal\Tests\Core\Extension\ExtensionSerializationTest::testPublicProperties()
Tests dynamically assigned public properties kept when serialized.
@covers ::__sleep @covers ::__wakeup
File
- core/
tests/ Drupal/ Tests/ Core/ Extension/ ExtensionSerializationTest.php, line 65
Class
- ExtensionSerializationTest
- Tests Extension serialization.
Namespace
Drupal\Tests\Core\ExtensionCode
public function testPublicProperties() {
$container = new ContainerBuilder();
// Set a dummy container app.root to test against.
$container
->set('app.root', 'vfs://dummy_app_root');
\Drupal::setContainer($container);
$extension = new Extension($container
->get('app.root'), 'module', 'core/modules/system/system.info.yml', 'system.module');
// Assign a public property dynamically.
$extension->test = 'foo';
$extension = unserialize(serialize($extension));
$this
->assertSame('foo', $extension->test);
}