@@ -91,6 +91,56 @@ public function testUpdateActivity()
9191 $ this ->client ->updateActivity ($ activity );
9292 }
9393
94+ public function testPartialUpdateActivity ()
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+ 'product ' => ["name " => "shoes " , "price " => 9.99 , "color " => "blue " ],
104+ ];
105+ $ response = $ this ->user1 ->addActivity ($ activity_data );
106+ $ activity = $ response ;
107+ $ set = [
108+ "product.name " => "boots " ,
109+ "product.price " => 7.99 ,
110+ "popularity " => 1000 ,
111+ "foo " => ["bar " => ["baz " => "qux " ]],
112+ ];
113+ $ unset = ["product.color " ];
114+
115+ $ this ->client ->doPartialActivityUpdate ($ activity ['id ' ], null , null , $ set , $ unset );
116+
117+ $ updated = $ this ->user1 ->getActivities (0 , 1 )['results ' ][0 ];
118+
119+ $ this ->assertEquals ($ updated ['id ' ], $ activity ['id ' ]);
120+ $ this ->assertEquals ($ updated ['product ' ]['name ' ], 'boots ' );
121+ $ this ->assertEquals ($ updated ['popularity ' ], 1000 );
122+ $ this ->assertFalse (in_array ('color ' , $ updated ['product ' ]));
123+
124+ $ set = [
125+ "foo.bar.baz " => 42 ,
126+ "popularity " => 9000 ,
127+ ];
128+ $ unset = ["product.price " ];
129+
130+ $ this ->client ->doPartialActivityUpdate (null , $ activity ['foreign_id ' ], $ activity ['time ' ], $ set , $ unset );
131+
132+
133+ $ updated_again = $ this ->user1 ->getActivities (0 , 1 )['results ' ][0 ];
134+
135+ $ this ->assertEquals ($ updated_again ['id ' ], $ activity ['id ' ]);
136+ $ this ->assertEquals ($ updated_again ['foo ' ]['bar ' ]['baz ' ], 42 );
137+ $ this ->assertEquals ($ updated_again ['popularity ' ], 9000 );
138+ $ this ->assertEquals ($ updated_again ['product ' ]['name ' ], 'boots ' );
139+ $ this ->assertFalse (in_array ('color ' , $ updated_again ['product ' ]));
140+ $ this ->assertFalse (in_array ('price ' , $ updated_again ['product ' ]));
141+
142+ }
143+
94144 public function testAddToMany ()
95145 {
96146 $ id = Uuid::uuid4 ();
@@ -172,15 +222,15 @@ public function testUnfollowMany()
172222 ['source ' => $ f2 ->getId (), 'target ' => $ u2 ->getId (), 'keep_history ' => true ]
173223 ];
174224 $ batcher ->unfollowMany ($ unfollows );
175-
225+
176226 $ resp = $ f1 ->following ();
177227 $ this ->assertCount (0 , $ resp ['results ' ]);
178228 $ resp = $ f2 ->following ();
179229 $ this ->assertCount (0 , $ resp ['results ' ]);
180230
181231 $ this ->assertCount (0 , $ f1 ->getActivities ()['results ' ]);
182232 $ this ->assertCount (1 , $ f2 ->getActivities ()['results ' ]);
183-
233+
184234 }
185235
186236 public function testReadonlyToken ()
@@ -200,7 +250,7 @@ public function testUserSessionToken()
200250 $ payload = JWT ::decode ($ token , getenv ('STREAM_API_SECRET ' ), array ('HS256 ' ));
201251 $ this ->assertSame ($ payload ->client , 'PHP ' );
202252 }
203-
253+
204254 public function testUserToken ()
205255 {
206256 $ token = $ this ->client ->createUserToken ('user ' );
0 commit comments