Skip to content

Commit

Permalink
feat: add integration test for destroy action
Browse files Browse the repository at this point in the history
  • Loading branch information
lindyhopchris committed Aug 19, 2023
1 parent 0908407 commit 99a681d
Show file tree
Hide file tree
Showing 9 changed files with 432 additions and 30 deletions.
5 changes: 3 additions & 2 deletions src/Core/Http/Actions/Middleware/HandlesActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Closure;
use Illuminate\Contracts\Support\Responsable;
use LaravelJsonApi\Core\Http\Actions\Input\ActionInput;
use Symfony\Component\HttpFoundation\Response;

interface HandlesActions
{
Expand All @@ -30,7 +31,7 @@ interface HandlesActions
*
* @param ActionInput $action
* @param Closure $next
* @return Responsable
* @return Responsable|Response
*/
public function handle(ActionInput $action, Closure $next): Responsable;
public function handle(ActionInput $action, Closure $next): Responsable|Response;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Illuminate\Http\Request;
use LaravelJsonApi\Core\Http\Actions\Input\ActionInput;
use LaravelJsonApi\Core\Http\Exceptions\HttpNotAcceptableException;
use Symfony\Component\HttpFoundation\Response;

class ItAcceptsJsonApiResponses implements HandlesActions
{
Expand All @@ -43,7 +44,7 @@ public function __construct(private readonly Translator $translator)
/**
* @inheritDoc
*/
public function handle(ActionInput $action, Closure $next): Responsable
public function handle(ActionInput $action, Closure $next): Responsable|Response
{
if (!$this->isAcceptable($action->request())) {
$message = $this->translator->get(
Expand Down
8 changes: 4 additions & 4 deletions src/Core/Http/Actions/Middleware/LookupModelIfMissing.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
namespace LaravelJsonApi\Core\Http\Actions\Middleware;

use Closure;
use Illuminate\Contracts\Support\Responsable;
use LaravelJsonApi\Contracts\Store\Store;
use LaravelJsonApi\Core\Document\Error;
use LaravelJsonApi\Core\Exceptions\JsonApiException;
use LaravelJsonApi\Core\Http\Actions\Input\ActionInput;
use LaravelJsonApi\Core\Http\Actions\Input\IsIdentifiable;
use LaravelJsonApi\Core\Responses\DataResponse;
use Symfony\Component\HttpFoundation\Response;

class LookupModelIfMissing
Expand All @@ -44,10 +44,10 @@ public function __construct(private readonly Store $store)
*
* @param IsIdentifiable&ActionInput $action
* @param Closure $next
* @return DataResponse
* @return Responsable
* @throws JsonApiException
*/
public function handle(ActionInput&IsIdentifiable $action, Closure $next): DataResponse
public function handle(ActionInput&IsIdentifiable $action, Closure $next): Responsable
{
if ($action->model() === null) {
$model = $this->store->find(
Expand All @@ -66,4 +66,4 @@ public function handle(ActionInput&IsIdentifiable $action, Closure $next): DataR

return $next($action);
}
}
}
Loading

0 comments on commit 99a681d

Please sign in to comment.