LazyEventDispatcherWithPsr11ContainerTest.php 767 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace JMS\Serializer\Tests\Serializer\EventDispatcher;
  3. use Psr\Container\ContainerInterface;
  4. class LazyEventDispatcherWithPsr11ContainerTest extends LazyEventDispatcherTest
  5. {
  6. protected function createContainer()
  7. {
  8. return new Psr11Container();
  9. }
  10. protected function registerListenerService($serviceId, MockListener $listener)
  11. {
  12. $this->container->set($serviceId, $listener);
  13. }
  14. }
  15. class Psr11Container implements ContainerInterface
  16. {
  17. private $services;
  18. public function get($id)
  19. {
  20. return $this->services[$id];
  21. }
  22. public function has($id)
  23. {
  24. return isset($this->services[$id]);
  25. }
  26. public function set($id, $service)
  27. {
  28. $this->services[$id] = $service;
  29. }
  30. }