コード例 #1
0
 /**
  * Creates a RestManager.
  *
  * @param  \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return \BedRest\Rest\Dispatcher
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $rm = new Dispatcher();
     $rm->setResourceMetadataFactory($serviceLocator->get('BedRest.ResourceMetadataFactory'));
     $rm->setServiceMetadataFactory($serviceLocator->get('BedRest.ServiceMetadataFactory'));
     $rm->setServiceLocator(new ServiceLocator($serviceLocator));
     $rm->setEventManager(new EventManager(new AnnotationDriver(new AnnotationReader())));
     return $rm;
 }
コード例 #2
0
ファイル: DispatcherTest.php プロジェクト: bedrest/bedrest
 /**
  * @dataProvider requests
  *
  * @param string $method
  */
 public function testDispatchToNonExistentSubResourceThrows404Exception($method)
 {
     // configure the Dispatcher with the necessary dependencies
     $this->dispatcher->setResourceMetadataFactory($this->getMockResourceMetadataFactory());
     $this->dispatcher->setServiceMetadataFactory($this->getMockServiceMetadataFactory($method));
     $this->dispatcher->setServiceLocator($this->getMockServiceLocator());
     $eventManager = $this->getMock('BedRest\\Events\\EventManager');
     $this->dispatcher->setEventManager($eventManager);
     // form a basic request
     $request = new Request();
     $request->setResource('testResource/nonExistentSub');
     $request->setMethod($method);
     // test an exception is thrown
     $this->setExpectedException('BedRest\\Rest\\Exception', '', 404);
     $this->dispatcher->dispatch($request);
 }
コード例 #3
0
 /**
  * @dataProvider supportedRequests
  *
  * @param \BedRest\Rest\Request\Request $request
  */
 public function testSupportedRequestsAreDispatchable(Request $request)
 {
     $container = new Container();
     $container->set('TestService', $this->service);
     $locator = new SimpleLocator($container);
     $dispatcher = new Dispatcher();
     $dispatcher->setResourceMetadataFactory($this->getResourceMetadataFactory());
     $dispatcher->setServiceMetadataFactory($this->getServiceMetadataFactory());
     $dispatcher->setServiceLocator($locator);
     $dispatcher->setEventManager(new EventManager(new AnnotationDriver(new AnnotationReader())));
     $data = $dispatcher->dispatch($request);
 }