Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

archboard/tidal-ptc

4 stars
1 code files
View archboard/tidal-ptc on GitHub

tests/Feature/SectionTest.php

Open in GitHub
use App\Models\Section;
 
beforeEach(function () {
logIn()->setSchool();
$this->section = test()->seedSection();
});
 
it("can't see section index page without permission", function () {
$this->get(route('sections.index'))
->assertStatus(403);
});
 
it('can show section index page with permission', function () {
$this->givePermission(\App\Enums\Permission::viewAny, Section::class)
->get(route('sections.index'))
->assertOk()
->assertInertia(fn (\Inertia\Testing\AssertableInertia $page) => $page
->component('sections/Index')
->has('title')
->has('sections')
);
});
 
it("can't show view page without permission", function () {
$this->get(route('sections.show', $this->section))
->assertStatus(403);
});
 
it('can show view page with permission', function () {
$this->givePermission(\App\Enums\Permission::view, Section::class)
->get(route('sections.show', $this->section))
->assertOk()
->assertInertia(fn (\Inertia\Testing\AssertableInertia $page) => $page
->component('sections/Show')
->has('title')
->has('section')
);
});
 
it('can edit section', function () {
$this->givePermission(\App\Enums\Permission::update, Section::class)
->get(route('sections.edit', $this->section))
->assertOk()
->assertInertia(fn (\Inertia\Testing\AssertableInertia $page) => $page
->component('sections/Edit')
->has('title')
->has('section')
);
});

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.