135 lines
4 KiB
PHP
135 lines
4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use FluxCms\Core\Models\CmsContent;
|
|
use FluxCms\Core\Services\CmsContentService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
test('seeder creates content entries for all mapped sections', function () {
|
|
$this->seed(\Database\Seeders\CmsContentSeeder::class);
|
|
|
|
expect(CmsContent::count())->toBeGreaterThan(0);
|
|
|
|
$expectedGroups = ['global', 'home', 'immobilien', 'netzwerk', 'faq', 'contact', 'about', 'magazin'];
|
|
|
|
foreach ($expectedGroups as $group) {
|
|
expect(CmsContent::where('group', $group)->exists())
|
|
->toBeTrue("Expected group '{$group}' to exist in CmsContent");
|
|
}
|
|
});
|
|
|
|
test('seeder creates all home sections', function () {
|
|
$this->seed(\Database\Seeders\CmsContentSeeder::class);
|
|
|
|
$homeKeys = CmsContent::where('group', 'home')->pluck('key')->toArray();
|
|
|
|
expect($homeKeys)
|
|
->toContain('hero')
|
|
->toContain('founder_bar')
|
|
->toContain('ecosystem_core')
|
|
->toContain('vision_section');
|
|
});
|
|
|
|
test('seeder stores hero content as translatable json', function () {
|
|
$this->seed(\Database\Seeders\CmsContentSeeder::class);
|
|
|
|
$hero = CmsContent::where('group', 'home')->where('key', 'hero')->first();
|
|
|
|
expect($hero)->not->toBeNull()
|
|
->and($hero->type)->toBe('json');
|
|
|
|
$valueDe = $hero->getTranslation('value', 'de');
|
|
$valueEn = $hero->getTranslation('value', 'en');
|
|
|
|
expect($valueDe)->toBeArray()
|
|
->toHaveKeys(['title', 'subtitle', 'image']);
|
|
|
|
expect($valueEn)->toBeArray()
|
|
->toHaveKeys(['title', 'subtitle', 'image']);
|
|
});
|
|
|
|
test('cms helper returns correct content after seeding', function () {
|
|
$this->seed(\Database\Seeders\CmsContentSeeder::class);
|
|
|
|
$hero = cms('home.hero');
|
|
|
|
expect($hero)->toBeArray()
|
|
->and($hero['title'])->toContain('B2in');
|
|
});
|
|
|
|
test('cms content service getGroup returns all section keys', function () {
|
|
$this->seed(\Database\Seeders\CmsContentSeeder::class);
|
|
|
|
$service = app(CmsContentService::class);
|
|
$homeGroup = $service->getGroup('home');
|
|
|
|
expect($homeGroup)->toBeArray()
|
|
->toHaveKey('hero')
|
|
->toHaveKey('founder_bar')
|
|
->toHaveKey('ecosystem_core');
|
|
|
|
expect($homeGroup['hero'])->toBeArray()
|
|
->toHaveKey('title');
|
|
});
|
|
|
|
test('seeder is idempotent', function () {
|
|
$this->seed(\Database\Seeders\CmsContentSeeder::class);
|
|
$countFirst = CmsContent::count();
|
|
|
|
$this->seed(\Database\Seeders\CmsContentSeeder::class);
|
|
$countSecond = CmsContent::count();
|
|
|
|
expect($countSecond)->toBe($countFirst);
|
|
});
|
|
|
|
test('immobilien sections are seeded correctly', function () {
|
|
$this->seed(\Database\Seeders\CmsContentSeeder::class);
|
|
|
|
$immoKeys = CmsContent::where('group', 'immobilien')->pluck('key')->toArray();
|
|
|
|
expect($immoKeys)
|
|
->toContain('hero_v2')
|
|
->toContain('warum_dubai')
|
|
->toContain('kaufprozess')
|
|
->toContain('bruecke')
|
|
->toContain('mindset')
|
|
->toContain('moebel_vorteil');
|
|
});
|
|
|
|
test('faq content contains questions array', function () {
|
|
$this->seed(\Database\Seeders\CmsContentSeeder::class);
|
|
|
|
$faq = cms('faq.faq');
|
|
|
|
expect($faq)->toBeArray()
|
|
->toHaveKey('questions')
|
|
->and($faq['questions'])->toBeArray()
|
|
->not->toBeEmpty();
|
|
});
|
|
|
|
test('cms_theme_section returns CMS content after seeding', function () {
|
|
$this->seed(\Database\Seeders\CmsContentSeeder::class);
|
|
|
|
$hero = cms_theme_section('hero');
|
|
|
|
expect($hero)->toBeArray()
|
|
->and($hero['title'])->toContain('B2in');
|
|
});
|
|
|
|
test('portfolio is stored under immobilien group for CMS', function () {
|
|
$this->seed(\Database\Seeders\CmsContentSeeder::class);
|
|
|
|
$portfolio = CmsContent::where('group', 'immobilien')->where('key', 'portfolio')->first();
|
|
|
|
expect($portfolio)->not->toBeNull()
|
|
->and($portfolio->type)->toBe('json');
|
|
|
|
$valueDe = $portfolio->getTranslation('value', 'de');
|
|
|
|
expect($valueDe)->toBeArray()
|
|
->toHaveKey('projects')
|
|
->and($valueDe['projects'])->toBeArray();
|
|
});
|