/**
* @covers ::__sleep
* @covers ::__wakeup
*/
public function testSerialization() { // Create a pseudo service and dependency injected object.
$service =
new \
stdClass();
$container = TestKernel::
setContainerWithKernel();
$container->
set('test_service',
$service);
$this->
assertSame($container,
$container->
get('service_container'
));
$dependencySerialization =
new DependencySerializationTestDummy($service);
$dependencySerialization->
setContainer($container);
$string =
serialize($dependencySerialization);
/** @var \Drupal\Tests\Core\DependencyInjection\DependencySerializationTestDummy $dependencySerialization */
$dependencySerialization =
unserialize($string);
$this->
assertTrue($container->
has(ReverseContainer::
class));
$this->
assertSame($service,
$dependencySerialization->service
);
$this->
assertSame($container,
$dependencySerialization->container
);
$this->
assertEmpty($dependencySerialization->
getServiceIds());
}}