adrema/tests/Feature/Activity/EditTest.php

48 lines
1.6 KiB
PHP
Raw Normal View History

2023-02-25 17:19:17 +01:00
<?php
namespace Tests\Feature\Activity;
use App\Activity;
use App\Subactivity;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class EditTest extends TestCase
{
use DatabaseTransactions;
public function testItEditsAnActivity(): void
{
$this->login()->loginNami()->withoutExceptionHandling();
2023-03-07 00:27:10 +01:00
$activity = Activity::factory()->name('Asas')->hasAttached(Subactivity::factory()->name('Pupu')->filterable())->create();
2023-02-25 17:19:17 +01:00
2023-03-04 12:09:25 +01:00
$response = $this->get(route('activity.edit', ['activity' => $activity]));
2023-02-25 17:19:17 +01:00
$this->assertInertiaHas([
'name' => 'Asas',
2023-03-04 12:09:25 +01:00
'is_filterable' => false,
2023-02-25 17:19:17 +01:00
'subactivities' => [$activity->subactivities->first()->id],
2023-03-04 15:23:45 +01:00
'subactivity_model' => [
'activities' => [$activity->id],
'is_age_group' => false,
'is_filterable' => false,
'name' => '',
],
2023-02-25 17:19:17 +01:00
], $response, 'data');
$this->assertInertiaHas([
'id' => $activity->subactivities->first()->id,
'name' => 'Pupu',
2023-03-07 00:27:10 +01:00
'is_filterable' => true,
2023-02-25 17:19:17 +01:00
], $response, 'meta.subactivities.0');
2023-03-07 01:35:39 +01:00
$this->assertInertiaHas([
'id' => $activity->subactivities->first()->id,
'name' => 'Pupu',
'is_filterable' => true,
'links' => [
'show' => route('api.subactivity.show', ['subactivity' => $activity->subactivities->first()->id]),
'update' => route('api.subactivity.update', ['subactivity' => $activity->subactivities->first()->id]),
],
], $response, 'meta.subactivities.0');
2023-02-25 17:19:17 +01:00
}
}