67 lines
2.1 KiB
PHP
67 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Marketing;
|
|
|
|
use App\Models\BlogCategory;
|
|
use App\Models\BlogPost;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Testing\Fluent\AssertableJson;
|
|
use Inertia\Testing\AssertableInertia as Assert;
|
|
use Tests\TestCase;
|
|
|
|
class BlogIndexTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_blog_index_returns_html_excerpts(): void
|
|
{
|
|
$category = BlogCategory::query()->create([
|
|
'slug' => 'blog',
|
|
'name' => [
|
|
'de' => 'Blog',
|
|
'en' => 'Blog',
|
|
],
|
|
'description' => [
|
|
'de' => 'Hochzeitsblog',
|
|
'en' => 'Wedding blog',
|
|
],
|
|
'is_visible' => true,
|
|
]);
|
|
|
|
BlogPost::query()->create([
|
|
'blog_category_id' => $category->id,
|
|
'slug' => 'markdown-vorschau',
|
|
'title' => [
|
|
'de' => 'Markdown Vorschau',
|
|
'en' => 'Markdown Preview',
|
|
],
|
|
'excerpt' => [
|
|
'de' => '**Fette** Vorschau für Gäste',
|
|
'en' => '**Bold** preview for guests',
|
|
],
|
|
'content' => [
|
|
'de' => '## Inhalt',
|
|
'en' => '## Content',
|
|
],
|
|
'is_published' => true,
|
|
'published_at' => Carbon::now()->subDay(),
|
|
]);
|
|
|
|
$response = $this->get('/de/blog');
|
|
|
|
$response->assertOk();
|
|
|
|
$response->assertInertia(fn (Assert $page) => $page
|
|
->component('marketing/Blog')
|
|
->has('posts.data', 1, fn (AssertableJson $post) => $post
|
|
->where('excerpt', '**Fette** Vorschau für Gäste')
|
|
->where('excerpt_html', fn ($value) => is_string($value) && str_contains($value, '<strong>Fette</strong>'))
|
|
->etc()
|
|
)
|
|
->where('posts.links.0.label', __('marketing.blog.pagination.previous', [], 'de'))
|
|
->where('posts.links.2.label', __('marketing.blog.pagination.next', [], 'de'))
|
|
);
|
|
}
|
|
}
|