function it_calculates_average_price(ReviewableInterface $reviewable, ReviewInterface $review1, ReviewInterface $review2) { $reviewable->getReviews()->willReturn([$review1, $review2]); $review1->getStatus()->willReturn(ReviewInterface::STATUS_ACCEPTED)->shouldBeCalled(); $review2->getStatus()->willReturn(ReviewInterface::STATUS_ACCEPTED)->shouldBeCalled(); $review1->getRating()->willReturn(4); $review2->getRating()->willReturn(5); $this->calculate($reviewable)->shouldReturn(4.5); }
function it_returns_zero_if_given_reviewable_object_has_reviews_but_none_of_them_is_accepted(ReviewableInterface $reviewable, ReviewInterface $review) { $reviewable->getReviews()->willReturn([$review]); $review->getStatus()->willReturn(ReviewInterface::STATUS_NEW); $this->calculate($reviewable)->shouldReturn(0); }