Permalink
Browse files

Fix ServiceLocatorLoader to work with adapters

  • Loading branch information...
1 parent 1b6795f commit 0cdc9ab62d5474d9f74e751d893a57bea0869595 @chEbba committed Mar 10, 2012
@@ -9,7 +9,7 @@
namespace Che\LogStock\Loader;
-use Che\LogStock\Logger;
+use Che\LogStock\Adapter\LoggerAdapter;
use Che\LogStock\Loader\Container\ServiceLocator;
use Che\LogStock\Loader\Container\ServiceNameFormatter;
@@ -67,6 +67,6 @@ public function load($name)
$name = $this->formatter ? $this->formatter->formatServiceName($name) : $name;
$service = $this->locator->getService($name);
- return (is_object($service) && ($service instanceof Logger)) ? $service : null;
+ return (is_object($service) && ($service instanceof LoggerAdapter)) ? $service : null;
}
}
@@ -35,27 +35,27 @@ class ServiceLocatorLoaderTest extends TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
- private $logger;
+ private $adapter;
protected function setUp()
{
$this->locator = $this->getMock('Che\LogStock\Loader\Container\ServiceLocator');
$this->formatter = $this->getMock('Che\LogStock\Loader\Container\ServiceNameFormatter');
$this->loader = new ServiceLocatorLoader($this->locator, $this->formatter);
- $this->logger = $this->getMock('Che\LogStock\Logger', array(), array(), '', false);
+ $this->adapter = $this->getMock('Che\LogStock\Adapter\LoggerAdapter', array(), array(), '', false);
}
/**
- * @test Loader uses locator and formatter to find logger services
+ * @test Loader uses locator and formatter to find adapter services
*/
public function locatorAndFormatter()
{
- $this->expectsLocator($this->logger);
+ $this->expectsLocator($this->adapter);
- $logger = $this->loader->load('logger');
+ $adapter = $this->loader->load('adapter');
- self::assertSame($this->logger, $logger);
+ self::assertSame($this->adapter, $adapter);
}
/**
@@ -65,19 +65,19 @@ public function notFound()
{
$this->expectsLocator(null);
- $logger = $this->loader->load('logger');
+ $adapter = $this->loader->load('adapter');
- self::assertNull($logger);
+ self::assertNull($adapter);
}
/**
- * @test If service found but is not Logger, null should be returned
+ * @test If service found but is not LoggerAdapter, null should be returned
*/
public function notLogger()
{
$this->expectsLocator(new \stdClass());
- $logger = $this->loader->load('logger');
+ $logger = $this->loader->load('adapter');
self::assertNull($logger);
}
@@ -91,12 +91,12 @@ private function expectsLocator($value)
{
$this->locator->expects(self::once())
->method('getService')
- ->with('logger_service')
+ ->with('adapter_service')
->will(self::returnValue($value));
$this->formatter->expects(self::once())
->method('formatServiceName')
- ->with('logger')
- ->will(self::returnValue('logger_service'));
+ ->with('adapter')
+ ->will(self::returnValue('adapter_service'));
}
}

0 comments on commit 0cdc9ab

Please sign in to comment.