Add recipe duplicate test

This commit is contained in:
Christopher C. Wells 2022-03-06 20:47:42 -08:00 committed by Christopher Charbonneau Wells
parent 4aaf83c862
commit 5de41c4793
1 changed files with 19 additions and 0 deletions

View File

@ -102,6 +102,25 @@ class RecipeControllerTest extends HttpControllerTestCase
$response->assertSessionHasNoErrors();
}
public function testCanDuplicateInstances(): void {
$instance = $this->createInstance();
$confirm_url = action([$this->class(), 'duplicateConfirm'], [$this->routeKey() => $instance]);
$response = $this->get($confirm_url);
$response->assertOk();
$response->assertViewHas($this->routeKey());
$duplicate_url = action([$this->class(), 'duplicate'], [$this->routeKey() => $instance]);
$response = $this->followingRedirects()->post($duplicate_url, ['name' => 'Duplicated Recipe']);
$response->assertOk();
$recipe = Recipe::latest()->first();
$this->assertEquals('Duplicated Recipe', $recipe->name);
$this->assertEquals($instance->tags->toArray(), $instance->tags->toArray());
$this->assertEquals($instance->ingredientAmounts->toArray(), $instance->ingredientAmounts->toArray());
$this->assertEquals($instance->steps->toArray(), $instance->steps->toArray());
$this->assertEquals($instance->separators->toArray(), $instance->separators->toArray());
}
public function testSessionKeepsOldInputOnAdd(): void {
$instance = $this->createInstance();
$data = $this->createInvalidFormData($instance);