Permalink
Browse files

fix callback test

  • Loading branch information...
1 parent b8f846e commit da426a62f33385e38a847d64b47bbe15f537ca57 @stefanotorresi committed Sep 30, 2013
Showing with 7 additions and 5 deletions.
  1. +7 −5 tests/ZendTest/ServiceManager/ServiceManagerTest.php
@@ -899,15 +899,17 @@ public function testDelegatorFromCallback()
$realService = $this->getMock('stdClass', array(), array(), 'RealService');
$delegator = $this->getMock('stdClass', array(), array(), 'Delegator');
- $delegator = function($serviceManager, $cName, $rName, $callback) use($delegator) {
+ $delegatorFactoryCallback = function($serviceManager, $cName, $rName, $callback) use ($delegator) {
$delegator->real = call_user_func($callback);
return $delegator;
};
- $this->serviceManager->addDelegator('foo-service', $delegator);
- $this->serviceManager->setService('foo-service', $realService);
+ $this->serviceManager->setFactory('foo-service', function() use ($realService) { return $realService; } );
+ $this->serviceManager->addDelegator('foo-service', $delegatorFactoryCallback);
- $this->assertSame($delegator, $this->serviceManager->create('foo-service'));
- $this->assertSame($realService, $delegator->real);
+ $service = $this->serviceManager->create('foo-service');
+
+ $this->assertSame($delegator, $service);
+ $this->assertSame($realService, $service->real);
}
}

0 comments on commit da426a6

Please sign in to comment.