Files
famous-ly4-ev/app-modules/cms/tests/Feature/CmsReadApiTest.php
T

38 lines
1.2 KiB
PHP
Raw Normal View History

2026-08-30 14:51:57 +07:00
<?php
use Modules\Cms\Models\CmsPage;
test('lists active cms pages', function () {
$active = CmsPage::factory()->create(['is_active' => true]);
CmsPage::factory()->create(['is_active' => false]);
$this->getJson('/api/v1/cms-pages')
->assertSuccessful()
->assertJsonCount(1, 'data')
->assertJsonFragment(['id' => $active->id]);
});
test('does not require authentication', function () {
CmsPage::factory()->create(['is_active' => true]);
$this->getJson('/api/v1/cms-pages')->assertSuccessful();
});
test('shows an active cms page by its page slug', function () {
$page = CmsPage::factory()->create(['page' => 'miniapp_faq', 'is_active' => true]);
$this->getJson('/api/v1/cms-pages/miniapp_faq')
->assertSuccessful()
->assertJsonFragment(['id' => $page->id, 'page' => 'miniapp_faq']);
});
test('returns not found for an inactive page', function () {
CmsPage::factory()->create(['page' => 'miniapp_faq', 'is_active' => false]);
$this->getJson('/api/v1/cms-pages/miniapp_faq')->assertNotFound();
});
test('returns not found for an unknown page slug', function () {
$this->getJson('/api/v1/cms-pages/unknown-page')->assertNotFound();
});