From f9cb622d929e3cc61286d9830e5eaa7e07d8da5e Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Tue, 30 Mar 2021 15:36:39 -0700 Subject: [PATCH] Do not follow redirects when asserting no session errors --- tests/Feature/Http/Controllers/HttpControllerTestCase.php | 7 ++----- .../Http/Controllers/JournalEntryControllerTest.php | 5 +---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/Feature/Http/Controllers/HttpControllerTestCase.php b/tests/Feature/Http/Controllers/HttpControllerTestCase.php index ae353cb..8e55082 100644 --- a/tests/Feature/Http/Controllers/HttpControllerTestCase.php +++ b/tests/Feature/Http/Controllers/HttpControllerTestCase.php @@ -45,8 +45,7 @@ abstract class HttpControllerTestCase extends LoggedInTestCase $response->assertOk(); $instance = $this->factory()->make(); $store_url = action([$this->class(), 'store']); - $response = $this->followingRedirects()->post($store_url, $instance->toArray()); - $response->assertOk(); + $response = $this->post($store_url, $instance->toArray()); $response->assertSessionHasNoErrors(); } @@ -68,10 +67,8 @@ abstract class HttpControllerTestCase extends LoggedInTestCase $new_instance = $this->factory()->make(); $put_url = action([$this->class(), 'update'], [$this->routeKey() => $instance]); - $response = $this->followingRedirects()->put($put_url, $new_instance->toArray()); - $response->assertOk(); + $response = $this->put($put_url, $new_instance->toArray()); $response->assertSessionHasNoErrors(); - $response->assertViewHas($this->routeKey()); } public function testCanDeleteInstance(): void diff --git a/tests/Feature/Http/Controllers/JournalEntryControllerTest.php b/tests/Feature/Http/Controllers/JournalEntryControllerTest.php index 3576f0d..3d39109 100644 --- a/tests/Feature/Http/Controllers/JournalEntryControllerTest.php +++ b/tests/Feature/Http/Controllers/JournalEntryControllerTest.php @@ -2,9 +2,7 @@ namespace Tests\Feature\Http\Controllers; -use App\Http\Controllers\GoalController; use App\Http\Controllers\JournalEntryController; -use App\Models\Goal; use App\Models\JournalEntry; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Model; @@ -69,8 +67,7 @@ class JournalEntryControllerTest extends HttpControllerTestCase $response->assertOk(); $instance = $this->factory()->make(); $store_url = action([$this->class(), 'storeFromNutrients']); - $response = $this->followingRedirects()->post($store_url, $instance->toArray()); - $response->assertOk(); + $response = $this->post($store_url, $instance->toArray()); $response->assertSessionHasNoErrors(); }