adrema/tests/Feature/Activity/EditTest.php

43 lines
1.5 KiB
PHP
Raw Permalink 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;
2024-09-21 23:43:51 +02:00
uses(DatabaseTransactions::class);
2023-02-25 17:19:17 +01:00
2024-09-21 23:43:51 +02:00
it('testItEditsAnActivity', function () {
$this->login()->loginNami()->withoutExceptionHandling();
$activity = Activity::factory()->name('Asas')->hasAttached(Subactivity::factory()->name('Pupu')->filterable())->create();
2023-02-25 17:19:17 +01:00
2024-09-21 23:43:51 +02:00
$response = $this->get(route('activity.edit', ['activity' => $activity]));
2023-02-25 17:19:17 +01:00
2024-09-21 23:43:51 +02:00
$this->assertInertiaHas([
'name' => 'Asas',
'is_filterable' => false,
'subactivities' => [$activity->subactivities->first()->id],
'subactivity_model' => [
'activities' => [$activity->id],
'is_age_group' => false,
2023-03-04 12:09:25 +01:00
'is_filterable' => false,
2024-09-21 23:43:51 +02:00
'name' => '',
],
], $response, 'data');
$this->assertInertiaHas([
'id' => $activity->subactivities->first()->id,
'name' => 'Pupu',
'is_filterable' => true,
], $response, 'meta.subactivities.0');
$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');
});