-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Here's an example of creating a stub basic-test file using parameters in artisan command line. Example: php artisan make:a basic-test Feature\Modules\Pages\PageCategoryTest "{TEST}:Feature|{MODULE}:Pages|{MODEL}:PageCategory|{URL}:page_category"
- Loading branch information
Showing
4 changed files
with
110 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace Tests\{TEST}\Modules\{MODULE}; | ||
|
||
use App\Api\V1\Models\{MODEL}; | ||
use Tests\TestCase; | ||
|
||
class {MODEL}Test extends TestCase | ||
{ | ||
|
||
/** @test */ | ||
public function testIndex() | ||
{ | ||
factory({MODEL}::class, 10)->create(); | ||
$response = $this->json('GET', 'api/auth/{URL}'); | ||
$expect = $response->decodeResponseJson(); | ||
$response | ||
->assertOk() | ||
->assertExactJson($expect); | ||
} | ||
|
||
/** @test */ | ||
public function testShow() | ||
{ | ||
factory({MODEL}::class, 10)->create(); | ||
$random_id = random_int(1, 10); | ||
$response = $this->json('GET', 'api/auth/{URL}/' . $random_id); | ||
$expect = $response->decodeResponseJson(); | ||
$response | ||
->assertOk() | ||
->assertExactJson($expect); | ||
} | ||
|
||
/** @test */ | ||
public function testStore() | ||
{ | ||
factory({MODEL}::class, 10)->create(); | ||
$data = ['name' => 'Category 1']; | ||
$response = $this->json('POST', 'api/auth/{URL}', $data); | ||
$expect = $response->decodeResponseJson(); | ||
$response | ||
->assertOk() | ||
->assertExactJson($expect); | ||
} | ||
|
||
/** @test */ | ||
public function testUpdate() | ||
{ | ||
factory({MODEL}::class, 10)->create(); | ||
$random_id = random_int(1, 10); | ||
$data = ['nome' => 'Category updated']; | ||
$response = $this->json('PUT', 'api/auth/{URL}/' . $random_id, $data); | ||
$expect = $response->decodeResponseJson(); | ||
$response | ||
->assertOk() | ||
->assertExactJson($expect); | ||
} | ||
|
||
/** @test */ | ||
public function testDelete() | ||
{ | ||
factory({MODEL}::class, 10)->create(); | ||
$random_id = random_int(1, 10); | ||
$response = $this->json('DELETE', 'api/auth/{URL}/' . $random_id); | ||
$expect = $response->decodeResponseJson(); | ||
$response | ||
->assertOk() | ||
->assertExactJson($expect); | ||
} | ||
} |