diff --git a/tests/Feature/Http/Controllers/JournalEntryControllerTest.php b/tests/Feature/Http/Controllers/JournalEntryControllerTest.php index 2a4c43f..e4815bf 100644 --- a/tests/Feature/Http/Controllers/JournalEntryControllerTest.php +++ b/tests/Feature/Http/Controllers/JournalEntryControllerTest.php @@ -102,11 +102,17 @@ class JournalEntryControllerTest extends HttpControllerTestCase // Set first amount to an invalid string. $data['ingredients']['amount'][0] = 'abcd'; + $create_url = action([$this->class(), 'create']); $store_url = action([$this->class(), 'store']); - $response = $this->post($store_url, $data); - $response->assertRedirect(); + $response = $this->from($create_url)->post($store_url, $data); + $response->assertRedirect($create_url); $response->assertSessionHasErrors(); $response->assertSessionHasInput('ingredients', $data['ingredients']); + + $this->followingRedirects() + ->from($create_url) + ->post($store_url, $data); + $this->assertEquals($create_url, url()->current()); } /** @@ -124,8 +130,9 @@ class JournalEntryControllerTest extends HttpControllerTestCase ->make(['parent_id' => null, 'parent_type' => null]); /** @var \App\Models\IngredientAmount $ingredient_amount */ foreach ($ingredient_amounts as $ingredient_amount) { - $ingredients['date'][] = $this->faker->dateTimeThisMonth; + $ingredients['date'][] = $this->faker->dateTimeThisMonth->format('Y-m-d'); $ingredients['meal'][] = $this->faker->randomElement(JournalEntry::meals()->pluck('value')->toArray()); + $ingredients['name'][] = $ingredient_amount->ingredient->name; $ingredients['amount'][] = $ingredient_amount->amount; $ingredients['unit'][] = $ingredient_amount->unit; $ingredients['id'][] = $ingredient_amount->ingredient->id; diff --git a/tests/Feature/Http/Controllers/RecipeControllerTest.php b/tests/Feature/Http/Controllers/RecipeControllerTest.php index 12f3983..0b995af 100644 --- a/tests/Feature/Http/Controllers/RecipeControllerTest.php +++ b/tests/Feature/Http/Controllers/RecipeControllerTest.php @@ -115,13 +115,19 @@ class RecipeControllerTest extends HttpControllerTestCase // Remove the first amount value to force a form error. $data['ingredients']['amount'][0] = NULL; + $edit_url = action([$this->class(), 'edit'], [$this->routeKey() => $instance]); $put_url = action([$this->class(), 'update'], [$this->routeKey() => $instance]); - $response = $this->put($put_url, $data); - $response->assertRedirect(); + $response = $this->from($edit_url)->put($put_url, $data); + $response->assertRedirect($edit_url); $response->assertSessionHasErrors(); $response->assertSessionHasInput('ingredients', $data['ingredients']); $response->assertSessionHasInput('steps', $data['steps']); $response->assertSessionHasInput('separators', $data['separators']); + + $this->followingRedirects() + ->from($edit_url) + ->put($put_url, $data); + $this->assertEquals($edit_url, url()->current()); } /**