55namespace App \Tests \Api ;
66
77use App \Entity \ScreenLayout ;
8+ use App \Entity \ScreenLayoutRegions ;
9+ use App \Entity \Tenant \Playlist ;
810use App \Entity \Tenant \Screen ;
11+ use App \Entity \Tenant \ScreenGroup ;
912use App \Tests \AbstractBaseApiTestCase ;
1013
1114class ScreensTest extends AbstractBaseApiTestCase
@@ -67,11 +70,29 @@ public function testGetItem(): void
6770 ]);
6871 }
6972
73+ /**
74+ * A basic test example.
75+ *
76+ * @group test
77+ *
78+ * @return void
79+ */
7080 public function testCreateScreen (): void
7181 {
7282 $ client = $ this ->getAuthenticatedClient ('ROLE_ADMIN ' );
7383
74- $ layoutIri = $ this ->findIriBy (ScreenLayout::class, []);
84+ $ layoutIri = $ this ->findIriBy (ScreenLayout::class, ['title ' => '2 boxes ' ]);
85+ $ regionIriLeft = $ this ->findIriBy (ScreenLayoutRegions::class, ['title ' => 'Left ' ]);
86+ $ regionIriRight = $ this ->findIriBy (ScreenLayoutRegions::class, ['title ' => 'Right ' ]);
87+ $ screenGroupOneIri = $ this ->findIriBy (ScreenGroup::class, ['title ' => 'screen_group_abc_1 ' ]);
88+ $ screenGroupTwoIri = $ this ->findIriBy (ScreenGroup::class, ['title ' => 'screen_group_abc_2 ' ]);
89+ $ playlistIri = $ this ->findIriBy (Playlist::class, ['title ' => 'playlist_abc_3 ' ]);
90+
91+ $ regionUlidLeft = $ this ->iriHelperUtils ->getUlidFromIRI ($ regionIriLeft );
92+ $ regionUlidRight = $ this ->iriHelperUtils ->getUlidFromIRI ($ regionIriRight );
93+ $ screenGroupOneUlid = $ this ->iriHelperUtils ->getUlidFromIRI ($ screenGroupOneIri );
94+ $ screenGroupTwoUlid = $ this ->iriHelperUtils ->getUlidFromIRI ($ screenGroupTwoIri );
95+ $ playlistUlid = $ this ->iriHelperUtils ->getUlidFromIRI ($ playlistIri );
7596
7697 $ response = $ client ->request ('POST ' , '/v2/screens ' , [
7798 'json ' => [
@@ -82,12 +103,14 @@ public function testCreateScreen(): void
82103 'location ' => 'M2.42 ' ,
83104 'resolution ' => '4K ' ,
84105 'orientation ' => 'vertical ' ,
106+ 'groups ' => [$ screenGroupOneUlid , $ screenGroupTwoUlid ],
107+ 'enableColorSchemeChange ' => true ,
108+ 'regions ' => [['playlists ' => [['id ' => $ playlistUlid , 'weight ' => 0 ]], 'regionId ' => $ regionUlidLeft ], ['playlists ' => [['id ' => $ playlistUlid , 'weight ' => 0 ]], 'regionId ' => $ regionUlidRight ]],
85109 ],
86110 'headers ' => [
87111 'Content-Type ' => 'application/ld+json ' ,
88112 ],
89113 ]);
90-
91114 $ this ->assertResponseStatusCodeSame (201 );
92115 $ this ->assertResponseHeaderSame ('content-type ' , 'application/ld+json; charset=utf-8 ' );
93116 $ this ->assertJsonContains ([
@@ -118,6 +141,9 @@ public function testCreateScreen(): void
118141 'location ' => 'M2.42 ' ,
119142 'resolution ' => '4K ' ,
120143 'orientation ' => 'vertical ' ,
144+ 'inScreenGroups ' => '/v2/screens/todo/screen-groups ' ,
145+ 'enableColorSchemeChange ' => true ,
146+ 'regions ' => ['/v2/screens/todo/regions/ ' .$ regionUlidLeft .'/playlists ' , '/v2/screens/todo/regions/ ' .$ regionUlidLeft .'/playlists ' ],
121147 ]);
122148 $ this ->assertMatchesRegularExpression ('@^/v\d/\w+/([A-Za-z0-9]{26})$@ ' , $ response ->toArray ()['@id ' ]);
123149
0 commit comments