/
evo
/
docviz
Обзор
Документация
Войти
/
evo
/
docviz
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
tests/Unit/StaticPageModelTest.php
65 строк
2 KB
evo
Checkout for tests
08 фев 2026, 09:59
Верифицирован
08 фев 2026, 09:59
ccd7e85
Код
Авторство
О чём код?
<?php namespace Tests\Unit; use App\Models\StaticPage; use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class StaticPageModelTest extends TestCase { use RefreshDatabase; public function test_static_page_fillable_attributes(): void { $fillable = (new StaticPage())->getFillable(); $this->assertContains('slug', $fillable); $this->assertContains('title', $fillable); $this->assertContains('content', $fillable); $this->assertContains('is_published', $fillable); $this->assertContains('updated_by', $fillable); } public function test_static_page_uses_slug_as_route_key(): void { $page = StaticPage::factory()->create(); $this->assertSame('slug', $page->getRouteKeyName()); } public function test_static_page_is_published_cast(): void { $page = StaticPage::factory()->create(['is_published' => true]); $this->assertTrue($page->is_published); $this->assertIsBool($page->is_published); } public function test_static_page_factory_creates_valid_model(): void { $page = StaticPage::factory()->create(); $this->assertDatabaseHas('static_pages', [ 'id' => $page->id, 'slug' => $page->slug, 'title' => $page->title, 'is_published' => true, ]); } public function test_static_page_can_be_unpublished(): void { $page = StaticPage::factory()->unpublished()->create(); $this->assertFalse($page->is_published); } public function test_static_page_can_have_null_content(): void { $page = StaticPage::factory()->create(['content' => null]); $this->assertNull($page->content); } }