public function DependencySerializationTest::testSerialization in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/DependencyInjection/DependencySerializationTest.php \Drupal\Tests\Core\DependencyInjection\DependencySerializationTest::testSerialization()
@covers ::__sleep @covers ::__wakeup
File
- core/
tests/ Drupal/ Tests/ Core/ DependencyInjection/ DependencySerializationTest.php, line 26 - Contains \Drupal\Tests\Core\DependencyInjection\DependencySerializationTest.
Class
- DependencySerializationTest
- @coversDefaultClass \Drupal\Core\DependencyInjection\DependencySerializationTrait @group DependencyInjection
Namespace
Drupal\Tests\Core\DependencyInjectionCode
public function testSerialization() {
// Create a pseudo service and dependency injected object.
$service = new \stdClass();
$service->_serviceId = 'test_service';
$container = new Container();
$container
->set('test_service', $service);
$container
->set('service_container', $container);
\Drupal::setContainer($container);
$dependencySerialization = new DependencySerializationTestDummy($service);
$dependencySerialization
->setContainer($container);
$string = serialize($dependencySerialization);
$object = unserialize($string);
$string = serialize($dependencySerialization);
/** @var \Drupal\Tests\Core\DependencyInjection\DependencySerializationTestDummy $object */
$dependencySerialization = unserialize($string);
$this
->assertSame($service, $dependencySerialization->service);
$this
->assertSame($container, $dependencySerialization->container);
$this
->assertEmpty($dependencySerialization
->getServiceIds());
}