create(['id' => 1]); $this->seed(RealBlogContentSeeder::class); $this->assertSame(12, Category::count()); $this->assertSame(26, Tag::count()); $this->assertSame(24, Post::count()); $post = Post::where('slug', 'core-web-vitals-practical-guide')->firstOrFail(); $this->assertSame($user->id, $post->author_id); $this->assertNotNull($post->published_at); $this->assertStringStartsWith('Core Web Vitals', $post->title); $this->assertStringNotContainsStringIgnoringCase('lorem', $post->body); $this->assertStringContainsString('##', $post->body); $this->assertGreaterThan(0, $post->tags()->count()); $faTwin = Post::where('slug', 'core-web-vitals-practical-guide-fa')->firstOrFail(); $this->assertNotNull($faTwin->published_at); // Strict English/Persian mirror: the two versions always cover exactly // the same topics, so no post exists in only one language. $englishCount = Post::where('slug', 'not like', '%-fa')->count(); $persianCount = Post::where('slug', 'like', '%-fa')->count(); $this->assertSame($englishCount, $persianCount); foreach (Post::where('slug', 'not like', '%-fa')->pluck('slug') as $slug) { $this->assertDatabaseHas('posts', ['slug' => $slug.'-fa']); } // Related posts stay inside the reader's language: the English version // of a post never offers a Persian card and vice versa. $this->assertGreaterThan(0, $post->relatedPosts()->count()); $this->assertSame(0, $post->relatedPosts()->where('slug', 'like', '%-fa')->count()); $this->assertSame(0, $faTwin->relatedPosts()->where('slug', 'not like', '%-fa')->count()); } public function test_it_is_safe_to_run_twice(): void { User::factory()->create(['id' => 1]); $this->seed(RealBlogContentSeeder::class); $this->seed(RealBlogContentSeeder::class); $this->assertSame(12, Category::count()); $this->assertSame(26, Tag::count()); $this->assertSame(24, Post::count()); } }