Esempio n. 1
0
 public static function quickResponse($respondingClass, Factory $factory = null)
 {
     $factory = $factory ?: self::init();
     $root = $factory->getInstance($respondingClass);
     $router = new NoneRouter(RespondingTarget::factory($factory, $root));
     self::quickRoute($router, $factory);
 }
 private function given_IsRoutedToARespondingClass_ThatRespondsWith($path, $className, $methodBody)
 {
     eval('class ' . $className . ' implements \\watoki\\deli\\Responding {
         public function respond(\\watoki\\deli\\Request $request) {
             ' . $methodBody . '
         }
     }');
     $this->router->addPath($path, RespondingTarget::factory($this->factory, new $className()));
 }
Esempio n. 3
0
 public function whenIGet_From($path, $resourceClass)
 {
     $request = $this->request->withTarget(Path::fromString($path))->withMethod('get');
     $stub = new TestDelivererStub($request);
     $router = new NoneRouter(RespondingTarget::factory($this->factory, $this->factory->getInstance($resourceClass)));
     $delivery = new WebDelivery($router, $stub, $stub);
     $stub->onDeliver(function (WebResponse $response) {
         if ($response instanceof ErrorResponse) {
             throw $response->getException();
         }
         $this->model = $response->getBody();
     });
     $delivery->run();
 }
Esempio n. 4
0
 public function givenTheTargetIsTheRespondingClass($fullClassName)
 {
     $object = $this->spec->factory->getInstance($fullClassName);
     $this->router = new NoneRouter(RespondingTarget::factory($this->spec->factory, $object));
 }
Esempio n. 5
0
 public static function quickResponse($respondingClass, Factory $factory = null)
 {
     $targetFactory = RespondingTarget::factory(self::$factory, self::$factory->getInstance($respondingClass));
     self::quickRoute(new NoneRouter($targetFactory));
 }