/** * @dataProvider offsetGetBlacklistedProvider */ public function testOffsetGetBlacklisted($index, $initialIndex, $initialValue, $result) { $serviceManager = $this->createMock('Zend\\ServiceManager\\ServiceManager'); $serviceManager->expects($this->once())->method('get')->willReturnCallback(function ($name) { // Proxy to real service manager. Mock only exists to assert // that the service is used only once. return static::$serviceManager->get($name); }); $model = new \Model\Client\Client(array($initialIndex => $initialValue)); $model->setServiceLocator($serviceManager); $this->assertSame($result, $model[$index]); $this->assertSame($result, $model[$index]); // cached result }
/** * @internal */ public function __invoke(\Interop\Container\ContainerInterface $container, $requestedName, array $options = null) { $client = new \Model\Client\Client(); $client->setServiceLocator($container); return $client; }