Issue #2550641 by damiankloip: Use assert() in Drupal\Core\DependencyInjection\Container::__sleep instead of trigger error

8.0.x
webchick 2015-08-31 09:29:45 -07:00
parent e5018e6054
commit 25f26ed119
4 changed files with 13 additions and 3 deletions

View File

@ -31,7 +31,7 @@ class Container extends DrupalContainer {
* {@inheritdoc}
*/
public function __sleep() {
trigger_error('The container was serialized.', E_USER_ERROR);
assert(FALSE, 'The container was serialized.');
return array_keys(get_object_vars($this));
}

View File

@ -118,7 +118,7 @@ class ContainerBuilder extends SymfonyContainerBuilder {
* {@inheritdoc}
*/
public function __sleep() {
trigger_error('The container was serialized.', E_USER_ERROR);
assert(FALSE, 'The container was serialized.');
return array_keys(get_object_vars($this));
}

View File

@ -70,4 +70,14 @@ class ContainerBuilderTest extends UnitTestCase {
$container->register('Bar');
}
/**
* Tests serialization.
*
* @expectedException \AssertionError
*/
public function testSerialize() {
$container = new ContainerBuilder();
serialize($container);
}
}

View File

@ -20,7 +20,7 @@ class ContainerTest extends UnitTestCase {
/**
* Tests serialization.
*
* @expectedException \PHPUnit_Framework_Error
* @expectedException \AssertionError
*/
public function testSerialize() {
$container = new Container();