loginUser($user); $subject = RestaurantFactory::createOne([ 'createdBy' => $user, ]); $ratings = RatingFactory::createMany(5, [ 'subject' => $subject, ]); $client->request( 'GET', '/api/ratings', server: ['CONTENT_TYPE' => 'application/json'], content: json_encode(['name' => 'Riviera']), ); $data = json_decode($client->getResponse()->getContent(), true); $this->assertResponseIsSuccessful(); $this->assertCount(5, $data['payload']['ratings']); } public function testCreate(): void { $client = static::createClient(); $repo = static::getContainer()->get(RatingRepository::class); $user = UserFactory::createOne(); $client->loginUser($user); $subject = RestaurantFactory::createOne([ 'createdBy' => $user, ]); $client->request( 'POST', '/api/ratings', server: ['CONTENT_TYPE' => 'application/json'], content: json_encode([ 'subject_id' => $subject->getId(), 'score' => 8, ]), ); $this->assertResponseIsSuccessful(); $this->assertResponseStatusCodeSame(201); $this->assertCount(1, $repo->findAll()); $ratings = static::getContainer() ->get(RatingRepository::class) ->findAllBySubject($subject); $this->assertNotNull($ratings); $this->assertCount(1, $ratings); $this->assertInstanceOf(Rating::class, $ratings[0]); } }