-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
115 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Feature test | ||
name: Run Feature tests | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Static analysis | ||
name: Run Static analysis | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Unit test | ||
name: Run Unit tests | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
use Illuminate\Http\Response; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Log; | ||
use Symfony\Component\HttpFoundation\Response as ResponseAlias; | ||
|
||
class RecipeTest extends \TestCase | ||
{ | ||
|
@@ -166,6 +167,50 @@ public function it_cannot_clap_for_a_recipe_that_does_not_exist() | |
]); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_can_show_a_recipe_by_id_or_slug() | ||
{ | ||
$user = User::factory()->make([ | ||
'email' => '[email protected]', | ||
'password' => (new BcryptHasher)->make('pass123'), | ||
]); | ||
$user->save(); | ||
|
||
$token = Auth::attempt([ | ||
'email' => '[email protected]', | ||
'password' => 'pass123' | ||
]); | ||
|
||
$cookbook = Cookbook::factory()->make([ | ||
'user_id' => $user->getKey() | ||
]); | ||
|
||
$cookbook->save(); | ||
|
||
$recipe = Recipe::factory()->make([ | ||
'cookbook_id' => $cookbook->refresh()->getKey(), | ||
'user_id' => $user->getKey() | ||
]); | ||
|
||
$recipe->save(); | ||
$recipe = $recipe->refresh(); | ||
|
||
$searchBy = ['id', 'slug']; | ||
|
||
foreach ($searchBy as $key) { | ||
$this->json( | ||
'GET', | ||
'/api/v1/recipes/' . $recipe->$key, | ||
[], | ||
[ | ||
'Authorization' => 'Bearer ' . $token | ||
] | ||
)->assertStatus(ResponseAlias::HTTP_OK)->assertJsonStructure(['data']); | ||
} | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
|
@@ -366,7 +411,7 @@ public function only_supers_can_destroy_a_recipe() | |
[ | ||
'Authorization' => 'Bearer ' . $token | ||
] | ||
)->assertStatus(Response::HTTP_ACCEPTED) | ||
)->assertStatus(ResponseAlias::HTTP_OK) | ||
->assertExactJson([ | ||
"deleted" => true | ||
]); | ||
|