mirror of https://github.com/kcal-app/kcal.git
Update Goals tests
This commit is contained in:
parent
6bb2439378
commit
b21f483af2
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue