client = static::createClient(); $this->bootDatabase(); $this->bootFaker(); $this->getFaker()->unique(); } public function testPostDetail(): void { $post = $this->createPost(1); $comments = []; $comments[] = $this->createComment(1, $post); $comments[] = $this->createComment(2, $post); $this->client->request('GET', '/posts/detail/1'); $this->assertResponseIsSuccessful(); $this->assertSelectorTextSame('.t-title', $post->title); $this->assertSelectorTextSame('.t-content', $post->body); $this->assertSelectorTextSame('.t-user-name', $post->user->name); $this->assertSelectorTextSame('.t-user-email', $post->user->email); $this->assertSelectorTextSame('.t-user-website', $post->user->website); $this->assertSelectorTextSame('.t-user-company', $post->user->company->name); $this->assertSelectorCount(2, '.t-comment'); $this->assertSelectorTextSame('.t-comment:nth-child(1) .t-comment-name', $comments[0]->name); $this->assertSelectorTextSame('.t-comment:nth-child(1) .t-comment-email', $comments[0]->email); $this->assertSelectorTextSame('.t-comment:nth-child(1) .t-comment-body', $comments[0]->body); } public function testPostDetailNotFound(): void { $this->client->request('GET', '/posts/detail/100'); $this->assertResponseStatusCodeSame(404); } }