Skip to content

Commit

Permalink
Don't depend on something that doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
gms8994 committed Nov 18, 2020
1 parent 259f37d commit 4464959
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tests/CanGuardRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ public function test_no_apikeys_triggers_unauthorized()
$response = $this->get(__FUNCTION__ . '?foo=bar');

$response->assertStatus(401);
$response->assertJsonPath('error.code', 401);
$response->assertJsonPath('error.http_code', "GEN-UNAUTHORIZED");
$response->assertJsonPath('error.message', "Unauthorized.");
$error = $response->json();

$this->assertSame(data_get($error, 'error.code'), '401');
$this->assertSame(data_get($error, 'error.http_code'), "GEN-UNAUTHORIZED");
$this->assertSame(data_get($error, 'error.message'), "Unauthorized.");
}

public function test_auth_request_returns_proper_value()
Expand Down Expand Up @@ -79,7 +81,9 @@ public function test_auth_request_returns_proper_value()

$response->assertStatus(200);

$response->assertJsonPath('id', $user->id);
$responseUser = $response->json();

$this->assertSame(data_get($responseUser, 'id'), $user->id);
}

public function test_auth_request_with_invalid_key_returns_unauthorized()
Expand Down Expand Up @@ -108,9 +112,12 @@ public function test_auth_request_with_invalid_key_returns_unauthorized()
->get(__FUNCTION__ . '?foo=bar');

$response->assertStatus(401);
$response->assertJsonPath('error.code', 401);
$response->assertJsonPath('error.http_code', "GEN-UNAUTHORIZED");
$response->assertJsonPath('error.message', "Unauthorized.");

$error = $response->json();

$this->assertSame(data_get($error, 'error.code'), '401');
$this->assertSame(data_get($error, 'error.http_code'), "GEN-UNAUTHORIZED");
$this->assertSame(data_get($error, 'error.message'), "Unauthorized.");
}
}

Expand Down

0 comments on commit 4464959

Please sign in to comment.