@@ -152,8 +152,12 @@ public function testCreateScreen(): void
152152 'orientation ' => 'vertical ' ,
153153 'inScreenGroups ' => '/v2/screens/ ' .$ response ->toArray ()['id ' ].'/screen-groups ' ,
154154 'enableColorSchemeChange ' => true ,
155- 'regions ' => ['/v2/screens/ ' .$ response ->toArray ()['id ' ].'/regions/ ' .$ regionUlidLeft .'/playlists ' , '/v2/screens/ ' .$ response ->toArray ()['id ' ].'/regions/ ' .$ regionUlidRight .'/playlists ' ],
156155 ]);
156+
157+ $ regions = $ response ->toArray ()['regions ' ];
158+ $ this ->assertTrue (in_array ('/v2/screens/ ' .$ response ->toArray ()['id ' ].'/regions/ ' .$ regionUlidLeft .'/playlists ' , $ regions ));
159+ $ this ->assertTrue (in_array ('/v2/screens/ ' .$ response ->toArray ()['id ' ].'/regions/ ' .$ regionUlidRight .'/playlists ' , $ regions ));
160+
157161 $ this ->assertMatchesRegularExpression ('@^/v\d/\w+/([A-Za-z0-9]{26})$@ ' , $ response ->toArray ()['@id ' ]);
158162
159163 $ this ->assertMatchesResourceItemJsonSchema (Screen::class);
@@ -183,18 +187,18 @@ public function testCreateInvalidScreen(): void
183187
184188 public function testUpdateScreen (): void
185189 {
190+ $ client = $ this ->getAuthenticatedClient ('ROLE_ADMIN ' );
191+
186192 $ playlistScreenRegionRepository = $ this ->entityManager ->getRepository (PlaylistScreenRegion::class);
187193 $ playlistScreenRegionCountBefore = $ playlistScreenRegionRepository ->count ([]);
188194
189- $ playlistIri = $ this ->findIriBy (Playlist::class, ['title ' => 'playlist_abc_3 ' ]);
195+ $ playlistIri = $ this ->findIriBy (Playlist::class, ['title ' => 'playlist_screen_test_update ' ]);
190196 $ playlistUlid = $ this ->iriHelperUtils ->getUlidFromIRI ($ playlistIri );
191197 $ regionIri = $ this ->findIriBy (ScreenLayoutRegions::class, ['title ' => 'full ' ]);
192198 $ regionUlid = $ this ->iriHelperUtils ->getUlidFromIRI ($ regionIri );
199+ $ screenIri = $ this ->findIriBy (Screen::class, ['title ' => 'screen_test_update ' ]);
193200
194- $ client = $ this ->getAuthenticatedClient ('ROLE_ADMIN ' );
195- $ iri = $ this ->findIriBy (Screen::class, ['title ' => 'screen_abc_3 ' ]);
196-
197- $ response = $ client ->request ('PUT ' , $ iri , [
201+ $ client ->request ('PUT ' , $ screenIri , [
198202 'json ' => [
199203 'title ' => 'Updated title ' ,
200204 'regions ' => [['playlists ' => [['id ' => $ playlistUlid , 'weight ' => 0 ]], 'regionId ' => $ regionUlid ]],
@@ -207,14 +211,16 @@ public function testUpdateScreen(): void
207211 $ this ->assertResponseIsSuccessful ();
208212 $ this ->assertJsonContains ([
209213 '@type ' => 'Screen ' ,
210- '@id ' => $ iri ,
214+ '@id ' => $ screenIri ,
211215 'title ' => 'Updated title ' ,
212- 'regions ' => [' /v2/screens/ ' . $ response -> toArray ()[ ' id ' ] .'/regions/ ' .$ regionUlid .'/playlists ' ],
216+ 'regions ' => [$ screenIri .'/regions/ ' .$ regionUlid .'/playlists ' ],
213217 ]);
214218 $ playlistScreenRegionCountAfter = $ playlistScreenRegionRepository ->count ([]);
215219 $ this ->assertEquals ($ playlistScreenRegionCountBefore , $ playlistScreenRegionCountAfter , 'PlaylistScreenRegion count should not change ' );
216220
217- $ response = $ client ->request ('PUT ' , $ iri , [
221+ // Test that PUT without regions property will not change playlist screen regions.
222+
223+ $ client ->request ('PUT ' , $ screenIri , [
218224 'json ' => [
219225 'title ' => 'Updated title 2 ' ,
220226 ],
@@ -225,11 +231,31 @@ public function testUpdateScreen(): void
225231
226232 $ this ->assertResponseIsSuccessful ();
227233 $ this ->assertJsonContains ([
228- '@id ' => $ iri ,
234+ '@id ' => $ screenIri ,
229235 'title ' => 'Updated title 2 ' ,
230236 ]);
231237 $ playlistScreenRegionCountAfter = $ playlistScreenRegionRepository ->count ([]);
232238 $ this ->assertEquals ($ playlistScreenRegionCountBefore , $ playlistScreenRegionCountAfter , 'PlaylistScreenRegion count should not change ' );
239+
240+ // Test that region can be cleared.
241+
242+ $ client ->request ('PUT ' , $ screenIri , [
243+ 'json ' => [
244+ 'title ' => 'Updated title 3 ' ,
245+ 'regions ' => [['playlists ' => [], 'regionId ' => $ regionUlid ]],
246+ ],
247+ 'headers ' => [
248+ 'Content-Type ' => 'application/ld+json ' ,
249+ ],
250+ ]);
251+
252+ $ this ->assertResponseIsSuccessful ();
253+ $ this ->assertJsonContains ([
254+ '@id ' => $ screenIri ,
255+ 'title ' => 'Updated title 3 ' ,
256+ ]);
257+ $ playlistScreenRegionCountAfter = $ playlistScreenRegionRepository ->count ([]);
258+ $ this ->assertEquals ($ playlistScreenRegionCountBefore - 1 , $ playlistScreenRegionCountAfter , 'PlaylistScreenRegion count should go 1 down ' );
233259 }
234260
235261 public function testDeleteScreen (): void
0 commit comments