Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.0] Add responses for destroy methods #942

Merged
merged 2 commits into from
Jan 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Http/Controllers/AuthorizedAccessTokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@ public function destroy(Request $request, $tokenId)
}

$token->revoke();

return new Response('', Response::HTTP_NO_CONTENT);
}
}
8 changes: 4 additions & 4 deletions src/Http/Controllers/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function update(Request $request, $clientId)
/**
* Delete the given client.
*
* @param Request $request
* @param \Illuminate\Http\Request $request
* @param string $clientId
* @return \Illuminate\Http\Response
*/
Expand All @@ -120,8 +120,8 @@ public function destroy(Request $request, $clientId)
return new Response('', 404);
}

$this->clients->delete(
$client
);
$this->clients->delete($client);

return new Response('', Response::HTTP_NO_CONTENT);
}
}
4 changes: 3 additions & 1 deletion src/Http/Controllers/PersonalAccessTokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function store(Request $request)
/**
* Delete the given token.
*
* @param Request $request
* @param \Illuminate\Http\Request $request
* @param string $tokenId
* @return \Illuminate\Http\Response
*/
Expand All @@ -88,5 +88,7 @@ public function destroy(Request $request, $tokenId)
}

$token->revoke();

return new Response('', Response::HTTP_NO_CONTENT);
}
}
5 changes: 4 additions & 1 deletion tests/AuthorizedAccessTokenControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Laravel\Passport\Client;
use PHPUnit\Framework\TestCase;
use Laravel\Passport\TokenRepository;
use Symfony\Component\HttpFoundation\Response;
use Laravel\Passport\Http\Controllers\AuthorizedAccessTokenController;

class AuthorizedAccessTokenControllerTest extends TestCase
Expand Down Expand Up @@ -85,7 +86,9 @@ public function test_tokens_can_be_deleted()
return $user;
});

$this->controller->destroy($request, 1);
$response = $this->controller->destroy($request, 1);

$this->assertEquals(Response::HTTP_NO_CONTENT, $response->status());
}

public function test_not_found_response_is_returned_if_user_doesnt_have_token()
Expand Down
5 changes: 4 additions & 1 deletion tests/ClientControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Laravel\Passport\Client;
use PHPUnit\Framework\TestCase;
use Laravel\Passport\Http\Rules\RedirectRule;
use Symfony\Component\HttpFoundation\Response;
use Laravel\Passport\Http\Controllers\ClientController;

class ClientControllerTest extends TestCase
Expand Down Expand Up @@ -155,7 +156,9 @@ public function test_clients_can_be_deleted()
$clients, $validator, m::mock(RedirectRule::class)
);

$controller->destroy($request, 1);
$response = $controller->destroy($request, 1);

$this->assertEquals(Response::HTTP_NO_CONTENT, $response->status());
}

public function test_404_response_if_client_doesnt_belong_to_user_on_delete()
Expand Down
5 changes: 4 additions & 1 deletion tests/PersonalAccessTokenControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Laravel\Passport\Passport;
use PHPUnit\Framework\TestCase;
use Laravel\Passport\TokenRepository;
use Symfony\Component\HttpFoundation\Response;
use Laravel\Passport\Http\Controllers\PersonalAccessTokenController;

class PersonalAccessTokenControllerTest extends TestCase
Expand Down Expand Up @@ -104,7 +105,9 @@ public function test_tokens_can_be_deleted()
$validator = m::mock('Illuminate\Contracts\Validation\Factory');
$controller = new PersonalAccessTokenController($tokenRepository, $validator);

$controller->destroy($request, 1);
$response = $controller->destroy($request, 1);

$this->assertEquals(Response::HTTP_NO_CONTENT, $response->status());
}

public function test_not_found_response_is_returned_if_user_doesnt_have_token()
Expand Down