From 1de2171f63df7df9a40402519ae24ecd4686195e Mon Sep 17 00:00:00 2001 From: BacLuc Date: Thu, 13 Jul 2023 21:53:41 +0200 Subject: [PATCH] api: add snapshot tests of the responses That we are sure that we don't accidentally change the interface for the frontend which may lead to n+1 requests. --- api/composer.json | 5 + api/composer.lock | 70 ++- .../Api/Activities/CreateActivityTest.php | 18 + .../Api/Activities/ListActivitiesTest.php | 18 + api/tests/Api/Activities/ReadActivityTest.php | 20 + .../Api/Activities/UpdateActivityTest.php | 23 + ...ateActivityResponseMatchesSnapshot__1.json | 213 +++++++ ..._testListActivitiesMatchesSnapshot__1.json | 508 ++++++++++++++++ ...Test__testGetSingleMatchesSnapshot__1.json | 558 ++++++++++++++++++ ...__testPatchActivityMatchesSnapshot__1.json | 554 +++++++++++++++++ api/tests/Api/Camps/ListCampsTest.php | 18 + api/tests/Api/Camps/ReadCampTest.php | 20 + ...Test__testListCampsMatchesSnapshot__1.json | 164 +++++ ...__testGetSingleCampMatchesSnapshot__1.json | 418 +++++++++++++ api/tests/Api/ECampApiTestCase.php | 24 + 15 files changed, 2630 insertions(+), 1 deletion(-) create mode 100644 api/tests/Api/Activities/__snapshots__/CreateActivityTest__testCreateActivityResponseMatchesSnapshot__1.json create mode 100644 api/tests/Api/Activities/__snapshots__/ListActivitiesTest__testListActivitiesMatchesSnapshot__1.json create mode 100644 api/tests/Api/Activities/__snapshots__/ReadActivityTest__testGetSingleMatchesSnapshot__1.json create mode 100644 api/tests/Api/Activities/__snapshots__/UpdateActivityTest__testPatchActivityMatchesSnapshot__1.json create mode 100644 api/tests/Api/Camps/__snapshots__/ListCampsTest__testListCampsMatchesSnapshot__1.json create mode 100644 api/tests/Api/Camps/__snapshots__/ReadCampTest__testGetSingleCampMatchesSnapshot__1.json diff --git a/api/composer.json b/api/composer.json index 79d3fec3a53..f3cc4cfe955 100644 --- a/api/composer.json +++ b/api/composer.json @@ -56,6 +56,7 @@ "phpstan/phpstan": "1.10.25", "phpunit/phpunit": "9.6.10", "rector/rector": "0.17.2", + "spatie/phpunit-snapshot-assertions": "4.2.16", "symfony/browser-kit": "6.3.0", "symfony/css-selector": "6.3.0", "symfony/debug-bundle": "6.3.0", @@ -112,6 +113,10 @@ "Composer\\Config::disableProcessTimeout", "bin/phpunit -d memory_limit=-1" ], + "update-snapshots": [ + "Composer\\Config::disableProcessTimeout", + "bin/phpunit -d memory_limit=-1 --update-snapshots" + ], "auto-scripts": { "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd" diff --git a/api/composer.lock b/api/composer.lock index 1045e151ee0..0bcee4e655b 100644 --- a/api/composer.lock +++ b/api/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fdaca76bcb9fc4cff3c8eb3677b5b5dc", + "content-hash": "57381e10ebbb5d3fe7320bf9329addae", "packages": [ { "name": "api-platform/core", @@ -13432,6 +13432,74 @@ ], "time": "2023-05-11T14:04:07+00:00" }, + { + "name": "spatie/phpunit-snapshot-assertions", + "version": "4.2.16", + "source": { + "type": "git", + "url": "https://github.com/spatie/phpunit-snapshot-assertions.git", + "reference": "4c325139313c06b656ba10d5b60306c0de728c1f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/phpunit-snapshot-assertions/zipball/4c325139313c06b656ba10d5b60306c0de728c1f", + "reference": "4c325139313c06b656ba10d5b60306c0de728c1f", + "shasum": "" + }, + "require": { + "composer-runtime-api": "^2.0", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "php": "^7.3|^7.4|^8.0", + "phpunit/phpunit": "^8.3|^9.0", + "symfony/property-access": "^4.0|^5.0|^6.0", + "symfony/serializer": "^4.0|^5.0|^6.0", + "symfony/yaml": "^4.0|^5.0|^6.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Snapshots\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sebastian De Deyne", + "email": "sebastian@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Snapshot testing with PHPUnit", + "homepage": "https://github.com/spatie/phpunit-snapshot-assertions", + "keywords": [ + "assert", + "phpunit", + "phpunit-snapshot-assertions", + "snapshot", + "spatie", + "testing" + ], + "support": { + "issues": "https://github.com/spatie/phpunit-snapshot-assertions/issues", + "source": "https://github.com/spatie/phpunit-snapshot-assertions/tree/4.2.16" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + } + ], + "time": "2022-10-10T15:58:50+00:00" + }, { "name": "symfony/browser-kit", "version": "v6.3.0", diff --git a/api/tests/Api/Activities/CreateActivityTest.php b/api/tests/Api/Activities/CreateActivityTest.php index 1ff1aca8d96..50e0fddbf4e 100644 --- a/api/tests/Api/Activities/CreateActivityTest.php +++ b/api/tests/Api/Activities/CreateActivityTest.php @@ -7,6 +7,11 @@ use App\Entity\Activity; use App\Entity\User; use App\Tests\Api\ECampApiTestCase; +use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; /** * @internal @@ -76,6 +81,19 @@ public function testCreateActivityIsAllowedForManager() { $this->assertJsonContains($this->getExampleReadPayload()); } + /** + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + */ + public function testCreateActivityResponseMatchesSnapshot() { + $response = static::createClientWithCredentials()->request('POST', '/activities', ['json' => $this->getExampleWritePayload()]); + + $this->assertMatchesResponseSnapshot($response); + } + public function testCreateActivityInCampPrototypeIsDeniedForUnrelatedUser() { static::createClientWithCredentials()->request('POST', '/activities', ['json' => $this->getExampleWritePayload([ 'category' => $this->getIriFor('category1campPrototype'), diff --git a/api/tests/Api/Activities/ListActivitiesTest.php b/api/tests/Api/Activities/ListActivitiesTest.php index 0d4a4b7d807..46558a4e243 100644 --- a/api/tests/Api/Activities/ListActivitiesTest.php +++ b/api/tests/Api/Activities/ListActivitiesTest.php @@ -3,6 +3,11 @@ namespace App\Tests\Api\Activities; use App\Tests\Api\ECampApiTestCase; +use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; /** * @internal @@ -40,6 +45,19 @@ public function testListActivitiesIsAllowedForLoggedInUserButFiltered() { ], $response->toArray()['_links']['items']); } + /** + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + */ + public function testListActivitiesMatchesSnapshot() { + $response = static::createClientWithCredentials()->request('GET', '/activities'); + + $this->assertMatchesResponseSnapshot($response); + } + public function testListActivitiesFilteredByCampIsAllowedForCollaborator() { $camp = static::$fixtures['camp1']; $response = static::createClientWithCredentials()->request('GET', '/activities?camp=%2Fcamps%2F'.$camp->getId()); diff --git a/api/tests/Api/Activities/ReadActivityTest.php b/api/tests/Api/Activities/ReadActivityTest.php index 50b869c41fd..c6eeec857a6 100644 --- a/api/tests/Api/Activities/ReadActivityTest.php +++ b/api/tests/Api/Activities/ReadActivityTest.php @@ -4,6 +4,11 @@ use App\Entity\Activity; use App\Tests\Api\ECampApiTestCase; +use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; /** * @internal @@ -116,6 +121,21 @@ public function testGetSingleActivityIsAllowedForManager() { ]); } + /** + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + */ + public function testGetSingleMatchesSnapshot() { + /** @var Activity $activity */ + $activity = static::$fixtures['activity1']; + $response = static::createClientWithCredentials()->request('GET', '/activities/'.$activity->getId()); + + $this->assertMatchesResponseSnapshot($response); + } + public function testGetSingleActivityFromCampPrototypeIsAllowedForUnrelatedUser() { /** @var Activity $activity */ $activity = static::$fixtures['activity1campPrototype']; diff --git a/api/tests/Api/Activities/UpdateActivityTest.php b/api/tests/Api/Activities/UpdateActivityTest.php index 9e6d9ea4080..b8c94bfe247 100644 --- a/api/tests/Api/Activities/UpdateActivityTest.php +++ b/api/tests/Api/Activities/UpdateActivityTest.php @@ -3,6 +3,11 @@ namespace App\Tests\Api\Activities; use App\Tests\Api\ECampApiTestCase; +use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; /** * @internal @@ -106,6 +111,24 @@ public function testPatchActivityIsAllowedForManager() { ]); } + /** + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + */ + public function testPatchActivityMatchesSnapshot() { + $activity = static::$fixtures['activity1']; + $response = static::createClientWithCredentials()->request('PATCH', '/activities/'.$activity->getId(), ['json' => [ + 'title' => 'Hello World', + 'location' => 'Stoos', + 'category' => $this->getIriFor('category2'), + ], 'headers' => ['Content-Type' => 'application/merge-patch+json']]); + + $this->assertMatchesResponseSnapshot($response); + } + public function testPatchActivityFromCampPrototypeIsDeniedForUnrelatedUser() { $activity = static::$fixtures['activity1campPrototype']; static::createClientWithCredentials()->request('PATCH', '/activities/'.$activity->getId(), ['json' => [ diff --git a/api/tests/Api/Activities/__snapshots__/CreateActivityTest__testCreateActivityResponseMatchesSnapshot__1.json b/api/tests/Api/Activities/__snapshots__/CreateActivityTest__testCreateActivityResponseMatchesSnapshot__1.json new file mode 100644 index 00000000000..1b65af65544 --- /dev/null +++ b/api/tests/Api/Activities/__snapshots__/CreateActivityTest__testCreateActivityResponseMatchesSnapshot__1.json @@ -0,0 +1,213 @@ +{ + "_links": { + "self": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + }, + "category": { + "href": "escaped_value" + }, + "progressLabel": "escaped_value", + "activityResponsibles": { + "href": "escaped_value" + }, + "rootContentNode": { + "href": "escaped_value" + }, + "contentNodes": { + "href": "escaped_value" + } + }, + "_embedded": { + "rootContentNode": { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": "escaped_value", + "children": [ + { + "href": "escaped_value" + } + ], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + "category": { + "_links": { + "self": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + }, + "preferredContentTypes": { + "href": "escaped_value" + }, + "rootContentNode": { + "href": "escaped_value" + }, + "contentNodes": { + "href": "escaped_value" + } + }, + "_embedded": { + "rootContentNode": { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": "escaped_value", + "children": [ + { + "href": "escaped_value" + } + ], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + } + }, + "short": "escaped_value", + "name": "escaped_value", + "color": "escaped_value", + "numberingStyle": "escaped_value", + "id": "escaped_value" + }, + "progressLabel": "escaped_value", + "contentNodes": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": "escaped_value", + "children": [ + { + "href": "escaped_value" + } + ], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + } + ], + "scheduleEntries": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "day": { + "href": "escaped_value" + } + }, + "left": "escaped_value", + "width": "escaped_value", + "id": "escaped_value", + "start": "escaped_value", + "end": "escaped_value", + "dayNumber": "escaped_value", + "scheduleEntryNumber": "escaped_value", + "number": "escaped_value" + } + ], + "activityResponsibles": [] + }, + "title": "escaped_value", + "location": "escaped_value", + "id": "escaped_value" +} diff --git a/api/tests/Api/Activities/__snapshots__/ListActivitiesTest__testListActivitiesMatchesSnapshot__1.json b/api/tests/Api/Activities/__snapshots__/ListActivitiesTest__testListActivitiesMatchesSnapshot__1.json new file mode 100644 index 00000000000..3f1765fbc5c --- /dev/null +++ b/api/tests/Api/Activities/__snapshots__/ListActivitiesTest__testListActivitiesMatchesSnapshot__1.json @@ -0,0 +1,508 @@ +{ + "_links": { + "self": { + "href": "escaped_value" + }, + "items": [ + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + } + ] + }, + "totalItems": "escaped_value", + "_embedded": { + "items": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + }, + "category": { + "href": "escaped_value" + }, + "progressLabel": "escaped_value", + "activityResponsibles": { + "href": "escaped_value" + }, + "rootContentNode": { + "href": "escaped_value" + }, + "contentNodes": { + "href": "escaped_value" + } + }, + "_embedded": { + "rootContentNode": { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": "escaped_value", + "children": [ + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + } + ], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + }, + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + "progressLabel": "escaped_value", + "scheduleEntries": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "day": { + "href": "escaped_value" + } + }, + "left": "escaped_value", + "width": "escaped_value", + "id": "escaped_value", + "start": "escaped_value", + "end": "escaped_value", + "dayNumber": "escaped_value", + "scheduleEntryNumber": "escaped_value", + "number": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "day": { + "href": "escaped_value" + } + }, + "left": "escaped_value", + "width": "escaped_value", + "id": "escaped_value", + "start": "escaped_value", + "end": "escaped_value", + "dayNumber": "escaped_value", + "scheduleEntryNumber": "escaped_value", + "number": "escaped_value" + } + ], + "activityResponsibles": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "campCollaboration": { + "href": "escaped_value" + } + }, + "id": "escaped_value" + } + ] + }, + "title": "escaped_value", + "location": "escaped_value", + "id": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + }, + "category": { + "href": "escaped_value" + }, + "progressLabel": "escaped_value", + "activityResponsibles": { + "href": "escaped_value" + }, + "rootContentNode": { + "href": "escaped_value" + }, + "contentNodes": { + "href": "escaped_value" + } + }, + "_embedded": { + "rootContentNode": { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": "escaped_value", + "children": [ + { + "href": "escaped_value" + } + ], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + "progressLabel": "escaped_value", + "scheduleEntries": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "day": { + "href": "escaped_value" + } + }, + "left": "escaped_value", + "width": "escaped_value", + "id": "escaped_value", + "start": "escaped_value", + "end": "escaped_value", + "dayNumber": "escaped_value", + "scheduleEntryNumber": "escaped_value", + "number": "escaped_value" + } + ], + "activityResponsibles": [] + }, + "title": "escaped_value", + "location": "escaped_value", + "id": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + }, + "category": { + "href": "escaped_value" + }, + "progressLabel": { + "href": "escaped_value" + }, + "activityResponsibles": { + "href": "escaped_value" + }, + "rootContentNode": { + "href": "escaped_value" + }, + "contentNodes": { + "href": "escaped_value" + } + }, + "_embedded": { + "rootContentNode": { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": "escaped_value", + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + "progressLabel": { + "_links": { + "self": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + } + }, + "position": "escaped_value", + "title": "escaped_value", + "id": "escaped_value" + }, + "scheduleEntries": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "day": { + "href": "escaped_value" + } + }, + "left": "escaped_value", + "width": "escaped_value", + "id": "escaped_value", + "start": "escaped_value", + "end": "escaped_value", + "dayNumber": "escaped_value", + "scheduleEntryNumber": "escaped_value", + "number": "escaped_value" + } + ], + "activityResponsibles": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "campCollaboration": { + "href": "escaped_value" + } + }, + "id": "escaped_value" + } + ] + }, + "title": "escaped_value", + "location": "escaped_value", + "id": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + }, + "category": { + "href": "escaped_value" + }, + "progressLabel": "escaped_value", + "activityResponsibles": { + "href": "escaped_value" + }, + "rootContentNode": { + "href": "escaped_value" + }, + "contentNodes": { + "href": "escaped_value" + } + }, + "_embedded": { + "rootContentNode": { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": "escaped_value", + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + "progressLabel": "escaped_value", + "scheduleEntries": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "day": { + "href": "escaped_value" + } + }, + "left": "escaped_value", + "width": "escaped_value", + "id": "escaped_value", + "start": "escaped_value", + "end": "escaped_value", + "dayNumber": "escaped_value", + "scheduleEntryNumber": "escaped_value", + "number": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "day": { + "href": "escaped_value" + } + }, + "left": "escaped_value", + "width": "escaped_value", + "id": "escaped_value", + "start": "escaped_value", + "end": "escaped_value", + "dayNumber": "escaped_value", + "scheduleEntryNumber": "escaped_value", + "number": "escaped_value" + } + ], + "activityResponsibles": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "campCollaboration": { + "href": "escaped_value" + } + }, + "id": "escaped_value" + } + ] + }, + "title": "escaped_value", + "location": "escaped_value", + "id": "escaped_value" + } + ] + } +} diff --git a/api/tests/Api/Activities/__snapshots__/ReadActivityTest__testGetSingleMatchesSnapshot__1.json b/api/tests/Api/Activities/__snapshots__/ReadActivityTest__testGetSingleMatchesSnapshot__1.json new file mode 100644 index 00000000000..420422bb139 --- /dev/null +++ b/api/tests/Api/Activities/__snapshots__/ReadActivityTest__testGetSingleMatchesSnapshot__1.json @@ -0,0 +1,558 @@ +{ + "_links": { + "self": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + }, + "category": { + "href": "escaped_value" + }, + "progressLabel": "escaped_value", + "activityResponsibles": { + "href": "escaped_value" + }, + "rootContentNode": { + "href": "escaped_value" + }, + "contentNodes": { + "href": "escaped_value" + } + }, + "_embedded": { + "rootContentNode": { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": "escaped_value", + "children": [ + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + } + ], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + }, + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + "category": { + "_links": { + "self": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + }, + "preferredContentTypes": { + "href": "escaped_value" + }, + "rootContentNode": { + "href": "escaped_value" + }, + "contentNodes": { + "href": "escaped_value" + } + }, + "_embedded": { + "rootContentNode": { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": "escaped_value", + "children": [ + { + "href": "escaped_value" + } + ], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + } + }, + "short": "escaped_value", + "name": "escaped_value", + "color": "escaped_value", + "numberingStyle": "escaped_value", + "id": "escaped_value" + }, + "progressLabel": "escaped_value", + "contentNodes": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "materialItems": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "_embedded": { + "materialItems": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "materialList": { + "href": "escaped_value" + }, + "period": "escaped_value", + "materialNode": { + "href": "escaped_value" + } + }, + "article": "escaped_value", + "quantity": "escaped_value", + "unit": "escaped_value", + "id": "escaped_value" + } + ] + }, + "data": "escaped_value", + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "options": { + "key1": { + "checked": "escaped_value" + } + } + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "options": { + "key1": { + "checked": "escaped_value" + }, + "key2": { + "checked": "escaped_value" + } + } + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "html": "escaped_value" + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "html": "escaped_value" + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "html": "escaped_value" + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "sections": { + "ab9740f6-61a4-4cae-b574-a73aeb7c5ea0": { + "column1": "escaped_value", + "column3": "escaped_value", + "position": "escaped_value", + "column2Html": "escaped_value" + }, + "cb26d76a-9e3b-43f0-a7c4-0f2ad0ea8029": { + "column1": "escaped_value", + "column3": "escaped_value", + "position": "escaped_value", + "column2Html": "escaped_value" + } + } + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "sections": { + "ea6f1e5d-0ef7-454f-8ae0-1d9b3bfd1177": { + "column1": "escaped_value", + "column3": "escaped_value", + "position": "escaped_value", + "column2Html": "escaped_value" + } + } + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": "escaped_value", + "children": [ + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + } + ], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + }, + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [ + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + } + ], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + }, + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + } + ], + "scheduleEntries": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "day": { + "href": "escaped_value" + } + }, + "left": "escaped_value", + "width": "escaped_value", + "id": "escaped_value", + "start": "escaped_value", + "end": "escaped_value", + "dayNumber": "escaped_value", + "scheduleEntryNumber": "escaped_value", + "number": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "day": { + "href": "escaped_value" + } + }, + "left": "escaped_value", + "width": "escaped_value", + "id": "escaped_value", + "start": "escaped_value", + "end": "escaped_value", + "dayNumber": "escaped_value", + "scheduleEntryNumber": "escaped_value", + "number": "escaped_value" + } + ], + "activityResponsibles": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "campCollaboration": { + "href": "escaped_value" + } + }, + "id": "escaped_value" + } + ] + }, + "title": "escaped_value", + "location": "escaped_value", + "id": "escaped_value" +} diff --git a/api/tests/Api/Activities/__snapshots__/UpdateActivityTest__testPatchActivityMatchesSnapshot__1.json b/api/tests/Api/Activities/__snapshots__/UpdateActivityTest__testPatchActivityMatchesSnapshot__1.json new file mode 100644 index 00000000000..6bf4e6790cf --- /dev/null +++ b/api/tests/Api/Activities/__snapshots__/UpdateActivityTest__testPatchActivityMatchesSnapshot__1.json @@ -0,0 +1,554 @@ +{ + "_links": { + "self": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + }, + "category": { + "href": "escaped_value" + }, + "progressLabel": "escaped_value", + "activityResponsibles": { + "href": "escaped_value" + }, + "rootContentNode": { + "href": "escaped_value" + }, + "contentNodes": { + "href": "escaped_value" + } + }, + "_embedded": { + "rootContentNode": { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": "escaped_value", + "children": [ + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + } + ], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + }, + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + "category": { + "_links": { + "self": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + }, + "preferredContentTypes": { + "href": "escaped_value" + }, + "rootContentNode": { + "href": "escaped_value" + }, + "contentNodes": { + "href": "escaped_value" + } + }, + "_embedded": { + "rootContentNode": { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": "escaped_value", + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + } + }, + "short": "escaped_value", + "name": "escaped_value", + "color": "escaped_value", + "numberingStyle": "escaped_value", + "id": "escaped_value" + }, + "progressLabel": "escaped_value", + "contentNodes": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "materialItems": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "_embedded": { + "materialItems": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "materialList": { + "href": "escaped_value" + }, + "period": "escaped_value", + "materialNode": { + "href": "escaped_value" + } + }, + "article": "escaped_value", + "quantity": "escaped_value", + "unit": "escaped_value", + "id": "escaped_value" + } + ] + }, + "data": "escaped_value", + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "options": { + "key1": { + "checked": "escaped_value" + } + } + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "options": { + "key1": { + "checked": "escaped_value" + }, + "key2": { + "checked": "escaped_value" + } + } + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "html": "escaped_value" + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "html": "escaped_value" + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "html": "escaped_value" + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "sections": { + "ab9740f6-61a4-4cae-b574-a73aeb7c5ea0": { + "column1": "escaped_value", + "column3": "escaped_value", + "position": "escaped_value", + "column2Html": "escaped_value" + }, + "cb26d76a-9e3b-43f0-a7c4-0f2ad0ea8029": { + "column1": "escaped_value", + "column3": "escaped_value", + "position": "escaped_value", + "column2Html": "escaped_value" + } + } + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "sections": { + "ea6f1e5d-0ef7-454f-8ae0-1d9b3bfd1177": { + "column1": "escaped_value", + "column3": "escaped_value", + "position": "escaped_value", + "column2Html": "escaped_value" + } + } + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": "escaped_value", + "children": [ + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + } + ], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + }, + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "root": { + "href": "escaped_value" + }, + "parent": { + "href": "escaped_value" + }, + "children": [ + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + } + ], + "contentType": { + "href": "escaped_value" + } + }, + "data": { + "columns": [ + { + "slot": "escaped_value", + "width": "escaped_value" + }, + { + "slot": "escaped_value", + "width": "escaped_value" + } + ] + }, + "slot": "escaped_value", + "position": "escaped_value", + "instanceName": "escaped_value", + "id": "escaped_value", + "contentTypeName": "escaped_value" + } + ], + "scheduleEntries": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "day": { + "href": "escaped_value" + } + }, + "left": "escaped_value", + "width": "escaped_value", + "id": "escaped_value", + "start": "escaped_value", + "end": "escaped_value", + "dayNumber": "escaped_value", + "scheduleEntryNumber": "escaped_value", + "number": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "day": { + "href": "escaped_value" + } + }, + "left": "escaped_value", + "width": "escaped_value", + "id": "escaped_value", + "start": "escaped_value", + "end": "escaped_value", + "dayNumber": "escaped_value", + "scheduleEntryNumber": "escaped_value", + "number": "escaped_value" + } + ], + "activityResponsibles": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "activity": { + "href": "escaped_value" + }, + "campCollaboration": { + "href": "escaped_value" + } + }, + "id": "escaped_value" + } + ] + }, + "title": "escaped_value", + "location": "escaped_value", + "id": "escaped_value" +} diff --git a/api/tests/Api/Camps/ListCampsTest.php b/api/tests/Api/Camps/ListCampsTest.php index 2b2e4dda797..2bcfd9322dc 100644 --- a/api/tests/Api/Camps/ListCampsTest.php +++ b/api/tests/Api/Camps/ListCampsTest.php @@ -3,6 +3,11 @@ namespace App\Tests\Api\Camps; use App\Tests\Api\ECampApiTestCase; +use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; /** * @internal @@ -36,6 +41,19 @@ public function testListCampsIsAllowedForLoggedInUserButFiltered() { ], $response->toArray()['_links']['items']); } + /** + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + */ + public function testListCampsMatchesSnapshot() { + $response = static::createClientWithCredentials()->request('GET', '/camps'); + + $this->assertMatchesResponseSnapshot($response); + } + public function testListPrototypeCampsOnly() { $response = static::createClientWithCredentials()->request('GET', '/camps?isPrototype=true'); $this->assertResponseStatusCodeSame(200); diff --git a/api/tests/Api/Camps/ReadCampTest.php b/api/tests/Api/Camps/ReadCampTest.php index bf21263ff08..fdb71ad2baf 100644 --- a/api/tests/Api/Camps/ReadCampTest.php +++ b/api/tests/Api/Camps/ReadCampTest.php @@ -4,6 +4,11 @@ use App\Entity\Camp; use App\Tests\Api\ECampApiTestCase; +use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; /** * @internal @@ -124,6 +129,21 @@ public function testGetSingleCampIsAllowedForManager() { ]); } + /** + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + */ + public function testGetSingleCampMatchesSnapshot() { + /** @var Camp $camp */ + $camp = static::$fixtures['camp1']; + $response = static::createClientWithCredentials()->request('GET', '/camps/'.$camp->getId()); + + $this->assertMatchesResponseSnapshot($response); + } + public function testGetSinglePrototypeCampIsAllowedForUnrelatedUser() { /** @var Camp $camp */ $camp = static::$fixtures['campPrototype']; diff --git a/api/tests/Api/Camps/__snapshots__/ListCampsTest__testListCampsMatchesSnapshot__1.json b/api/tests/Api/Camps/__snapshots__/ListCampsTest__testListCampsMatchesSnapshot__1.json new file mode 100644 index 00000000000..c2eb7a6f567 --- /dev/null +++ b/api/tests/Api/Camps/__snapshots__/ListCampsTest__testListCampsMatchesSnapshot__1.json @@ -0,0 +1,164 @@ +{ + "_links": { + "self": { + "href": "escaped_value" + }, + "items": [ + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + }, + { + "href": "escaped_value" + } + ] + }, + "totalItems": "escaped_value", + "_embedded": { + "items": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "campCollaborations": { + "href": "escaped_value" + }, + "periods": { + "href": "escaped_value" + }, + "categories": { + "href": "escaped_value" + }, + "progressLabels": { + "href": "escaped_value" + }, + "activities": { + "href": "escaped_value" + }, + "materialLists": { + "href": "escaped_value" + }, + "creator": { + "href": "escaped_value" + }, + "profiles": { + "href": "escaped_value" + } + }, + "isPrototype": "escaped_value", + "name": "escaped_value", + "title": "escaped_value", + "motto": "escaped_value", + "addressName": "escaped_value", + "addressStreet": "escaped_value", + "addressZipcode": "escaped_value", + "addressCity": "escaped_value", + "organizer": "escaped_value", + "kind": "escaped_value", + "coachName": "escaped_value", + "courseNumber": "escaped_value", + "courseKind": "escaped_value", + "trainingAdvisorName": "escaped_value", + "printYSLogoOnPicasso": "escaped_value", + "id": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "campCollaborations": { + "href": "escaped_value" + }, + "periods": { + "href": "escaped_value" + }, + "categories": { + "href": "escaped_value" + }, + "progressLabels": { + "href": "escaped_value" + }, + "activities": { + "href": "escaped_value" + }, + "materialLists": { + "href": "escaped_value" + }, + "creator": { + "href": "escaped_value" + }, + "profiles": { + "href": "escaped_value" + } + }, + "isPrototype": "escaped_value", + "name": "escaped_value", + "title": "escaped_value", + "motto": "escaped_value", + "addressName": "escaped_value", + "addressStreet": "escaped_value", + "addressZipcode": "escaped_value", + "addressCity": "escaped_value", + "organizer": "escaped_value", + "kind": "escaped_value", + "coachName": "escaped_value", + "courseNumber": "escaped_value", + "courseKind": "escaped_value", + "trainingAdvisorName": "escaped_value", + "printYSLogoOnPicasso": "escaped_value", + "id": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "campCollaborations": { + "href": "escaped_value" + }, + "periods": { + "href": "escaped_value" + }, + "categories": { + "href": "escaped_value" + }, + "progressLabels": { + "href": "escaped_value" + }, + "activities": { + "href": "escaped_value" + }, + "materialLists": { + "href": "escaped_value" + }, + "creator": { + "href": "escaped_value" + }, + "profiles": { + "href": "escaped_value" + } + }, + "isPrototype": "escaped_value", + "name": "escaped_value", + "title": "escaped_value", + "motto": "escaped_value", + "addressName": "escaped_value", + "addressStreet": "escaped_value", + "addressZipcode": "escaped_value", + "addressCity": "escaped_value", + "organizer": "escaped_value", + "kind": "escaped_value", + "coachName": "escaped_value", + "courseNumber": "escaped_value", + "courseKind": "escaped_value", + "trainingAdvisorName": "escaped_value", + "printYSLogoOnPicasso": "escaped_value", + "id": "escaped_value" + } + ] + } +} diff --git a/api/tests/Api/Camps/__snapshots__/ReadCampTest__testGetSingleCampMatchesSnapshot__1.json b/api/tests/Api/Camps/__snapshots__/ReadCampTest__testGetSingleCampMatchesSnapshot__1.json new file mode 100644 index 00000000000..086d00907af --- /dev/null +++ b/api/tests/Api/Camps/__snapshots__/ReadCampTest__testGetSingleCampMatchesSnapshot__1.json @@ -0,0 +1,418 @@ +{ + "_links": { + "self": { + "href": "escaped_value" + }, + "campCollaborations": { + "href": "escaped_value" + }, + "periods": { + "href": "escaped_value" + }, + "categories": { + "href": "escaped_value" + }, + "progressLabels": { + "href": "escaped_value" + }, + "activities": { + "href": "escaped_value" + }, + "materialLists": { + "href": "escaped_value" + }, + "creator": { + "href": "escaped_value" + }, + "profiles": { + "href": "escaped_value" + } + }, + "_embedded": { + "periods": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "days": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + }, + "materialItems": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + }, + "contentNodes": { + "href": "escaped_value" + }, + "dayResponsibles": { + "href": "escaped_value" + } + }, + "_embedded": { + "days": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "dayResponsibles": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + } + }, + "dayOffset": "escaped_value", + "id": "escaped_value", + "number": "escaped_value", + "start": "escaped_value", + "end": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "dayResponsibles": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + } + }, + "dayOffset": "escaped_value", + "id": "escaped_value", + "number": "escaped_value", + "start": "escaped_value", + "end": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "dayResponsibles": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + } + }, + "dayOffset": "escaped_value", + "id": "escaped_value", + "number": "escaped_value", + "start": "escaped_value", + "end": "escaped_value" + } + ] + }, + "description": "escaped_value", + "start": "escaped_value", + "end": "escaped_value", + "id": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "days": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + }, + "materialItems": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + }, + "contentNodes": { + "href": "escaped_value" + }, + "dayResponsibles": { + "href": "escaped_value" + } + }, + "_embedded": { + "days": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "dayResponsibles": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + } + }, + "dayOffset": "escaped_value", + "id": "escaped_value", + "number": "escaped_value", + "start": "escaped_value", + "end": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "dayResponsibles": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + } + }, + "dayOffset": "escaped_value", + "id": "escaped_value", + "number": "escaped_value", + "start": "escaped_value", + "end": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "dayResponsibles": { + "href": "escaped_value" + }, + "period": { + "href": "escaped_value" + }, + "scheduleEntries": { + "href": "escaped_value" + } + }, + "dayOffset": "escaped_value", + "id": "escaped_value", + "number": "escaped_value", + "start": "escaped_value", + "end": "escaped_value" + } + ] + }, + "description": "escaped_value", + "start": "escaped_value", + "end": "escaped_value", + "id": "escaped_value" + } + ], + "campCollaborations": [ + { + "_links": { + "self": { + "href": "escaped_value" + }, + "user": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + } + }, + "_embedded": { + "user": { + "_links": { + "self": { + "href": "escaped_value" + }, + "profile": { + "href": "escaped_value" + } + }, + "id": "escaped_value", + "displayName": "escaped_value" + } + }, + "inviteEmail": "escaped_value", + "status": "escaped_value", + "role": "escaped_value", + "id": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "user": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + } + }, + "_embedded": { + "user": { + "_links": { + "self": { + "href": "escaped_value" + }, + "profile": { + "href": "escaped_value" + } + }, + "id": "escaped_value", + "displayName": "escaped_value" + } + }, + "inviteEmail": "escaped_value", + "status": "escaped_value", + "role": "escaped_value", + "id": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "user": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + } + }, + "_embedded": { + "user": { + "_links": { + "self": { + "href": "escaped_value" + }, + "profile": { + "href": "escaped_value" + } + }, + "id": "escaped_value", + "displayName": "escaped_value" + } + }, + "inviteEmail": "escaped_value", + "status": "escaped_value", + "role": "escaped_value", + "id": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "user": "escaped_value", + "camp": { + "href": "escaped_value" + } + }, + "_embedded": { + "user": "escaped_value" + }, + "inviteEmail": "escaped_value", + "status": "escaped_value", + "role": "escaped_value", + "id": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "user": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + } + }, + "_embedded": { + "user": { + "_links": { + "self": { + "href": "escaped_value" + }, + "profile": { + "href": "escaped_value" + } + }, + "id": "escaped_value", + "displayName": "escaped_value" + } + }, + "inviteEmail": "escaped_value", + "status": "escaped_value", + "role": "escaped_value", + "id": "escaped_value" + }, + { + "_links": { + "self": { + "href": "escaped_value" + }, + "user": { + "href": "escaped_value" + }, + "camp": { + "href": "escaped_value" + } + }, + "_embedded": { + "user": { + "_links": { + "self": { + "href": "escaped_value" + }, + "profile": { + "href": "escaped_value" + } + }, + "id": "escaped_value", + "displayName": "escaped_value" + } + }, + "inviteEmail": "escaped_value", + "status": "escaped_value", + "role": "escaped_value", + "id": "escaped_value" + } + ] + }, + "isPrototype": "escaped_value", + "name": "escaped_value", + "title": "escaped_value", + "motto": "escaped_value", + "addressName": "escaped_value", + "addressStreet": "escaped_value", + "addressZipcode": "escaped_value", + "addressCity": "escaped_value", + "organizer": "escaped_value", + "kind": "escaped_value", + "coachName": "escaped_value", + "courseNumber": "escaped_value", + "courseKind": "escaped_value", + "trainingAdvisorName": "escaped_value", + "printYSLogoOnPicasso": "escaped_value", + "id": "escaped_value" +} diff --git a/api/tests/Api/ECampApiTestCase.php b/api/tests/Api/ECampApiTestCase.php index ad331555915..196bce9b7ac 100644 --- a/api/tests/Api/ECampApiTestCase.php +++ b/api/tests/Api/ECampApiTestCase.php @@ -18,8 +18,10 @@ use App\Repository\ProfileRepository; use Doctrine\ORM\EntityManagerInterface; use Hautelook\AliceBundle\PhpUnit\RefreshDatabaseTrait; +use Spatie\Snapshots\MatchesSnapshots; use Symfony\Component\BrowserKit\Cookie; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; @@ -27,6 +29,7 @@ abstract class ECampApiTestCase extends ApiTestCase { use RefreshDatabaseTrait; + use MatchesSnapshots; protected string $endpoint = ''; protected string $routePrefix = ''; @@ -297,4 +300,25 @@ protected function assertJsonSchemaError(ResponseInterface $response, string $pr $this->assertEquals($propertyName, $responseArray['violations'][0]['propertyPath']); $this->assertStringStartsWith('Provided JSON doesn\'t match required schema', $responseArray['violations'][0]['message']); } + + /** + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + */ + protected function assertMatchesResponseSnapshot(ResponseInterface $response): void { + $responseArray = $response->toArray(false); + + array_walk_recursive($responseArray, fn (mixed & $value) => self::escape_values($value)); + $responseJson = json_encode($responseArray); + $this->assertMatchesJsonSnapshot($responseJson); + } + + private static function escape_values(mixed &$object): void { + if (!is_array($object)) { + $object = 'escaped_value'; + } + } }