From 2afb8b9df873c3f9572a32ab7a62ea8ba8d8a45b Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 20 Nov 2012 18:14:48 -0600 Subject: [ticket/11103] Create user loader class, update for DIC Create a very basic user loader class to handle querying/storing user data in a centralized location. Use DIC collection service for notification types/methods. Cleanup unused dependencies. Fix some other issues. PHPBB3-11103 --- tests/mock/container_builder.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/mock/container_builder.php') diff --git a/tests/mock/container_builder.php b/tests/mock/container_builder.php index 8a81dd72d1..734d3e1741 100644 --- a/tests/mock/container_builder.php +++ b/tests/mock/container_builder.php @@ -11,6 +11,9 @@ use Symfony\Component\DependencyInjection\ScopeInterface; class phpbb_mock_container_builder implements ContainerInterface { + protected $services = array(); + protected $parameters = array(); + /** * Sets a service. * @@ -22,6 +25,7 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function set($id, $service, $scope = self::SCOPE_CONTAINER) { + $this->services[$id] = $service; } /** @@ -42,6 +46,12 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE) { + if ($this->has($id)) + { + return $this->services[$id]; + } + + throw new Exception('Could not find service: ' . $id); } /** @@ -55,6 +65,7 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function has($id) { + return isset($this->services[$id]); } /** @@ -70,6 +81,12 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function getParameter($name) { + if ($this->hasParameter($name)) + { + return $this->parameters[$name]; + } + + throw new Exception('Could not find parameter: ' . $name); } /** @@ -83,6 +100,7 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function hasParameter($name) { + return isset($this->parameters[$name]); } /** @@ -95,6 +113,7 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function setParameter($name, $value) { + $this->parameters[$name] = $value; } /** -- cgit v1.2.1