-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Simple test added for coverage generation and testing
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
tests/Feature/Http/Controllers/SearchSimpleControllerTest.php
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,37 @@ | ||
<?php | ||
|
||
namespace Http\Controllers; | ||
|
||
use App\Models\Recipe; | ||
use Database\Seeders\BasicSeeder; | ||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Inertia\Testing\AssertableInertia as Assert; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use Tests\TestCase; | ||
|
||
/** | ||
* @see \App\Http\Controllers\RecipeController | ||
*/ | ||
final class SearchSimpleControllerTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
#[Test] | ||
public function search_gives_results(): void | ||
{ | ||
Recipe::factory()->create([ | ||
"name" => "Mac and Cheese", | ||
]); | ||
|
||
Recipe::factory()->create([ | ||
"name" => "Fruit Salad", | ||
]); | ||
|
||
$response = $this->postJson(route('search.simple'), ["search" => "Mac"]); | ||
|
||
$response->assertOk(); | ||
|
||
$response->assertJsonPath("0.name", "Mac and Cheese"); | ||
$this->assertGreaterThan(0, Recipe::count()); | ||
} | ||
} |