77use App \Entity \ScreenLayout ;
88use App \Entity \ScreenLayoutRegions ;
99use App \Entity \Tenant \Playlist ;
10+ use App \Entity \Tenant \PlaylistScreenRegion ;
1011use App \Entity \Tenant \Screen ;
1112use App \Entity \Tenant \ScreenGroup ;
1213use App \Tests \AbstractBaseApiTestCase ;
14+ use Doctrine \ORM \EntityManager ;
1315
1416class ScreensTest extends AbstractBaseApiTestCase
1517{
18+ private ?EntityManager $ entityManager ;
19+
20+ protected function setUp (): void
21+ {
22+ parent ::setUp ();
23+
24+ $ kernel = self ::bootKernel ();
25+
26+ $ this ->entityManager = $ kernel ->getContainer ()
27+ ->get ('doctrine ' )
28+ ->getManager ();
29+ }
30+
1631 public function testGetCollection (): void
1732 {
1833 $ response = $ this ->getAuthenticatedClient ('ROLE_ADMIN ' )->request ('GET ' , '/v2/screens?itemsPerPage=5 ' , ['headers ' => ['Content-Type ' => 'application/ld+json ' ]]);
@@ -168,12 +183,21 @@ public function testCreateInvalidScreen(): void
168183
169184 public function testUpdateScreen (): void
170185 {
186+ $ playlistScreenRegionRepository = $ this ->entityManager ->getRepository (PlaylistScreenRegion::class);
187+ $ playlistScreenRegionCountBefore = $ playlistScreenRegionRepository ->count ([]);
188+
189+ $ playlistIri = $ this ->findIriBy (Playlist::class, ['title ' => 'playlist_abc_3 ' ]);
190+ $ playlistUlid = $ this ->iriHelperUtils ->getUlidFromIRI ($ playlistIri );
191+ $ regionIri = $ this ->findIriBy (ScreenLayoutRegions::class, ['title ' => 'full ' ]);
192+ $ regionUlid = $ this ->iriHelperUtils ->getUlidFromIRI ($ regionIri );
193+
171194 $ client = $ this ->getAuthenticatedClient ('ROLE_ADMIN ' );
172- $ iri = $ this ->findIriBy (Screen::class, ['tenant ' => $ this -> tenant ]);
195+ $ iri = $ this ->findIriBy (Screen::class, ['title ' => ' screen_abc_1 ' ]);
173196
174- $ client ->request ('PUT ' , $ iri , [
197+ $ response = $ client ->request ('PUT ' , $ iri , [
175198 'json ' => [
176199 'title ' => 'Updated title ' ,
200+ 'regions ' => [['playlists ' => [['id ' => $ playlistUlid , 'weight ' => 0 ]], 'regionId ' => $ regionUlid ]],
177201 ],
178202 'headers ' => [
179203 'Content-Type ' => 'application/ld+json ' ,
@@ -185,7 +209,10 @@ public function testUpdateScreen(): void
185209 '@type ' => 'Screen ' ,
186210 '@id ' => $ iri ,
187211 'title ' => 'Updated title ' ,
212+ 'regions ' => ['/v2/screens/ ' .$ response ->toArray ()['id ' ].'/regions/ ' .$ regionUlid .'/playlists ' ],
188213 ]);
214+ $ playlistScreenRegionCountAfter = $ playlistScreenRegionRepository ->count ([]);
215+ $ this ->assertEquals ($ playlistScreenRegionCountBefore , $ playlistScreenRegionCountAfter , 'PlaylistScreenRegion count should not change ' );
189216 }
190217
191218 public function testDeleteScreen (): void
0 commit comments