class(), 'index']); $response = $this->get($index_url); $response->assertOk(); } public function testCanAddInstance(): void { $create_url = action([$this->class(), 'create']); $response = $this->get($create_url); $response->assertOk(); $instance = $this->factory()->make(); $store_url = action([$this->class(), 'store']); $response = $this->followingRedirects()->post($store_url, $instance->toArray()); $response->assertOk(); $response->assertSessionHasNoErrors(); $response->assertViewHas($this->routeKey()); } public function testCanViewInstance(): void { $instance = $this->factory()->create(); $view_url = action([$this->class(), 'show'], [$this->routeKey() => $instance]); $response = $this->get($view_url); $response->assertOk(); $response->assertViewHas($this->routeKey()); } public function testCanEditInstance(): void { $instance = $this->factory()->create(); $edit_url = action([$this->class(), 'edit'], [$this->routeKey() => $instance]); $response = $this->get($edit_url); $response->assertOk(); $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->assertSessionHasNoErrors(); $response->assertViewHas($this->routeKey()); } public function testCanDeleteInstance(): void { $instance = $this->factory()->create(); $delete_url = action([$this->class(), 'delete'], [$this->routeKey() => $instance]); $response = $this->get($delete_url); $response->assertOk(); $response->assertViewHas($this->routeKey()); $destroy_url = action([$this->class(), 'destroy'], [$this->routeKey() => $instance]); $response = $this->followingRedirects()->delete($destroy_url); $response->assertOk(); $view_url = action([$this->class(), 'show'], [$this->routeKey() => $instance]); $response = $this->get($view_url); $response->assertNotFound(); } }