create(['id' => 1]); $this->seed(RealBlogContentSeeder::class); $this->assertSame(10, Category::count()); $this->assertSame(20, Tag::count()); $this->assertSame(12, 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); // English posts and their Persian twins are linked as related posts. $this->assertTrue( $post->relatedPosts()->where('related_posts.related_post_id', $faTwin->id)->exists() ); } 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(10, Category::count()); $this->assertSame(20, Tag::count()); $this->assertSame(12, Post::count()); } }