@@ -91,6 +91,83 @@ public function testUpdateActivity()
9191 $ this ->client ->updateActivity ($ activity );
9292 }
9393
94+ public function testBatchPartialUpdateActivity ()
95+ {
96+ $ now = new DateTime ('now ' , new DateTimeZone ('Pacific/Nauru ' ));
97+ $ activity_data = [
98+ 'actor ' => 1 ,
99+ 'verb ' => 'tweet ' ,
100+ 'object ' => 1 ,
101+ 'time ' => $ now ->format (DateTime::ISO8601 ),
102+ 'foreign_id ' => 'batch1 ' ,
103+ 'popularity ' => 100 ,
104+ 'new ' => true ,
105+ ];
106+ $ act1 = $ this ->user1 ->addActivity ($ activity_data );
107+ $ activity_data = [
108+ 'actor ' => 2 ,
109+ 'verb ' => 'tweet ' ,
110+ 'object ' => 2 ,
111+ 'time ' => $ now ->format (DateTime::ISO8601 ),
112+ 'foreign_id ' => 'batch2 ' ,
113+ 'popularity ' => 100 ,
114+ 'new ' => true ,
115+ ];
116+ $ act2 = $ this ->user1 ->addActivity ($ activity_data );
117+ $ payload = [
118+ [
119+ "id " => $ act1 ["id " ],
120+ "set " => ["popularity " => 999 ],
121+ "unset " => ['new ' ],
122+ ],
123+ [
124+ "id " => $ act2 ["id " ],
125+ "set " => ["popularity " => 5 ],
126+ //"unset" => [],
127+ ],
128+ ];
129+ $ response = $ this ->client ->batchPartialActivityUpdate ($ payload );
130+ $ updated = $ this ->user1 ->getActivities (0 ,2 )["results " ];
131+ if ($ updated [0 ]["id " ] == $ act1 ["id " ]){
132+ $ updated1 = $ updated [0 ];
133+ $ updated2 = $ updated [1 ];
134+ } else {
135+ $ updated1 = $ updated [1 ];
136+ $ updated2 = $ updated [0 ];
137+ }
138+ $ this ->assertEquals ($ updated1 ['popularity ' ], 999 );
139+ $ this ->assertFalse (in_array ("new " , $ updated1 ));
140+ $ this ->assertEquals ($ updated2 ['popularity ' ], 5 );
141+ $ this ->assertTrue (in_array ("new " , $ updated2 ));
142+
143+ $ payload = [
144+ [
145+ "foreign_id " => $ act1 ["foreign_id " ],
146+ "time " => $ act1 ["time " ],
147+ "set " => ["popularity " => 1242 ],
148+ ],
149+ [
150+ "foreign_id " => $ act2 ["foreign_id " ],
151+ "time " => $ act2 ["time " ],
152+ "set " => ["popularity " => -3 ],
153+ "unset " => ["new " ],
154+ ],
155+ ];
156+ $ response = $ this ->client ->batchPartialActivityUpdate ($ payload );
157+ $ updated = $ this ->user1 ->getActivities (0 ,2 )["results " ];
158+ if ($ updated [0 ]["id " ] == $ act1 ["id " ]){
159+ $ updated1 = $ updated [0 ];
160+ $ updated2 = $ updated [1 ];
161+ } else {
162+ $ updated1 = $ updated [1 ];
163+ $ updated2 = $ updated [0 ];
164+ }
165+ $ this ->assertEquals ($ updated1 ['popularity ' ], 1242 );
166+ $ this ->assertFalse (in_array ("new " , $ updated1 ));
167+ $ this ->assertEquals ($ updated2 ['popularity ' ], -3 );
168+ $ this ->assertFalse (in_array ("new " , $ updated2 ));
169+ }
170+
94171 public function testPartialUpdateActivity ()
95172 {
96173 $ now = new DateTime ('now ' , new DateTimeZone ('Pacific/Nauru ' ));
@@ -102,8 +179,8 @@ public function testPartialUpdateActivity()
102179 'foreign_id ' => 'batch1 ' ,
103180 'product ' => ["name " => "shoes " , "price " => 9.99 , "color " => "blue " ],
104181 ];
105- $ response = $ this ->user1 ->addActivity ($ activity_data );
106- $ activity = $ response ;
182+ $ activity = $ this ->user1 ->addActivity ($ activity_data );
183+
107184 $ set = [
108185 "product.name " => "boots " ,
109186 "product.price " => 7.99 ,
0 commit comments