Skip to content

Commit 10d1308

Browse files
author
Sine Jespersen
committed
2314: test with todo
1 parent a1f35fe commit 10d1308

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ docker run --rm -v .:/app --workdir=/app node:18 npm run coding-standards-apply
297297
Run automated tests:
298298

299299
```shell
300-
docker compose exec phpfpm composer tests
300+
docker compose exec phpfpm composer test setup
301+
docker compose exec phpfpm composer test
301302
```
302303

303304
Disable or hide deprecation warnings using the [`SYMFONY_DEPRECATIONS_HELPER` environment

tests/Api/ScreensTest.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
namespace App\Tests\Api;
66

77
use App\Entity\ScreenLayout;
8+
use App\Entity\ScreenLayoutRegions;
9+
use App\Entity\Tenant\Playlist;
810
use App\Entity\Tenant\Screen;
11+
use App\Entity\Tenant\ScreenGroup;
912
use App\Tests\AbstractBaseApiTestCase;
1013

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

Comments
 (0)