-
-
Save kofoworola/14fd5031f9e2733ebe4d3de5f1ae0490 to your computer and use it in GitHub Desktop.
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
<?php | |
... | |
class RecipeTest extends TestCase | |
{ | |
use RefreshDatabase; | |
... | |
//Create user and authenticate the user | |
protected function authenticate(){ | |
$user = User::create([ | |
'name' => 'test', | |
'email' => 'test@gmail.com', | |
'password' => Hash::make('secret1234'), | |
]); | |
$token = JWTAuth::fromUser($user); | |
return $token; | |
} | |
public function testCreate() | |
{ | |
//Get token | |
$token = $this->authenticate(); | |
$response = $this->withHeaders([ | |
'Authorization' => 'Bearer '. $token, | |
])->json('POST',route('recipe.create'),[ | |
'title' => 'Jollof Rice', | |
'procedure' => 'Parboil rice, get pepper and mix, and some spice and serve!' | |
]); | |
$response->assertStatus(200); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment