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(); }
<?php use spec\watoki\deli\fixtures\TestDelivererStub; use watoki\deli\Delivery; use watoki\deli\Path; use watoki\deli\Request; use watoki\deli\router\NoneRouter; use watoki\deli\target\CallbackTarget; require_once __DIR__ . '/../../vendor/autoload.php'; error_reporting(0); $router = new NoneRouter(CallbackTarget::factory(function () { /** @noinspection PhpUndefinedFunctionInspection */ causeFatalError(); })); $test = new TestDelivererStub(new Request(new Path(), Path::fromString('some/target'))); $test->onDeliver(function ($response) { echo $response; }); $delivery = new Delivery($router, $test, $test); $delivery->run();