diff --git a/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php b/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php index 9348117..23e8df6 100644 --- a/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php +++ b/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php @@ -35,7 +35,7 @@ * It is machine-optimized, for a human-readable version based on this one see * \Drupal\Component\DependencyInjection\Dumper\PhpArrayDumper. * - * @see \Drupal\Component\DependecyInjection\Container + * @see \Drupal\Component\DependencyInjection\Container */ class OptimizedPhpArrayDumper extends Dumper { @@ -414,7 +414,7 @@ protected function dumpValue($value) { return $this->getParameterCall((string) $value); } elseif ($value instanceof Expression) { - return $this->getExpressionCall((string) $value); + throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); } elseif (is_object($value)) { // Drupal specific: Instantiated objects have a _serviceId parameter. diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 2faa62c..2ee663a 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -811,7 +811,7 @@ protected function initializeContainer() { // boot the container injected via setContainer(). // @see \Drupal\KernelTests\KernelTestBase::setUp() if (isset($this->container) && !$this->booted) { - $container = $this->container; + $container = $this->container; } // If the module list hasn't already been set in updateModules and we are @@ -867,7 +867,7 @@ protected function initializeContainer() { \Drupal::setContainer($this->container); // If needs dumping flag was set, dump the container. - if ($this->containerNeedsDumping && !$this->cacheDrupalContainer($container_definition)) { + if ($this->containerNeedsDumping && isset($container) && !$this->cacheDrupalContainer($container_definition)) { $this->container->get('logger.factory')->get('DrupalKernel')->notice('Container cannot be saved to cache.'); } diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php index fff8364..21f6f5f 100644 --- a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php +++ b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php @@ -8,6 +8,7 @@ namespace Drupal\Tests\Component\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\LogicException; use Prophecy\Argument; @@ -365,8 +366,8 @@ public function testGetForNonExistantNULLService() { public function testGetForNonExistantServiceMultipleTimes() { $container = new $this->containerClass(); - $this->assertNull($container->get('service_not_exists', ContainerInterface::NULL_ON_INVALID_REFERENCE, 'Not found service does not throw exception.')); - $this->assertNull($container->get('service_not_exists', ContainerInterface::NULL_ON_INVALID_REFERENCE, 'Not found service does not throw exception on second call.')); + $this->assertNull($container->get('service_not_exists', ContainerInterface::NULL_ON_INVALID_REFERENCE), 'Not found service does not throw exception.'); + $this->assertNull($container->get('service_not_exists', ContainerInterface::NULL_ON_INVALID_REFERENCE), 'Not found service does not throw exception on second call.'); } /** @@ -379,7 +380,7 @@ public function testGetForNonExistantServiceMultipleTimes() { * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException */ public function testGetForNonExistantServiceWithExceptionOnSecondCall() { - $this->assertNull($this->container->get('service_not_exists', ContainerInterface::NULL_ON_INVALID_REFERENCE, 'Not found service does nto throw exception.')); + $this->assertNull($this->container->get('service_not_exists', ContainerInterface::NULL_ON_INVALID_REFERENCE), 'Not found service does nto throw exception.'); $this->container->get('service_not_exists'); } @@ -611,7 +612,7 @@ public function testResolveServicesAndParametersForInvalidArguments() { // In case the machine-optimized format is not used, we need to simulate the // test failure. if (!$this->machineFormat) { - throw new \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('Simulating the test failure.'); + throw new InvalidArgumentException('Simulating the test failure.'); } $this->container->get('invalid_arguments_service'); } diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php index b315403..7240e86 100644 --- a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php +++ b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php @@ -21,6 +21,20 @@ class OptimizedPhpArrayDumperTest extends \PHPUnit_Framework_TestCase { /** + * The container builder instance. + * + * @var \Drupal\Core\DependencyInjection\ContainerBuilder + */ + protected $containerBuilder; + + /** + * The definition for the container to build in tests. + * + * @var array + */ + protected $containerDefinition; + + /** * Whether the dumper uses the machine-optimized format or not. * * @var bool @@ -35,6 +49,13 @@ class OptimizedPhpArrayDumperTest extends \PHPUnit_Framework_TestCase { protected $dumperClass = '\Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper'; /** + * The dumper instance. + * + * @var \Symfony\Component\DependencyInjection\DumperDumperInterface + */ + protected $dumper; + + /** * {@inheritdoc} */ public function setUp() { @@ -264,7 +285,7 @@ public function getDefinitionsDataProvider() { 'arguments_expected' => $this->getCollection(array($this->getServiceCall('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE))), ) + $base_service_definition; - // Test a private shared servied, denoted by having a Reference. + // Test a private shared service, denoted by having a Reference. $private_definition = array( 'class' => '\stdClass', 'public' => FALSE,