Skip to content

Commit 8b605c8

Browse files
committed
Added test case
1 parent 73afcb8 commit 8b605c8

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

tests/Api/ScreensTest.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,27 @@
77
use App\Entity\ScreenLayout;
88
use App\Entity\ScreenLayoutRegions;
99
use App\Entity\Tenant\Playlist;
10+
use App\Entity\Tenant\PlaylistScreenRegion;
1011
use App\Entity\Tenant\Screen;
1112
use App\Entity\Tenant\ScreenGroup;
1213
use App\Tests\AbstractBaseApiTestCase;
14+
use Doctrine\ORM\EntityManager;
1315

1416
class 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

Comments
 (0)