@@ -33,10 +33,11 @@ public function testShouldReturnListWithSameSize()
33
33
$ mockRequest ->set_param ('testMode ' , give_is_test_mode ());
34
34
35
35
$ listDonations = give (ListDonations::class);
36
+ $ expectedItems = $ this ->getMockColumns ($ donations );
36
37
37
38
$ response = $ listDonations ->handleRequest ($ mockRequest );
38
39
39
- $ this ->assertSameSize ( $ donations , $ response ->data ['items ' ]);
40
+ $ this ->assertSame ( $ expectedItems , $ response ->data ['items ' ]);
40
41
}
41
42
42
43
/**
@@ -58,7 +59,39 @@ public function testShouldReturnListWithSameData()
58
59
$ mockRequest ->set_param ('sortDirection ' , $ sortDirection );
59
60
$ mockRequest ->set_param ('testMode ' , give_is_test_mode ());
60
61
61
- $ expectedItems = $ this ->getMockColumns ($ donations ,$ sortDirection );
62
+ $ expectedItems = $ this ->getMockColumns ($ donations , $ sortDirection );
63
+
64
+ $ listDonations = give (ListDonations::class);
65
+
66
+ $ response = $ listDonations ->handleRequest ($ mockRequest );
67
+
68
+ $ this ->assertSame ($ expectedItems , $ response ->data ['items ' ]);
69
+ }
70
+
71
+ /**
72
+ * @unreleased
73
+ *
74
+ * @return void
75
+ * @throws Exception
76
+ */
77
+ public function testShouldReturnFilteredListByDonorId ()
78
+ {
79
+ $ donations = Donation::factory ()->count (5 )->create ();
80
+ $ donorId = $ donations [0 ]->donorId ;
81
+
82
+ $ mockRequest = $ this ->getMockRequest ();
83
+ // set_params
84
+ $ mockRequest ->set_param ('page ' , 1 );
85
+ $ mockRequest ->set_param ('perPage ' , 30 );
86
+ $ mockRequest ->set_param ('locale ' , 'us-US ' );
87
+ $ mockRequest ->set_param ('donor ' , (string )$ donorId );
88
+ $ mockRequest ->set_param ('testMode ' , give_is_test_mode ());
89
+
90
+ $ expectedItems = $ this ->getMockColumns (
91
+ array_filter ($ donations , function ($ donation ) use ($ donorId ) {
92
+ return $ donation ->donorId === $ donorId ;
93
+ })
94
+ );
62
95
63
96
$ listDonations = give (ListDonations::class);
64
97
0 commit comments