@@ -148,6 +148,42 @@ public function test_getReceivedReview_can_retrieve_unapproved_review_when_inclu
148
148
$ this ->assertEquals (3 , $ review ->rating );
149
149
}
150
150
151
+ public function test_getLatestReceivedReviews_retrieves_latest_approved_reviews_by_default ()
152
+ {
153
+ $ newMentee = Mentor::factory ()->create ();
154
+
155
+ $ newReview = $ newMentee ->review ($ this ->mentor , 4 , 'nice!!! ' );
156
+
157
+ $ reviews = $ this ->mentor ->getLatestReceivedReviews ();
158
+
159
+ $ this ->assertCount (3 , $ reviews );
160
+ $ this ->assertEquals ($ reviews ->first ()->id , $ newReview ->id );
161
+ }
162
+
163
+ public function test_getLatestReceivedReviews_not_returning_unapproved_reviews_by_default ()
164
+ {
165
+ $ newMentee = Mentor::factory ()->create ();
166
+
167
+ $ newReview = $ newMentee ->review ($ this ->mentor , 4 , 'nice!!! ' , isApproved: false );
168
+
169
+ $ reviews = $ this ->mentor ->getLatestReceivedReviews ();
170
+
171
+ $ this ->assertCount (2 , $ reviews );
172
+ $ this ->assertNotEquals ($ reviews ->first ()->id , $ newReview ->id );
173
+ }
174
+
175
+ public function test_getLatestReceivedReviews_can_retrieves_unapproved_reviews_when_includeUnapproved_is_true ()
176
+ {
177
+ $ newMentee = Mentor::factory ()->create ();
178
+
179
+ $ newReview = $ newMentee ->review ($ this ->mentor , 4 , 'nice!!! ' , isApproved: false );
180
+
181
+ $ reviews = $ this ->mentor ->getLatestReceivedReviews (includeUnapproved: true );
182
+
183
+ $ this ->assertCount (3 , $ reviews );
184
+ $ this ->assertEquals ($ reviews ->first ()->id , $ newReview ->id );
185
+ }
186
+
151
187
public function test_a_reviewable_can_display_its_review_summary ()
152
188
{
153
189
$ this ->assertTrue ($ this ->mentor ->reviewSummary ->exists ());
0 commit comments