@@ -152,8 +152,12 @@ public function testCreateScreen(): void
152
152
'orientation ' => 'vertical ' ,
153
153
'inScreenGroups ' => '/v2/screens/ ' .$ response ->toArray ()['id ' ].'/screen-groups ' ,
154
154
'enableColorSchemeChange ' => true ,
155
- 'regions ' => ['/v2/screens/ ' .$ response ->toArray ()['id ' ].'/regions/ ' .$ regionUlidLeft .'/playlists ' , '/v2/screens/ ' .$ response ->toArray ()['id ' ].'/regions/ ' .$ regionUlidRight .'/playlists ' ],
156
155
]);
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
+
157
161
$ this ->assertMatchesRegularExpression ('@^/v\d/\w+/([A-Za-z0-9]{26})$@ ' , $ response ->toArray ()['@id ' ]);
158
162
159
163
$ this ->assertMatchesResourceItemJsonSchema (Screen::class);
@@ -183,18 +187,18 @@ public function testCreateInvalidScreen(): void
183
187
184
188
public function testUpdateScreen (): void
185
189
{
190
+ $ client = $ this ->getAuthenticatedClient ('ROLE_ADMIN ' );
191
+
186
192
$ playlistScreenRegionRepository = $ this ->entityManager ->getRepository (PlaylistScreenRegion::class);
187
193
$ playlistScreenRegionCountBefore = $ playlistScreenRegionRepository ->count ([]);
188
194
189
- $ playlistIri = $ this ->findIriBy (Playlist::class, ['title ' => 'playlist_abc_3 ' ]);
195
+ $ playlistIri = $ this ->findIriBy (Playlist::class, ['title ' => 'playlist_screen_test_update ' ]);
190
196
$ playlistUlid = $ this ->iriHelperUtils ->getUlidFromIRI ($ playlistIri );
191
197
$ regionIri = $ this ->findIriBy (ScreenLayoutRegions::class, ['title ' => 'full ' ]);
192
198
$ regionUlid = $ this ->iriHelperUtils ->getUlidFromIRI ($ regionIri );
199
+ $ screenIri = $ this ->findIriBy (Screen::class, ['title ' => 'screen_test_update ' ]);
193
200
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 , [
198
202
'json ' => [
199
203
'title ' => 'Updated title ' ,
200
204
'regions ' => [['playlists ' => [['id ' => $ playlistUlid , 'weight ' => 0 ]], 'regionId ' => $ regionUlid ]],
@@ -207,14 +211,16 @@ public function testUpdateScreen(): void
207
211
$ this ->assertResponseIsSuccessful ();
208
212
$ this ->assertJsonContains ([
209
213
'@type ' => 'Screen ' ,
210
- '@id ' => $ iri ,
214
+ '@id ' => $ screenIri ,
211
215
'title ' => 'Updated title ' ,
212
- 'regions ' => [' /v2/screens/ ' . $ response -> toArray ()[ ' id ' ] .'/regions/ ' .$ regionUlid .'/playlists ' ],
216
+ 'regions ' => [$ screenIri .'/regions/ ' .$ regionUlid .'/playlists ' ],
213
217
]);
214
218
$ playlistScreenRegionCountAfter = $ playlistScreenRegionRepository ->count ([]);
215
219
$ this ->assertEquals ($ playlistScreenRegionCountBefore , $ playlistScreenRegionCountAfter , 'PlaylistScreenRegion count should not change ' );
216
220
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 , [
218
224
'json ' => [
219
225
'title ' => 'Updated title 2 ' ,
220
226
],
@@ -225,11 +231,31 @@ public function testUpdateScreen(): void
225
231
226
232
$ this ->assertResponseIsSuccessful ();
227
233
$ this ->assertJsonContains ([
228
- '@id ' => $ iri ,
234
+ '@id ' => $ screenIri ,
229
235
'title ' => 'Updated title 2 ' ,
230
236
]);
231
237
$ playlistScreenRegionCountAfter = $ playlistScreenRegionRepository ->count ([]);
232
238
$ 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 ' );
233
259
}
234
260
235
261
public function testDeleteScreen (): void
0 commit comments