Update Goals tests

This commit is contained in:
Christopher C. Wells 2021-05-15 10:44:36 -07:00 committed by Christopher Charbonneau Wells
parent 6bb2439378
commit b21f483af2
2 changed files with 36 additions and 0 deletions

View File

@ -25,6 +25,7 @@ class GoalSchema extends SchemaProvider
*/
public function getAttributes($resource): array
{
/** @var \App\Models\Goal $resource */
return [
'name' => $resource->name,
'days' => $resource->days,

View File

@ -41,4 +41,39 @@ class GoalControllerTest extends HttpControllerTestCase
return $this->factory()->for($this->user)->create();
}
/**
* @inheritdoc
*/
public function testCanAddInstance(): void
{
$create_url = action([$this->class(), 'create']);
$response = $this->get($create_url);
$response->assertOk();
$data = $this->factory()->makeOne()->toArray();
$data['days'] = Goal::days()->pluck('value')->random(3)->toArray();
$store_url = action([$this->class(), 'store']);
$response = $this->post($store_url, $data);
$response->assertSessionHasNoErrors();
}
/**
* @inheritdoc
*/
public function testCanEditInstance(): void
{
$instance = $this->createInstance();
$edit_url = action([$this->class(), 'edit'], [$this->routeKey() => $instance]);
$response = $this->get($edit_url);
$response->assertOk();
$data = $this->factory()->makeOne()->toArray();
$data['days'] = Goal::days()->pluck('value')->random(3)->toArray();
$put_url = action([$this->class(), 'update'], [$this->routeKey() => $instance]);
$response = $this->put($put_url, $data);
$response->assertSessionHasNoErrors();
}
}