function ExtensionSerializationTest::testPublicProperties
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Extension/ExtensionSerializationTest.php \Drupal\Tests\Core\Extension\ExtensionSerializationTest::testPublicProperties()
- 10 core/tests/Drupal/Tests/Core/Extension/ExtensionSerializationTest.php \Drupal\Tests\Core\Extension\ExtensionSerializationTest::testPublicProperties()
- 11.x 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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.