First commit

This commit is contained in:
Kevin Adametz 2025-10-20 17:50:35 +02:00
commit 7cf3558ba7
12933 changed files with 1180047 additions and 0 deletions

View file

@ -0,0 +1,33 @@
<?php
namespace FluxCms\Core\Tests\Unit\Models;
use FluxCms\Core\Models\BlogPost;
use FluxCms\Core\Models\User;
use Spatie\Tags\Tag;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Orchestra\Testbench\TestCase;
class BlogPostTest extends TestCase
{
use RefreshDatabase;
public function test_blog_post_has_author_relationship()
{
$user = User::factory()->create();
$post = BlogPost::factory()->create([
'author_id' => $user->id,
'author_type' => User::class
]);
$this->assertInstanceOf(User::class, $post->author);
}
public function test_can_attach_and_retrieve_tags()
{
$post = BlogPost::factory()->create();
$post->attachTag('Laravel');
$this->assertCount(1, $post->tags);
$this->assertEquals('Laravel', $post->tags->first()->name);
}
}

View file

@ -0,0 +1,49 @@
<?php
namespace FluxCms\Core\Tests\Unit\Models;
use FluxCms\Core\Models\Page;
use FluxCms\Core\Models\Slug;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Orchestra\Testbench\TestCase;
class PageTest extends TestCase
{
use RefreshDatabase;
public function test_page_has_slugs_relationship()
{
$page = Page::factory()->create();
Slug::factory()->create([
'model_id' => $page->id,
'model_type' => Page::class
]);
$this->assertInstanceOf(Slug::class, $page->slugs->first());
}
public function test_published_scope_returns_only_published_pages()
{
Page::factory()->create(['is_published' => true]);
Page::factory()->create(['is_published' => false]);
$this->assertEquals(1, Page::published()->count());
}
public function test_for_domain_scope_returns_pages_for_correct_domain()
{
Page::factory()->create(['domain_key' => 'domain-a']);
Page::factory()->create(['domain_key' => 'domain-b']);
$this->assertEquals(1, Page::forDomain('domain-a')->count());
}
public function test_by_slug_with_fallback_scope_finds_page_by_slug()
{
$page = Page::factory()->create();
$page->slugs()->create(['locale' => 'en', 'slug' => 'test-slug']);
$foundPage = Page::bySlugWithFallback('test-slug', 'en')->first();
$this->assertNotNull($foundPage);
$this->assertEquals($page->id, $foundPage->id);
}
}