PhpArrayContainerTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Drupal\Tests\Component\DependencyInjection;
  3. use Symfony\Component\DependencyInjection\ContainerInterface;
  4. /**
  5. * @coversDefaultClass \Drupal\Component\DependencyInjection\PhpArrayContainer
  6. * @group DependencyInjection
  7. */
  8. class PhpArrayContainerTest extends ContainerTest {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. protected function setUp() {
  13. $this->machineFormat = FALSE;
  14. $this->containerClass = '\Drupal\Component\DependencyInjection\PhpArrayContainer';
  15. $this->containerDefinition = $this->getMockContainerDefinition();
  16. $this->container = new $this->containerClass($this->containerDefinition);
  17. }
  18. /**
  19. * Helper function to return a service definition.
  20. */
  21. protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
  22. if ($invalid_behavior !== ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) {
  23. return sprintf('@?%s', $id);
  24. }
  25. return sprintf('@%s', $id);
  26. }
  27. /**
  28. * Helper function to return a service definition.
  29. */
  30. protected function getParameterCall($name) {
  31. return '%' . $name . '%';
  32. }
  33. /**
  34. * Helper function to return a machine-optimized '@notation'.
  35. */
  36. protected function getCollection($collection, $resolve = TRUE) {
  37. return $collection;
  38. }
  39. }