/** * Resolves a concrete resource by topic + action * * @param string $topic The resource topic, e.g "forums" * @param string $action The resource action, e.g. "listPosts" * * @return AbstractResource * @throws UnknownObjectException Is re-thrown if the DIC ObjectManager * can not resolve a proper resource object instance. */ public function resolve($topic, $action) { try { return $this->objectManager->get(sprintf($this->patternProvider->getPattern(), $topic, $action)); } catch (\Exception $e) { throw new UnknownObjectException('The resource ' . $topic . '/' . $action . ' is currently not implemented!', 1367666179); } }
/** * ResolverUsesObjectManagerToRetrieveConcreteImplementation * * @return void */ public function testResolverUsesObjectManagerToRetrieveConcreteImplementation() { $this->objectManagerMock->expects($this->once())->method('get')->with($this->equalTo('DreadLabs\\VantomasWebsite\\Disqus\\Resource\\Foo\\Bar')); $this->patternProviderMock->expects($this->once())->method('getPattern')->willReturn('DreadLabs\\VantomasWebsite\\Disqus\\Resource\\%s\\%s'); $this->sut->resolve('Foo', 'Bar'); }