From 58f92f9bb05ac96c74c979943716c7ac8793ffdd Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 10 Jun 2024 11:40:18 +0200 Subject: [PATCH 01/10] Adjust CI script for PHP 8.3 and Linting --- .github/workflows/test-application.yaml | 61 ++++++++++++++++++++----- composer.json | 16 +++---- 2 files changed, 57 insertions(+), 20 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 5d53e44..486fa18 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -9,7 +9,7 @@ on: jobs: test: - name: 'PHP ${{ matrix.php-version }} (${{ matrix.dependency-versions }}, Lint ${{ matrix.lint }})' + name: 'PHP ${{ matrix.php-version }} (${{ matrix.dependency-versions }})' runs-on: ubuntu-latest env: @@ -22,15 +22,13 @@ jobs: matrix: include: - php-version: '7.3' - lint: false coverage: false dependency-versions: 'lowest' - tools: 'composer:v1' + tools: 'composer:v2' env: SYMFONY_DEPRECATIONS_HELPER: disabled - php-version: '7.4' - lint: true coverage: true dependency-versions: 'highest' tools: 'composer:v2' @@ -38,7 +36,6 @@ jobs: SYMFONY_DEPRECATIONS_HELPER: weak - php-version: '8.0' - lint: false coverage: false dependency-versions: 'highest' tools: 'composer:v2' @@ -46,7 +43,20 @@ jobs: SYMFONY_DEPRECATIONS_HELPER: weak - php-version: '8.1' - lint: false + coverage: false + dependency-versions: 'highest' + tools: 'composer:v2' + env: + SYMFONY_DEPRECATIONS_HELPER: weak + + - php-version: '8.2' + coverage: false + dependency-versions: 'highest' + tools: 'composer:v2' + env: + SYMFONY_DEPRECATIONS_HELPER: weak + + - php-version: '8.3' coverage: false dependency-versions: 'highest' tools: 'composer:v2' @@ -64,7 +74,7 @@ jobs: steps: - name: Checkout project - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install and configure PHP uses: shivammathur/setup-php@v2 @@ -74,8 +84,11 @@ jobs: coverage: pcov tools: ${{ matrix.tools }} + - name: Remove not required test tooling + run: composer remove "*php-cs-fixer*" "*phpstan*" --no-update --dev + - name: Install composer dependencies - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v3 with: dependency-versions: ${{ matrix.dependency-versions }} composer-options: ${{ matrix.composer-options }} @@ -83,10 +96,6 @@ jobs: - name: Bootstrap test environment run: composer bootstrap-test-environment - - name: Lint code - if: ${{ matrix.lint }} - run: composer lint - - name: Execute unit test cases run: composer test -- Tests/Unit --coverage-php var/coverage.php --coverage-html coverage-report --log-junit var/junit.xml @@ -96,3 +105,31 @@ jobs: - name: Check code coverage if: ${{ matrix.coverage }} run: php vendor/bin/code-coverage-checker "var/coverage.php" "line" "95" "Content" + + lint: + name: 'PHP Lint' + runs-on: ubuntu-latest + + env: + DATABASE_URL: mysql://root:root@127.0.0.1:3306/su_headless_test?serverVersion=5.7 + DATABASE_CHARSET: utf8mb4 + DATABASE_COLLATE: utf8mb4_unicode_ci + + steps: + - name: Checkout project + uses: actions/checkout@v4 + + - name: Install and configure PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + extensions: ctype, iconv, mysql + tools: highest + + - name: Install composer dependencies + uses: ramsey/composer-install@v3 + with: + dependency-versions: highest + + - name: Lint code + run: composer lint diff --git a/composer.json b/composer.json index ba8ecad..9537f0f 100644 --- a/composer.json +++ b/composer.json @@ -14,23 +14,23 @@ }, "require-dev": { "coduo/php-matcher": "^5.0 || ^6.0", - "friendsofphp/php-cs-fixer": "^3.0", "handcraftedinthealps/code-coverage-checker": "^0.2.1", "handcraftedinthealps/zendsearch": "^2.0", "jackalope/jackalope-doctrine-dbal": "^1.3.4", - "jangregor/phpstan-prophecy": "^0.8", + "jangregor/phpstan-prophecy": "^1.0", + "php-cs-fixer/shim": "^3.0", "phpspec/prophecy": "^1.8", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-doctrine": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpstan/phpstan-symfony": "^0.12", - "phpunit/phpunit": "^8.4", + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-doctrine": "^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "phpstan/phpstan-symfony": "^1.0", + "phpunit/phpunit": "^9.6", "symfony/browser-kit": "^4.4 || ^5.0 || ^6.0", "symfony/console": "^4.4 || ^5.0 || ^6.0", "symfony/dotenv": "^4.4 || ^5.0 || ^6.0", "symfony/error-handler": "^4.4 || ^5.0 || ^6.0", "symfony/monolog-bundle": "^3.1", - "thecodingmachine/phpstan-strict-rules": "^0.12" + "thecodingmachine/phpstan-strict-rules": "^1.0" }, "conflict": { "doctrine/orm": "< 2.6.3", From 9414d39c9a6af7224a07dff501474d386a5b3875 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 10 Jun 2024 12:28:39 +0200 Subject: [PATCH 02/10] Update phpstan baseline and fix some errors --- .../AccountSelectionResolver.php | 2 +- .../CategorySelectionResolver.php | 2 +- .../CollectionSelectionResolver.php | 2 +- .../ContactAccountSelectionResolver.php | 2 +- .../ContactSelectionResolver.php | 2 +- .../MediaSelectionResolver.php | 6 +- .../PageSelectionResolver.php | 2 +- .../SingleAccountSelectionResolver.php | 2 +- .../SingleCategorySelectionResolver.php | 2 +- .../SingleCollectionSelectionResolver.php | 5 +- .../SingleContactSelectionResolver.php | 4 +- .../SingleMediaSelectionResolver.php | 4 +- .../SinglePageSelectionResolver.php | 2 +- .../SingleSnippetSelectionResolver.php | 2 +- .../SnippetSelectionResolver.php | 2 +- Content/Serializer/AccountSerializer.php | 2 +- Content/Serializer/ContactSerializer.php | 2 +- .../NavigationInvalidationSubscriber.php | 2 + Tests/Application/.env.local | 1 + .../Controller/SnippetAreaControllerTest.php | 3 +- phpstan-baseline.neon | 206 ++++++++++++++++++ phpstan.neon | 3 +- 22 files changed, 235 insertions(+), 25 deletions(-) create mode 100644 Tests/Application/.env.local create mode 100644 phpstan-baseline.neon diff --git a/Content/ContentTypeResolver/AccountSelectionResolver.php b/Content/ContentTypeResolver/AccountSelectionResolver.php index a79f6b1..d185e3f 100644 --- a/Content/ContentTypeResolver/AccountSelectionResolver.php +++ b/Content/ContentTypeResolver/AccountSelectionResolver.php @@ -46,7 +46,7 @@ public function __construct( public function resolve($data, PropertyInterface $property, string $locale, array $attributes = []): ContentView { - if (empty($data)) { + if (empty($data) || !\is_array($data)) { return new ContentView([], ['ids' => []]); } diff --git a/Content/ContentTypeResolver/CategorySelectionResolver.php b/Content/ContentTypeResolver/CategorySelectionResolver.php index 94e5c9d..cfe3dca 100644 --- a/Content/ContentTypeResolver/CategorySelectionResolver.php +++ b/Content/ContentTypeResolver/CategorySelectionResolver.php @@ -46,7 +46,7 @@ public function __construct( public function resolve($data, PropertyInterface $property, string $locale, array $attributes = []): ContentView { - if (empty($data)) { + if (empty($data) || !\is_array($data)) { return new ContentView([], ['ids' => []]); } diff --git a/Content/ContentTypeResolver/CollectionSelectionResolver.php b/Content/ContentTypeResolver/CollectionSelectionResolver.php index 41102eb..d09bf03 100644 --- a/Content/ContentTypeResolver/CollectionSelectionResolver.php +++ b/Content/ContentTypeResolver/CollectionSelectionResolver.php @@ -50,7 +50,7 @@ public function resolve($data, PropertyInterface $property, string $locale, arra /** @var int[]|null $ids */ $ids = $data; - if (empty($ids)) { + if (empty($ids) || !\is_array($ids)) { return new ContentView([], ['ids' => []]); } diff --git a/Content/ContentTypeResolver/ContactAccountSelectionResolver.php b/Content/ContentTypeResolver/ContactAccountSelectionResolver.php index cc65726..9cad5da 100644 --- a/Content/ContentTypeResolver/ContactAccountSelectionResolver.php +++ b/Content/ContentTypeResolver/ContactAccountSelectionResolver.php @@ -62,7 +62,7 @@ public function __construct( public function resolve($data, PropertyInterface $property, string $locale, array $attributes = []): ContentView { - if (empty($data)) { + if (empty($data) || !\is_array($data)) { return new ContentView([], ['ids' => []]); } diff --git a/Content/ContentTypeResolver/ContactSelectionResolver.php b/Content/ContentTypeResolver/ContactSelectionResolver.php index c909ec4..0d5cccf 100644 --- a/Content/ContentTypeResolver/ContactSelectionResolver.php +++ b/Content/ContentTypeResolver/ContactSelectionResolver.php @@ -46,7 +46,7 @@ public function __construct( public function resolve($data, PropertyInterface $property, string $locale, array $attributes = []): ContentView { - if (empty($data)) { + if (empty($data) || !\is_array($data)) { return new ContentView([], ['ids' => []]); } diff --git a/Content/ContentTypeResolver/MediaSelectionResolver.php b/Content/ContentTypeResolver/MediaSelectionResolver.php index 45058c6..b8c3da8 100644 --- a/Content/ContentTypeResolver/MediaSelectionResolver.php +++ b/Content/ContentTypeResolver/MediaSelectionResolver.php @@ -46,14 +46,14 @@ public function __construct( public function resolve($data, PropertyInterface $property, string $locale, array $attributes = []): ContentView { - if (empty($data)) { + if (empty($data) || !\is_array($data)) { return new ContentView([], ['ids' => []]); } $ids = $data['ids'] ?? []; $content = []; - if (\count($ids)) { + if (\is_array($ids) && \count($ids)) { $medias = $this->mediaManager->getByIds($ids, $locale); $content = $this->resolveApiMedias($medias, $locale); } @@ -64,7 +64,7 @@ public function resolve($data, PropertyInterface $property, string $locale, arra /** * @param Media[] $medias * - * @return array[] + * @return array> */ private function resolveApiMedias(array $medias, string $locale): array { diff --git a/Content/ContentTypeResolver/PageSelectionResolver.php b/Content/ContentTypeResolver/PageSelectionResolver.php index a455466..a745cc4 100644 --- a/Content/ContentTypeResolver/PageSelectionResolver.php +++ b/Content/ContentTypeResolver/PageSelectionResolver.php @@ -61,7 +61,7 @@ public function __construct( public function resolve($data, PropertyInterface $property, string $locale, array $attributes = []): ContentView { - if (empty($data)) { + if (empty($data) || !\is_array($data)) { return new ContentView([], ['ids' => []]); } diff --git a/Content/ContentTypeResolver/SingleAccountSelectionResolver.php b/Content/ContentTypeResolver/SingleAccountSelectionResolver.php index eaafe6c..4b03790 100644 --- a/Content/ContentTypeResolver/SingleAccountSelectionResolver.php +++ b/Content/ContentTypeResolver/SingleAccountSelectionResolver.php @@ -46,7 +46,7 @@ public function __construct( public function resolve($data, PropertyInterface $property, string $locale, array $attributes = []): ContentView { - if (empty($data)) { + if (!\is_numeric($data)) { return new ContentView(null, ['id' => null]); } diff --git a/Content/ContentTypeResolver/SingleCategorySelectionResolver.php b/Content/ContentTypeResolver/SingleCategorySelectionResolver.php index d61a6ec..65cbbba 100644 --- a/Content/ContentTypeResolver/SingleCategorySelectionResolver.php +++ b/Content/ContentTypeResolver/SingleCategorySelectionResolver.php @@ -46,7 +46,7 @@ public function __construct( public function resolve($data, PropertyInterface $property, string $locale, array $attributes = []): ContentView { - if (empty($data)) { + if (!\is_numeric($data)) { return new ContentView(null, ['id' => null]); } diff --git a/Content/ContentTypeResolver/SingleCollectionSelectionResolver.php b/Content/ContentTypeResolver/SingleCollectionSelectionResolver.php index c73b5f0..78d773a 100644 --- a/Content/ContentTypeResolver/SingleCollectionSelectionResolver.php +++ b/Content/ContentTypeResolver/SingleCollectionSelectionResolver.php @@ -35,14 +35,13 @@ public function __construct(ContentTypeResolverInterface $collectionSelectionRes public function resolve($data, PropertyInterface $property, string $locale, array $attributes = []): ContentView { - /** @var int|null $id */ $id = $data; - if (empty($id)) { + if (!\is_numeric($id)) { return new ContentView(null, ['id' => null]); } - $content = $this->collectionSelectionResolver->resolve([$id], $property, $locale, $attributes); + $content = $this->collectionSelectionResolver->resolve([(int) $id], $property, $locale, $attributes); /** @var mixed[]|null $contentData */ $contentData = $content->getContent(); diff --git a/Content/ContentTypeResolver/SingleContactSelectionResolver.php b/Content/ContentTypeResolver/SingleContactSelectionResolver.php index 5061970..5353ae0 100644 --- a/Content/ContentTypeResolver/SingleContactSelectionResolver.php +++ b/Content/ContentTypeResolver/SingleContactSelectionResolver.php @@ -46,11 +46,11 @@ public function __construct( public function resolve($data, PropertyInterface $property, string $locale, array $attributes = []): ContentView { - if (empty($data)) { + if (!\is_numeric($data)) { return new ContentView(null, ['id' => null]); } - $contact = $this->contactManager->getById($data, $locale); + $contact = $this->contactManager->getById((int) $data, $locale); $serializationContext = new SerializationContext(); $serializationContext->setGroups(['partialContact']); diff --git a/Content/ContentTypeResolver/SingleMediaSelectionResolver.php b/Content/ContentTypeResolver/SingleMediaSelectionResolver.php index 4b91ddf..45e4fff 100644 --- a/Content/ContentTypeResolver/SingleMediaSelectionResolver.php +++ b/Content/ContentTypeResolver/SingleMediaSelectionResolver.php @@ -35,11 +35,11 @@ public function __construct(ContentTypeResolverInterface $mediaSelectionResolver public function resolve($data, PropertyInterface $property, string $locale, array $attributes = []): ContentView { - if (empty($data)) { + if (empty($data) || !\is_array($data)) { return new ContentView(null, ['id' => null]); } - $ids = \array_key_exists('id', $data) ? [$data['id']] : []; + $ids = \array_key_exists('id', $data) && \is_numeric($data['id']) ? [(int) $data['id']] : []; $content = $this->mediaSelectionResolver->resolve(['ids' => $ids], $property, $locale, $attributes); return new ContentView($content->getContent()[0] ?? null, \array_merge(['id' => null], $data)); diff --git a/Content/ContentTypeResolver/SinglePageSelectionResolver.php b/Content/ContentTypeResolver/SinglePageSelectionResolver.php index 4ceefb4..a031868 100644 --- a/Content/ContentTypeResolver/SinglePageSelectionResolver.php +++ b/Content/ContentTypeResolver/SinglePageSelectionResolver.php @@ -35,7 +35,7 @@ public function __construct(ContentTypeResolverInterface $pageSelectionResolver) public function resolve($data, PropertyInterface $property, string $locale, array $attributes = []): ContentView { - if (empty($data)) { + if (!\is_string($data)) { return new ContentView(null, ['id' => null]); } diff --git a/Content/ContentTypeResolver/SingleSnippetSelectionResolver.php b/Content/ContentTypeResolver/SingleSnippetSelectionResolver.php index 8460405..ff3177d 100644 --- a/Content/ContentTypeResolver/SingleSnippetSelectionResolver.php +++ b/Content/ContentTypeResolver/SingleSnippetSelectionResolver.php @@ -38,7 +38,7 @@ public function resolve($data, PropertyInterface $property, string $locale, arra $snippetId = $data ?: null; $contentView = $this->snippetSelectionResolver->resolve( - $snippetId ? [$snippetId] : null, + !\is_string($snippetId) ? [$snippetId] : null, $property, $locale, $attributes diff --git a/Content/ContentTypeResolver/SnippetSelectionResolver.php b/Content/ContentTypeResolver/SnippetSelectionResolver.php index 9f58152..64e3f4b 100644 --- a/Content/ContentTypeResolver/SnippetSelectionResolver.php +++ b/Content/ContentTypeResolver/SnippetSelectionResolver.php @@ -68,7 +68,7 @@ public function resolve($data, PropertyInterface $property, string $locale, arra /** @var string $defaultArea */ $defaultArea = isset($params['default']) ? $params['default']->getValue() : null; - $snippetIds = $data ?? []; + $snippetIds = \is_array($data) ? $data : []; if (empty($snippetIds) && $defaultArea) { $defaultSnippetId = $this->defaultSnippetManager->loadIdentifier($webspaceKey, $defaultArea); $snippetIds = $defaultSnippetId ? [$defaultSnippetId] : []; diff --git a/Content/Serializer/AccountSerializer.php b/Content/Serializer/AccountSerializer.php index c099b44..7488b12 100644 --- a/Content/Serializer/AccountSerializer.php +++ b/Content/Serializer/AccountSerializer.php @@ -82,7 +82,7 @@ public function serialize(AccountInterface $account, string $locale, ?Serializat } if (null !== $apiAccount->getLogo()) { - /** @var mixed[] $logoData */ + /** @var array{id: int, url: string, thumbnails: array} $logoData */ $logoData = $apiAccount->getLogo(); $logo = $this->mediaManager->getById($logoData['id'], $locale); $accountData['logo'] = $this->mediaSerializer->serialize($logo->getEntity(), $locale); diff --git a/Content/Serializer/ContactSerializer.php b/Content/Serializer/ContactSerializer.php index a1f08fb..68d1a18 100644 --- a/Content/Serializer/ContactSerializer.php +++ b/Content/Serializer/ContactSerializer.php @@ -113,7 +113,7 @@ public function serialize(ContactInterface $contact, string $locale, ?Serializat } if (null !== $apiContact->getAvatar()) { - /** @var mixed[] $avatarData */ + /** @var array{id: int, url: string, thumbnails: array} $avatarData */ $avatarData = $apiContact->getAvatar(); $avatar = $this->mediaManager->getById($avatarData['id'], $locale); $contactData['avatar'] = $this->mediaSerializer->serialize($avatar->getEntity(), $locale); diff --git a/EventSubscriber/NavigationInvalidationSubscriber.php b/EventSubscriber/NavigationInvalidationSubscriber.php index 135bdb3..8f812d8 100644 --- a/EventSubscriber/NavigationInvalidationSubscriber.php +++ b/EventSubscriber/NavigationInvalidationSubscriber.php @@ -123,10 +123,12 @@ private function collectNavigationContexts(object $document, ?string $eventLocal $defaultNavigationContexts = []; if ($liveNode->hasProperty($propertyName)) { + /** @var string[] $liveNavigationContexts */ $liveNavigationContexts = $liveNode->getProperty($propertyName)->getValue(); } if ($defaultNode->hasProperty($propertyName)) { + /** @var string[] $defaultNavigationContexts */ $defaultNavigationContexts = $defaultNode->getProperty($propertyName)->getValue(); } diff --git a/Tests/Application/.env.local b/Tests/Application/.env.local new file mode 100644 index 0000000..33560e7 --- /dev/null +++ b/Tests/Application/.env.local @@ -0,0 +1 @@ +DATABASE_URL=mysql://root@127.0.0.1:3306/su_headless_test?serverVersion=8.0.27 diff --git a/Tests/Functional/Controller/SnippetAreaControllerTest.php b/Tests/Functional/Controller/SnippetAreaControllerTest.php index b0b1ffd..125239c 100644 --- a/Tests/Functional/Controller/SnippetAreaControllerTest.php +++ b/Tests/Functional/Controller/SnippetAreaControllerTest.php @@ -142,10 +142,11 @@ public function testGetAction( $content = $response->getContent(); self::assertIsString($content); + /** @var \stdClass|false $responseObject */ $responseObject = \json_decode($content); self::assertNotFalse($responseObject); - self::assertObjectHasAttribute('message', $responseObject); + self::assertTrue(\property_exists($responseObject, 'message')); self::assertSame($errorMessage, $responseObject->message); } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..9c6d18c --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,206 @@ +parameters: + ignoreErrors: + - + message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" + count: 1 + path: Content/ContentTypeResolver/ImageMapResolver.php + + - + message: "#^Cannot access offset 'hotspots' on mixed\\.$#" + count: 1 + path: Content/ContentTypeResolver/ImageMapResolver.php + + - + message: "#^Cannot access offset 'imageId' on mixed\\.$#" + count: 1 + path: Content/ContentTypeResolver/ImageMapResolver.php + + - + message: "#^Cannot access offset 'type' on mixed\\.$#" + count: 1 + path: Content/ContentTypeResolver/ImageMapResolver.php + + - + message: "#^Cannot access offset string on mixed\\.$#" + count: 2 + path: Content/ContentTypeResolver/ImageMapResolver.php + + - + message: "#^Parameter \\#1 \\$id of method Sulu\\\\Bundle\\\\MediaBundle\\\\Media\\\\Manager\\\\MediaManagerInterface\\:\\:getById\\(\\) expects int, mixed given\\.$#" + count: 1 + path: Content/ContentTypeResolver/ImageMapResolver.php + + - + message: "#^Parameter \\#1 \\$index of method Sulu\\\\Component\\\\Content\\\\Compat\\\\PropertyInterface\\:\\:initProperties\\(\\) expects int, mixed given\\.$#" + count: 1 + path: Content/ContentTypeResolver/ImageMapResolver.php + + - + message: "#^Parameter \\#2 \\$typeName of method Sulu\\\\Component\\\\Content\\\\Compat\\\\PropertyInterface\\:\\:initProperties\\(\\) expects string, mixed given\\.$#" + count: 1 + path: Content/ContentTypeResolver/ImageMapResolver.php + + - + message: "#^Cannot use array destructuring on string\\.$#" + count: 1 + path: Content/ContentTypeResolver/PageSelectionResolver.php + + - + message: "#^Cannot access offset 0 on mixed\\.$#" + count: 1 + path: Content/ContentTypeResolver/SingleMediaSelectionResolver.php + + - + message: "#^Cannot access offset 0 on mixed\\.$#" + count: 1 + path: Content/ContentTypeResolver/SinglePageSelectionResolver.php + + - + message: "#^Cannot access offset 0 on mixed\\.$#" + count: 2 + path: Content/ContentTypeResolver/SingleSnippetSelectionResolver.php + + - + message: "#^Cannot cast mixed to int\\.$#" + count: 1 + path: Content/ContentTypeResolver/SmartContentResolver.php + + - + message: "#^Parameter \\#1 \\$content of method Sulu\\\\Bundle\\\\MarkupBundle\\\\Markup\\\\MarkupParserInterface\\:\\:parse\\(\\) expects string, mixed given\\.$#" + count: 1 + path: Content/ContentTypeResolver/TextEditorResolver.php + + - + message: "#^Parameter \\#1 \\$filters of method Sulu\\\\Component\\\\SmartContent\\\\DataProviderInterface\\:\\:resolveResourceItems\\(\\) expects array\\{dataSource\\?\\: int\\|string\\|null, sortMethod\\?\\: 'asc'\\|'desc', sortBy\\?\\: string, tags\\?\\: array\\, tagOperator\\?\\: 'and'\\|'or', types\\?\\: array\\, categories\\?\\: array\\, categoryOperator\\?\\: 'and'\\|'or', \\.\\.\\.\\}, array given\\.$#" + count: 1 + path: Content/DataProviderResolver/AccountDataProviderResolver.php + + - + message: "#^Parameter \\#1 \\$filters of method Sulu\\\\Component\\\\SmartContent\\\\DataProviderInterface\\:\\:resolveResourceItems\\(\\) expects array\\{dataSource\\?\\: int\\|string\\|null, sortMethod\\?\\: 'asc'\\|'desc', sortBy\\?\\: string, tags\\?\\: array\\, tagOperator\\?\\: 'and'\\|'or', types\\?\\: array\\, categories\\?\\: array\\, categoryOperator\\?\\: 'and'\\|'or', \\.\\.\\.\\}, array given\\.$#" + count: 1 + path: Content/DataProviderResolver/ContactDataProviderResolver.php + + - + message: "#^Method Sulu\\\\Bundle\\\\HeadlessBundle\\\\Content\\\\DataProviderResolver\\\\DataProviderResult\\:\\:__construct\\(\\) has parameter \\$items with no value type specified in iterable type array\\.$#" + count: 1 + path: Content/DataProviderResolver/DataProviderResult.php + + - + message: "#^Method Sulu\\\\Bundle\\\\HeadlessBundle\\\\Content\\\\DataProviderResolver\\\\DataProviderResult\\:\\:getItems\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: Content/DataProviderResolver/DataProviderResult.php + + - + message: "#^Property Sulu\\\\Bundle\\\\HeadlessBundle\\\\Content\\\\DataProviderResolver\\\\DataProviderResult\\:\\:\\$items type has no value type specified in iterable type array\\.$#" + count: 1 + path: Content/DataProviderResolver/DataProviderResult.php + + - + message: "#^Parameter \\#1 \\$filters of method Sulu\\\\Component\\\\Media\\\\SmartContent\\\\MediaDataProvider\\:\\:resolveResourceItems\\(\\) expects array\\{dataSource\\?\\: int\\|string\\|null, sortMethod\\?\\: 'asc'\\|'desc', sortBy\\?\\: string, tags\\?\\: array\\, tagOperator\\?\\: 'and'\\|'or', types\\?\\: array\\, categories\\?\\: array\\, categoryOperator\\?\\: 'and'\\|'or', \\.\\.\\.\\}, array given\\.$#" + count: 1 + path: Content/DataProviderResolver/MediaDataProviderResolver.php + + - + message: "#^Parameter \\#2 \\$locale of method Sulu\\\\Bundle\\\\HeadlessBundle\\\\Content\\\\Serializer\\\\MediaSerializerInterface\\:\\:serialize\\(\\) expects string, mixed given\\.$#" + count: 1 + path: Content/DataProviderResolver/MediaDataProviderResolver.php + + - + message: "#^Cannot use array destructuring on string\\.$#" + count: 1 + path: Content/DataProviderResolver/PageDataProviderResolver.php + + - + message: "#^PHPDoc tag @var above a method has no effect\\.$#" + count: 1 + path: Content/DataProviderResolver/PageDataProviderResolver.php + + - + message: "#^PHPDoc tag @var does not specify variable name\\.$#" + count: 1 + path: Content/DataProviderResolver/PageDataProviderResolver.php + + - + message: "#^Parameter \\#1 \\$filters of method Sulu\\\\Component\\\\Content\\\\SmartContent\\\\PageDataProvider\\:\\:resolveResourceItems\\(\\) expects array\\{dataSource\\?\\: int\\|string\\|null, sortMethod\\?\\: 'asc'\\|'desc', sortBy\\?\\: string, tags\\?\\: array\\, tagOperator\\?\\: 'and'\\|'or', types\\?\\: array\\, categories\\?\\: array\\, categoryOperator\\?\\: 'and'\\|'or', \\.\\.\\.\\}, array given\\.$#" + count: 1 + path: Content/DataProviderResolver/PageDataProviderResolver.php + + - + message: "#^Parameter \\#3 \\$locale of method Sulu\\\\Bundle\\\\HeadlessBundle\\\\Content\\\\StructureResolverInterface\\:\\:resolveProperties\\(\\) expects string, mixed given\\.$#" + count: 1 + path: Content/DataProviderResolver/PageDataProviderResolver.php + + - + message: "#^Parameter \\#3 \\$webspaceKey of method Sulu\\\\Bundle\\\\HeadlessBundle\\\\Content\\\\DataProviderResolver\\\\PageDataProviderResolver\\:\\:loadPageStructures\\(\\) expects string, mixed given\\.$#" + count: 1 + path: Content/DataProviderResolver/PageDataProviderResolver.php + + - + message: "#^Parameter \\#4 \\$locale of method Sulu\\\\Bundle\\\\HeadlessBundle\\\\Content\\\\DataProviderResolver\\\\PageDataProviderResolver\\:\\:loadPageStructures\\(\\) expects string, mixed given\\.$#" + count: 1 + path: Content/DataProviderResolver/PageDataProviderResolver.php + + - + message: "#^Cannot use array destructuring on string\\.$#" + count: 1 + path: Content/DataProviderResolver/SnippetDataProviderResolver.php + + - + message: "#^PHPDoc tag @var above a method has no effect\\.$#" + count: 1 + path: Content/DataProviderResolver/SnippetDataProviderResolver.php + + - + message: "#^PHPDoc tag @var does not specify variable name\\.$#" + count: 1 + path: Content/DataProviderResolver/SnippetDataProviderResolver.php + + - + message: "#^Parameter \\#1 \\$filters of method Sulu\\\\Component\\\\SmartContent\\\\DataProviderInterface\\:\\:resolveResourceItems\\(\\) expects array\\{dataSource\\?\\: int\\|string\\|null, sortMethod\\?\\: 'asc'\\|'desc', sortBy\\?\\: string, tags\\?\\: array\\, tagOperator\\?\\: 'and'\\|'or', types\\?\\: array\\, categories\\?\\: array\\, categoryOperator\\?\\: 'and'\\|'or', \\.\\.\\.\\}, array given\\.$#" + count: 1 + path: Content/DataProviderResolver/SnippetDataProviderResolver.php + + - + message: "#^Cannot access offset string on mixed\\.$#" + count: 2 + path: Content/StructureResolver.php + + - + message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" + count: 2 + path: Controller/NavigationController.php + + - + message: "#^Cannot access offset 'children' on mixed\\.$#" + count: 2 + path: Controller/NavigationController.php + + - + message: "#^Cannot access offset 'excerpt' on mixed\\.$#" + count: 3 + path: Controller/NavigationController.php + + - + message: "#^Cannot access offset 'icon' on mixed\\.$#" + count: 2 + path: Controller/NavigationController.php + + - + message: "#^Cannot access offset 'images' on mixed\\.$#" + count: 2 + path: Controller/NavigationController.php + + - + message: "#^Cannot access offset mixed on mixed\\.$#" + count: 2 + path: Controller/NavigationController.php + + - + message: "#^Cannot call method getEntity\\(\\) on mixed\\.$#" + count: 2 + path: Controller/NavigationController.php + + - + message: "#^Parameter \\#1 \\$navigation of method Sulu\\\\Bundle\\\\HeadlessBundle\\\\Controller\\\\NavigationController\\:\\:serializeExcerptMedia\\(\\) expects array, mixed given\\.$#" + count: 1 + path: Controller/NavigationController.php diff --git a/phpstan.neon b/phpstan.neon index b26ea37..badcd23 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,5 @@ includes: + - phpstan-baseline.neon - vendor/jangregor/phpstan-prophecy/extension.neon - vendor/phpstan/phpstan-doctrine/extension.neon - vendor/phpstan/phpstan-doctrine/rules.neon @@ -11,7 +12,7 @@ parameters: paths: - . level: max - excludes_analyse: + excludePaths: - %currentWorkingDirectory%/DependencyInjection/Configuration.php - %currentWorkingDirectory%/Tests/Application/var/* - %currentWorkingDirectory%/vendor/* From d6ba1a1d4e033998090456cc38952202abbf1c47 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 10 Jun 2024 12:33:49 +0200 Subject: [PATCH 03/10] Fix check --- Content/ContentTypeResolver/SingleSnippetSelectionResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content/ContentTypeResolver/SingleSnippetSelectionResolver.php b/Content/ContentTypeResolver/SingleSnippetSelectionResolver.php index ff3177d..8d567b7 100644 --- a/Content/ContentTypeResolver/SingleSnippetSelectionResolver.php +++ b/Content/ContentTypeResolver/SingleSnippetSelectionResolver.php @@ -38,7 +38,7 @@ public function resolve($data, PropertyInterface $property, string $locale, arra $snippetId = $data ?: null; $contentView = $this->snippetSelectionResolver->resolve( - !\is_string($snippetId) ? [$snippetId] : null, + \is_string($snippetId) ? [$snippetId] : null, $property, $locale, $attributes From 5fdf0d55a3084595e9d977123e57e860c3e26496 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 10 Jun 2024 12:35:32 +0200 Subject: [PATCH 04/10] Fix gitignore --- .gitignore | 4 ++-- Tests/Application/.env.local | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 Tests/Application/.env.local diff --git a/.gitignore b/.gitignore index a45c7cc..ac8a491 100644 --- a/.gitignore +++ b/.gitignore @@ -18,8 +18,8 @@ # tests Tests/Application/var -Tests/Application/.env.dev.local -Tests/Application/.env.test.local +Tests/Application/.env.local +Tests/Application/.env.*.local # php-cs-fixer .php_cs.cache diff --git a/Tests/Application/.env.local b/Tests/Application/.env.local deleted file mode 100644 index 33560e7..0000000 --- a/Tests/Application/.env.local +++ /dev/null @@ -1 +0,0 @@ -DATABASE_URL=mysql://root@127.0.0.1:3306/su_headless_test?serverVersion=8.0.27 From 7294c52b24779c006093c9344905898a6ad46e79 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 10 Jun 2024 12:39:24 +0200 Subject: [PATCH 05/10] Add Sulu 2.6 compatibility Co-Authored-By: Oliver Kossin --- .../Controller/NavigationControllerTest.php | 24 ++-- .../responses/legacy/navigation__get.json | 56 +++++++++ .../navigation__get_context_footer.json | 31 +++++ .../legacy/navigation__get_depth_2.json | 107 +++++++++++++++++ .../legacy/navigation__get_depth_2_flat.json | 106 +++++++++++++++++ .../legacy/navigation__get_excerpt.json | 110 ++++++++++++++++++ .../legacy/navigation__get_uuid.json | 56 +++++++++ .../Controller/responses/navigation__get.json | 2 + .../navigation__get_context_footer.json | 1 + .../responses/navigation__get_depth_2.json | 4 + .../navigation__get_depth_2_flat.json | 4 + .../responses/navigation__get_excerpt.json | 2 + .../responses/navigation__get_uuid.json | 2 + 13 files changed, 497 insertions(+), 8 deletions(-) create mode 100644 Tests/Functional/Controller/responses/legacy/navigation__get.json create mode 100644 Tests/Functional/Controller/responses/legacy/navigation__get_context_footer.json create mode 100644 Tests/Functional/Controller/responses/legacy/navigation__get_depth_2.json create mode 100644 Tests/Functional/Controller/responses/legacy/navigation__get_depth_2_flat.json create mode 100644 Tests/Functional/Controller/responses/legacy/navigation__get_excerpt.json create mode 100644 Tests/Functional/Controller/responses/legacy/navigation__get_uuid.json diff --git a/Tests/Functional/Controller/NavigationControllerTest.php b/Tests/Functional/Controller/NavigationControllerTest.php index 95c1b55..61668a7 100644 --- a/Tests/Functional/Controller/NavigationControllerTest.php +++ b/Tests/Functional/Controller/NavigationControllerTest.php @@ -11,7 +11,7 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\HeadlessBundle\Tests\Functional\Controller; +namespace Functional\Controller; use Sulu\Bundle\HeadlessBundle\Tests\Functional\BaseTestCase; use Sulu\Bundle\HeadlessBundle\Tests\Traits\CreateMediaTrait; @@ -21,7 +21,7 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Component\HttpFoundation\Response; -class NavigationControllerTest extends BaseTestCase +class NavigationControllerTest2 extends BaseTestCase { use CreateMediaTrait; use CreatePageTrait; @@ -112,23 +112,30 @@ protected function setUp(): void */ public function provideAttributes(): \Generator { + $path = ''; + /* Todo Can be removed after ending support of sulu 2.5 */ + if (\version_compare(\Composer\InstalledVersions::getVersion('sulu/sulu') ?? '999.999.999', '2.6.0', '<') + ) { + $path = '/legacy/'; + } + yield [ [], - 'navigation__get.json', + $path . 'navigation__get.json', ]; yield [ [ 'context' => 'footer', ], - 'navigation__get_context_footer.json', + $path . 'navigation__get_context_footer.json', ]; yield [ [ 'depth' => 2, ], - 'navigation__get_depth_2.json', + $path . 'navigation__get_depth_2.json', ]; yield [ @@ -136,21 +143,21 @@ public function provideAttributes(): \Generator 'depth' => 2, 'flat' => 'true', ], - 'navigation__get_depth_2_flat.json', + $path . 'navigation__get_depth_2_flat.json', ]; yield [ [ 'excerpt' => 'true', ], - 'navigation__get_excerpt.json', + $path . 'navigation__get_excerpt.json', ]; yield [ [ 'uuid' => true, ], - 'navigation__get_uuid.json', + $path . 'navigation__get_uuid.json', ]; } @@ -173,6 +180,7 @@ public function testGetAction(array $filters, string $expectedPatternFile): void $this->websiteClient->request('GET', '/api/navigations/' . $context . '?' . \http_build_query($filters)); $response = $this->websiteClient->getResponse(); + $this->assertInstanceOf(Response::class, $response); $this->assertStringContainsString('public', (string) $response->headers->get('Cache-Control')); diff --git a/Tests/Functional/Controller/responses/legacy/navigation__get.json b/Tests/Functional/Controller/responses/legacy/navigation__get.json new file mode 100644 index 0000000..46c14c5 --- /dev/null +++ b/Tests/Functional/Controller/responses/legacy/navigation__get.json @@ -0,0 +1,56 @@ +{ + "_embedded": { + "items": [ + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "publishedState": true, + "published": "@string@.isDateTime()", + "title": "Test 1", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "url": "/test-1", + "path": "@string@.match(\"/test-1\").optional()", + "urls": { + "de": "/test-1" + }, + "author": null, + "authored": "@string@.isDateTime()", + "changer": null, + "changed": "@string@.isDateTime()", + "creator": null, + "created": "@string@.isDateTime()", + "order": 20, + "children": [] + }, + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "publishedState": true, + "published": "@string@.isDateTime()", + "title": "Test 2", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "path": "@string@.match(\"/test-2\").optional()", + "url": "/test-2", + "urls": { + "de": "/test-2" + }, + "author": null, + "authored": "@string@.isDateTime()", + "changer": null, + "changed": "@string@.isDateTime()", + "creator": null, + "created": "@string@.isDateTime()", + "order": 30, + "children": [] + } + ] + } +} diff --git a/Tests/Functional/Controller/responses/legacy/navigation__get_context_footer.json b/Tests/Functional/Controller/responses/legacy/navigation__get_context_footer.json new file mode 100644 index 0000000..dd98272 --- /dev/null +++ b/Tests/Functional/Controller/responses/legacy/navigation__get_context_footer.json @@ -0,0 +1,31 @@ +{ + "_embedded": { + "items": [ + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "publishedState": true, + "published": "@string@.isDateTime()", + "title": "Test 3", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "path": "@string@.match(\"/test-3\").optional()", + "url": "/test-3", + "urls": { + "de": "/test-3" + }, + "author": null, + "authored": "@string@.isDateTime()", + "changer": null, + "changed": "@string@.isDateTime()", + "creator": null, + "created": "@string@.isDateTime()", + "order": 40, + "children": [] + } + ] + } +} diff --git a/Tests/Functional/Controller/responses/legacy/navigation__get_depth_2.json b/Tests/Functional/Controller/responses/legacy/navigation__get_depth_2.json new file mode 100644 index 0000000..8f2c865 --- /dev/null +++ b/Tests/Functional/Controller/responses/legacy/navigation__get_depth_2.json @@ -0,0 +1,107 @@ +{ + "_embedded": { + "items": [ + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "publishedState": true, + "published": "@string@.isDateTime()", + "title": "Test 1", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "path": "@string@.match(\"/test-1\").optional()", + "url": "/test-1", + "urls": { + "de": "/test-1" + }, + "author": null, + "authored": "@string@.isDateTime()", + "changer": null, + "changed": "@string@.isDateTime()", + "creator": null, + "created": "@string@.isDateTime()", + "order": 20, + "children": [ + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "publishedState": true, + "published": "@string@.isDateTime()", + "title": "Test 1A", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "path": "@string@.match(\"/test-1/test-1a\").optional()", + "url": "/test-1a", + "urls": { + "de": "/test-1a" + }, + "author": null, + "authored": "@string@.isDateTime()", + "changer": null, + "changed": "@string@.isDateTime()", + "creator": null, + "created": "@string@.isDateTime()", + "order": 20, + "children": [] + }, + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "publishedState": true, + "published": "@string@.isDateTime()", + "title": "Test 1B", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "path": "@string@.match(\"/test-1/test-1b\").optional()", + "url": "/test-1b", + "urls": { + "de": "/test-1b" + }, + "author": null, + "authored": "@string@.isDateTime()", + "changer": null, + "changed": "@string@.isDateTime()", + "creator": null, + "created": "@string@.isDateTime()", + "order": 30, + "children": [] + } + ] + }, + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "publishedState": true, + "published": "@string@.isDateTime()", + "title": "Test 2", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "path": "@string@.match(\"/test-2\").optional()", + "url": "/test-2", + "urls": { + "de": "/test-2" + }, + "author": null, + "authored": "@string@.isDateTime()", + "changer": null, + "changed": "@string@.isDateTime()", + "creator": null, + "created": "@string@.isDateTime()", + "order": 30, + "children": [] + } + ] + } +} diff --git a/Tests/Functional/Controller/responses/legacy/navigation__get_depth_2_flat.json b/Tests/Functional/Controller/responses/legacy/navigation__get_depth_2_flat.json new file mode 100644 index 0000000..a532cc3 --- /dev/null +++ b/Tests/Functional/Controller/responses/legacy/navigation__get_depth_2_flat.json @@ -0,0 +1,106 @@ +{ + "_embedded": { + "items": [ + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "publishedState": true, + "published": "@string@.isDateTime()", + "title": "Test 1", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "path": "@string@.match(\"/test-1\").optional()", + "url": "/test-1", + "urls": { + "de": "/test-1" + }, + "author": null, + "authored": "@string@.isDateTime()", + "changer": null, + "changed": "@string@.isDateTime()", + "creator": null, + "created": "@string@.isDateTime()", + "order": 20, + "children": [] + }, + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "publishedState": true, + "published": "@string@.isDateTime()", + "title": "Test 1A", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "path": "@string@.match(\"/test-1/test-1a\").optional()", + "url": "/test-1a", + "urls": { + "de": "/test-1a" + }, + "author": null, + "authored": "@string@.isDateTime()", + "changer": null, + "changed": "@string@.isDateTime()", + "creator": null, + "created": "@string@.isDateTime()", + "order": 20, + "children": [] + }, + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "publishedState": true, + "published": "@string@.isDateTime()", + "title": "Test 2", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "path": "@string@.match(\"/test-2\").optional()", + "url": "/test-2", + "urls": { + "de": "/test-2" + }, + "author": null, + "authored": "@string@.isDateTime()", + "changer": null, + "changed": "@string@.isDateTime()", + "creator": null, + "created": "@string@.isDateTime()", + "order": 30, + "children": [] + }, + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "publishedState": true, + "published": "@string@.isDateTime()", + "title": "Test 1B", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "path": "@string@.match(\"/test-1/test-1b\").optional()", + "url": "/test-1b", + "urls": { + "de": "/test-1b" + }, + "author": null, + "authored": "@string@.isDateTime()", + "changer": null, + "changed": "@string@.isDateTime()", + "creator": null, + "created": "@string@.isDateTime()", + "order": 30, + "children": [] + } + ] + } +} diff --git a/Tests/Functional/Controller/responses/legacy/navigation__get_excerpt.json b/Tests/Functional/Controller/responses/legacy/navigation__get_excerpt.json new file mode 100644 index 0000000..b174231 --- /dev/null +++ b/Tests/Functional/Controller/responses/legacy/navigation__get_excerpt.json @@ -0,0 +1,110 @@ +{ + "_embedded": { + "items": [ + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "changed": "@string@.isDateTime()", + "changer": null, + "created": "@string@.isDateTime()", + "publishedState": true, + "published": "@string@.isDateTime()", + "creator": null, + "title": "Test 1", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "path": "@string@.match(\"/test-1\").optional()", + "url": "/test-1", + "urls": { + "de": "/test-1" + }, + "author": null, + "authored": "@string@.isDateTime()", + "order": 20, + "excerpt": { + "title": "", + "more": "", + "description": "", + "categories": [], + "audience_targeting_groups": [], + "tags": [], + "segments": "@array@.isEmpty().optional()", + "icon": [], + "images": [] + }, + "children": [] + }, + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "changed": "@string@.isDateTime()", + "changer": null, + "created": "@string@.isDateTime()", + "publishedState": true, + "published": "@string@.isDateTime()", + "creator": null, + "title": "Test 2", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "path": "@string@.match(\"/test-2\").optional()", + "url": "/test-2", + "urls": { + "de": "/test-2" + }, + "author": null, + "authored": "@string@.isDateTime()", + "order": 30, + "excerpt": { + "title": "", + "more": "", + "description": "", + "categories": [], + "audience_targeting_groups": [], + "tags": [], + "segments": "@array@.isEmpty().optional()", + "icon": [ + { + "id": "@integer@", + "locale": "de", + "collection": "@integer@", + "size": "@integer@", + "mimeType": "image/png", + "title": "Test Image", + "description": "", + "version": 1, + "subVersion": 0, + "name": "test-image.png", + "type": { + "name": "image", + "id": 2 + }, + "isImage": true, + "isVideo": false, + "isAudio": false, + "isDocument": false, + "publishLanguages": [], + "contentLanguages": [], + "tags": [], + "url": "@string@", + "changed": "@string@.isDateTime()", + "created": "@string@.isDateTime()", + "properties": [], + "categories": [], + "targetGroups": [], + "formatUri": "@string@.matchRegex('/^\\/uploads\\/media\\/{format}\\/\\d{2}\\/\\d+-test-image\\.{extension}\\?v=1-0$/')", + "formatPreferredExtension": "png" + } + ], + "images": [] + }, + "children": [] + } + ] + } +} diff --git a/Tests/Functional/Controller/responses/legacy/navigation__get_uuid.json b/Tests/Functional/Controller/responses/legacy/navigation__get_uuid.json new file mode 100644 index 0000000..a4958d5 --- /dev/null +++ b/Tests/Functional/Controller/responses/legacy/navigation__get_uuid.json @@ -0,0 +1,56 @@ +{ + "_embedded": { + "items": [ + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "publishedState": true, + "published": "@string@.isDateTime()", + "title": "Test 1A", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "path": "@string@.match(\"/test-1/test-1a\").optional()", + "url": "/test-1a", + "urls": { + "de": "/test-1a" + }, + "author": null, + "authored": "@string@.isDateTime()", + "changer": null, + "changed": "@string@.isDateTime()", + "creator": null, + "created": "@string@.isDateTime()", + "order": 20, + "children": [] + }, + { + "id": "@uuid@", + "uuid": "@uuid@", + "nodeType": 1, + "publishedState": true, + "published": "@string@.isDateTime()", + "title": "Test 1B", + "locale": "de", + "webspaceKey": "sulu_io", + "template": "default", + "parent": "@uuid@", + "path": "@string@.match(\"/test-1/test-1b\").optional()", + "url": "/test-1b", + "urls": { + "de": "/test-1b" + }, + "author": null, + "authored": "@string@.isDateTime()", + "changer": null, + "changed": "@string@.isDateTime()", + "creator": null, + "created": "@string@.isDateTime()", + "order": 30, + "children": [] + } + ] + } +} diff --git a/Tests/Functional/Controller/responses/navigation__get.json b/Tests/Functional/Controller/responses/navigation__get.json index d7554f1..444c446 100644 --- a/Tests/Functional/Controller/responses/navigation__get.json +++ b/Tests/Functional/Controller/responses/navigation__get.json @@ -17,6 +17,7 @@ "urls": { "de": "\/test-1" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "changer": null, @@ -42,6 +43,7 @@ "urls": { "de": "\/test-2" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "changer": null, diff --git a/Tests/Functional/Controller/responses/navigation__get_context_footer.json b/Tests/Functional/Controller/responses/navigation__get_context_footer.json index 1427482..7c4aa8b 100644 --- a/Tests/Functional/Controller/responses/navigation__get_context_footer.json +++ b/Tests/Functional/Controller/responses/navigation__get_context_footer.json @@ -17,6 +17,7 @@ "urls": { "de": "\/test-3" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "changer": null, diff --git a/Tests/Functional/Controller/responses/navigation__get_depth_2.json b/Tests/Functional/Controller/responses/navigation__get_depth_2.json index c26ea65..3f51631 100644 --- a/Tests/Functional/Controller/responses/navigation__get_depth_2.json +++ b/Tests/Functional/Controller/responses/navigation__get_depth_2.json @@ -17,6 +17,7 @@ "urls": { "de": "\/test-1" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "changer": null, @@ -41,6 +42,7 @@ "urls": { "de": "/test-1a" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "changer": null, @@ -66,6 +68,7 @@ "urls": { "de": "/test-1b" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "changer": null, @@ -93,6 +96,7 @@ "urls": { "de": "\/test-2" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "changer": null, diff --git a/Tests/Functional/Controller/responses/navigation__get_depth_2_flat.json b/Tests/Functional/Controller/responses/navigation__get_depth_2_flat.json index d17f7e5..4d533a5 100644 --- a/Tests/Functional/Controller/responses/navigation__get_depth_2_flat.json +++ b/Tests/Functional/Controller/responses/navigation__get_depth_2_flat.json @@ -17,6 +17,7 @@ "urls": { "de": "\/test-1" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "changer": null, @@ -42,6 +43,7 @@ "urls": { "de": "/test-1a" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "changer": null, @@ -67,6 +69,7 @@ "urls": { "de": "\/test-2" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "changer": null, @@ -92,6 +95,7 @@ "urls": { "de": "/test-1b" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "changer": null, diff --git a/Tests/Functional/Controller/responses/navigation__get_excerpt.json b/Tests/Functional/Controller/responses/navigation__get_excerpt.json index 0d3aa60..d88ad65 100644 --- a/Tests/Functional/Controller/responses/navigation__get_excerpt.json +++ b/Tests/Functional/Controller/responses/navigation__get_excerpt.json @@ -21,6 +21,7 @@ "urls": { "de": "\/test-1" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "order": 20, @@ -57,6 +58,7 @@ "urls": { "de": "\/test-2" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "order": 30, diff --git a/Tests/Functional/Controller/responses/navigation__get_uuid.json b/Tests/Functional/Controller/responses/navigation__get_uuid.json index a4958d5..b694877 100644 --- a/Tests/Functional/Controller/responses/navigation__get_uuid.json +++ b/Tests/Functional/Controller/responses/navigation__get_uuid.json @@ -17,6 +17,7 @@ "urls": { "de": "/test-1a" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "changer": null, @@ -42,6 +43,7 @@ "urls": { "de": "/test-1b" }, + "lastModified": null, "author": null, "authored": "@string@.isDateTime()", "changer": null, From a24eaed9e7f058b43cc168958d9cf5f4ddc7d2d2 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 10 Jun 2024 12:43:51 +0200 Subject: [PATCH 06/10] Fix uuid --- .../ContentTypeResolver/SinglePageSelectionResolverTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Tests/Unit/Content/ContentTypeResolver/SinglePageSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/SinglePageSelectionResolverTest.php index ff70d1a..c3eebd4 100644 --- a/Tests/Unit/Content/ContentTypeResolver/SinglePageSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/SinglePageSelectionResolverTest.php @@ -49,7 +49,8 @@ public function testGetContentType(): void public function testResolve(): void { $property = $this->prophesize(PropertyInterface::class); - $this->pageSelectionResolver->resolve([1], $property, 'en', [])->willReturn( + $uuid = '2c55ea29-a5ba-4847-90ce-038b86384ab5'; + $this->pageSelectionResolver->resolve([$uuid], $property, 'en', [])->willReturn( new ContentView( [ [ @@ -72,7 +73,7 @@ public function testResolve(): void ) ); - $result = $this->singlePageSelectionResolver->resolve(1, $property->reveal(), 'en'); + $result = $this->singlePageSelectionResolver->resolve($uuid, $property->reveal(), 'en'); $this->assertInstanceOf(ContentView::class, $result); $this->assertSame( From 35c65ccc6a02fd09b4ffd7bad59d7ed79ee96d6f Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 10 Jun 2024 12:49:24 +0200 Subject: [PATCH 07/10] Fix test --- .../SinglePageSelectionResolverTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/Unit/Content/ContentTypeResolver/SinglePageSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/SinglePageSelectionResolverTest.php index c3eebd4..fd50e9b 100644 --- a/Tests/Unit/Content/ContentTypeResolver/SinglePageSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/SinglePageSelectionResolverTest.php @@ -54,8 +54,8 @@ public function testResolve(): void new ContentView( [ [ - 'id' => '1', - 'uuid' => '1', + 'id' => $uuid, + 'uuid' => $uuid, 'nodeType' => 1, 'path' => '/testpage', 'changer' => 1, @@ -78,8 +78,8 @@ public function testResolve(): void $this->assertInstanceOf(ContentView::class, $result); $this->assertSame( [ - 'id' => '1', - 'uuid' => '1', + 'id' => $uuid, + 'uuid' => $uuid, 'nodeType' => 1, 'path' => '/testpage', 'changer' => 1, @@ -96,7 +96,7 @@ public function testResolve(): void ); $this->assertSame( [ - 'id' => 1, + 'id' => $uuid, ], $result->getView() ); From cbcd7324b6504028dc90a234e00efee392e03b11 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 10 Jun 2024 13:01:23 +0200 Subject: [PATCH 08/10] Add prophesize trait --- Tests/Unit/Content/ContentResolverTest.php | 3 +++ .../ContentTypeResolver/AccountSelectionResolverTest.php | 3 +++ Tests/Unit/Content/ContentTypeResolver/BlockResolverTest.php | 3 +++ .../ContentTypeResolver/CategorySelectionResolverTest.php | 3 +++ .../ContentTypeResolver/CollectionSelectionResolverTest.php | 3 +++ .../ContactAccountSelectionResolverTest.php | 3 +++ .../ContentTypeResolver/ContactSelectionResolverTest.php | 3 +++ .../Unit/Content/ContentTypeResolver/ImageMapResolverTest.php | 3 +++ Tests/Unit/Content/ContentTypeResolver/LinkResolverTest.php | 3 +++ .../Content/ContentTypeResolver/MediaSelectionResolverTest.php | 3 +++ .../Content/ContentTypeResolver/PageSelectionResolverTest.php | 3 +++ .../Content/ContentTypeResolver/PageTreeRouteResolverTest.php | 3 +++ .../ContentTypeResolver/ResourceLocatorResolverTest.php | 3 +++ .../ContentTypeResolver/SingleAccountSelectionResolverTest.php | 3 +++ .../SingleCategorySelectionResolverTest.php | 3 +++ .../SingleCollectionSelectionResolverTest.php | 3 +++ .../ContentTypeResolver/SingleContactSelectionResolverTest.php | 3 +++ .../ContentTypeResolver/SingleMediaSelectionResolverTest.php | 3 +++ .../ContentTypeResolver/SinglePageSelectionResolverTest.php | 3 +++ .../ContentTypeResolver/SingleSnippetSelectionResolverTest.php | 3 +++ .../Content/ContentTypeResolver/SmartContentResolverTest.php | 3 +++ .../ContentTypeResolver/SnippetSelectionResolverTest.php | 3 +++ .../ContentTypeResolver/TeaserSelectionResolverTest.php | 3 +++ .../Content/ContentTypeResolver/TextEditorResolverTest.php | 3 +++ .../DataProviderResolver/AccountDataProviderResolverTest.php | 3 +++ .../DataProviderResolver/ContactDataProviderResolverTest.php | 3 +++ .../DataProviderResolver/MediaDataProviderResolverTest.php | 3 +++ .../DataProviderResolver/PageDataProviderResolverTest.php | 3 +++ .../DataProviderResolver/SnippetDataProviderResolverTest.php | 3 +++ Tests/Unit/Content/Serializer/AccountSerializerTest.php | 3 +++ Tests/Unit/Content/Serializer/CategorySerializerTest.php | 3 +++ Tests/Unit/Content/Serializer/ContactSerializerTest.php | 3 +++ Tests/Unit/Content/Serializer/MediaSerializerTest.php | 3 +++ Tests/Unit/Content/Serializer/TeaserSerializerTest.php | 3 +++ Tests/Unit/Content/StructureResolverTest.php | 3 +++ composer.json | 1 + 36 files changed, 106 insertions(+) diff --git a/Tests/Unit/Content/ContentResolverTest.php b/Tests/Unit/Content/ContentResolverTest.php index ee823ca..4dc9cc2 100644 --- a/Tests/Unit/Content/ContentResolverTest.php +++ b/Tests/Unit/Content/ContentResolverTest.php @@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentResolver; use Sulu\Bundle\HeadlessBundle\Content\ContentResolverInterface; @@ -24,6 +25,8 @@ class ContentResolverTest extends TestCase { + use ProphecyTrait; + /** * @var ContentTypeResolverInterface|ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/AccountSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/AccountSelectionResolverTest.php index be85e47..e7224f9 100644 --- a/Tests/Unit/Content/ContentTypeResolver/AccountSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/AccountSelectionResolverTest.php @@ -16,6 +16,7 @@ use JMS\Serializer\SerializationContext; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\ContactBundle\Api\Account; use Sulu\Bundle\ContactBundle\Contact\AccountManager; @@ -27,6 +28,8 @@ class AccountSelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var AccountManager|ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/BlockResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/BlockResolverTest.php index e509dfb..e7dee1b 100644 --- a/Tests/Unit/Content/ContentTypeResolver/BlockResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/BlockResolverTest.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\HeadlessBundle\Tests\Unit\Content\ContentTypeResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentResolverInterface; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\BlockResolver; @@ -25,6 +26,8 @@ class BlockResolverTest extends TestCase { + use ProphecyTrait; + /** * @var ContentResolverInterface|ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/CategorySelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/CategorySelectionResolverTest.php index c8371ce..108ab0a 100644 --- a/Tests/Unit/Content/ContentTypeResolver/CategorySelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/CategorySelectionResolverTest.php @@ -16,6 +16,7 @@ use JMS\Serializer\SerializationContext; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\CategoryBundle\Category\CategoryManagerInterface; use Sulu\Bundle\CategoryBundle\Entity\CategoryInterface; @@ -26,6 +27,8 @@ class CategorySelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var CategoryManagerInterface|ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/CollectionSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/CollectionSelectionResolverTest.php index bdeb7c9..f4109ce 100644 --- a/Tests/Unit/Content/ContentTypeResolver/CollectionSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/CollectionSelectionResolverTest.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\HeadlessBundle\Tests\Unit\Content\ContentTypeResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\CollectionSelectionResolver; use Sulu\Bundle\HeadlessBundle\Content\ContentView; @@ -24,6 +25,8 @@ class CollectionSelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/ContactAccountSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/ContactAccountSelectionResolverTest.php index 23c48aa..79936ab 100644 --- a/Tests/Unit/Content/ContentTypeResolver/ContactAccountSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/ContactAccountSelectionResolverTest.php @@ -16,6 +16,7 @@ use JMS\Serializer\SerializationContext; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\ContactBundle\Api\Account; use Sulu\Bundle\ContactBundle\Api\Contact; @@ -31,6 +32,8 @@ class ContactAccountSelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var ContactManager|ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/ContactSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/ContactSelectionResolverTest.php index 61e71de..35f6ea7 100644 --- a/Tests/Unit/Content/ContentTypeResolver/ContactSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/ContactSelectionResolverTest.php @@ -16,6 +16,7 @@ use JMS\Serializer\SerializationContext; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\ContactBundle\Api\Contact; use Sulu\Bundle\ContactBundle\Contact\ContactManager; @@ -27,6 +28,8 @@ class ContactSelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var ContactManager|ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/ImageMapResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/ImageMapResolverTest.php index 713b377..084a516 100644 --- a/Tests/Unit/Content/ContentTypeResolver/ImageMapResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/ImageMapResolverTest.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\HeadlessBundle\Tests\Unit\Content\ContentTypeResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentResolverInterface; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\ImageMapResolver; @@ -28,6 +29,8 @@ class ImageMapResolverTest extends TestCase { + use ProphecyTrait; + /** * @var MediaManagerInterface|ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/LinkResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/LinkResolverTest.php index a984e03..d60df44 100644 --- a/Tests/Unit/Content/ContentTypeResolver/LinkResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/LinkResolverTest.php @@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\LinkResolver; use Sulu\Bundle\MarkupBundle\Markup\Link\LinkItem; use Sulu\Bundle\MarkupBundle\Markup\Link\LinkProviderInterface; @@ -24,6 +25,8 @@ class LinkResolverTest extends TestCase { + use ProphecyTrait; + public function testGetContentType(): void { $linkProviderPool = $this->prophesize(LinkProviderPoolInterface::class); diff --git a/Tests/Unit/Content/ContentTypeResolver/MediaSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/MediaSelectionResolverTest.php index 8033a14..1802c53 100644 --- a/Tests/Unit/Content/ContentTypeResolver/MediaSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/MediaSelectionResolverTest.php @@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\MediaSelectionResolver; use Sulu\Bundle\HeadlessBundle\Content\ContentView; @@ -26,6 +27,8 @@ class MediaSelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var MediaManagerInterface|ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/PageSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/PageSelectionResolverTest.php index bcf00ce..c538d3f 100644 --- a/Tests/Unit/Content/ContentTypeResolver/PageSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/PageSelectionResolverTest.php @@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\PageSelectionResolver; use Sulu\Bundle\HeadlessBundle\Content\ContentView; @@ -27,6 +28,8 @@ class PageSelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var StructureResolverInterface|ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/PageTreeRouteResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/PageTreeRouteResolverTest.php index dfbf052..01de6e9 100644 --- a/Tests/Unit/Content/ContentTypeResolver/PageTreeRouteResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/PageTreeRouteResolverTest.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\HeadlessBundle\Tests\Unit\Content\ContentTypeResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\PageTreeRouteResolver; use Sulu\Bundle\HeadlessBundle\Content\ContentView; @@ -21,6 +22,8 @@ class PageTreeRouteResolverTest extends TestCase { + use ProphecyTrait; + /** * @var PageTreeRouteResolver */ diff --git a/Tests/Unit/Content/ContentTypeResolver/ResourceLocatorResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/ResourceLocatorResolverTest.php index 78b1563..79d7aca 100644 --- a/Tests/Unit/Content/ContentTypeResolver/ResourceLocatorResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/ResourceLocatorResolverTest.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\HeadlessBundle\Tests\Unit\Content\ContentTypeResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\ResourceLocatorResolver; use Sulu\Bundle\HeadlessBundle\Content\ContentView; @@ -23,6 +24,8 @@ class ResourceLocatorResolverTest extends TestCase { + use ProphecyTrait; + /** * @var ResourceLocatorResolver */ diff --git a/Tests/Unit/Content/ContentTypeResolver/SingleAccountSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/SingleAccountSelectionResolverTest.php index f722757..a6f47bc 100644 --- a/Tests/Unit/Content/ContentTypeResolver/SingleAccountSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/SingleAccountSelectionResolverTest.php @@ -16,6 +16,7 @@ use JMS\Serializer\SerializationContext; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\ContactBundle\Api\Account; use Sulu\Bundle\ContactBundle\Contact\AccountManager; @@ -27,6 +28,8 @@ class SingleAccountSelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var AccountManager|ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/SingleCategorySelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/SingleCategorySelectionResolverTest.php index 74c277b..698261d 100644 --- a/Tests/Unit/Content/ContentTypeResolver/SingleCategorySelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/SingleCategorySelectionResolverTest.php @@ -16,6 +16,7 @@ use JMS\Serializer\SerializationContext; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\CategoryBundle\Category\CategoryManagerInterface; use Sulu\Bundle\CategoryBundle\Entity\CategoryInterface; @@ -26,6 +27,8 @@ class SingleCategorySelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var CategoryManagerInterface|ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/SingleCollectionSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/SingleCollectionSelectionResolverTest.php index 3901c68..280fbca 100644 --- a/Tests/Unit/Content/ContentTypeResolver/SingleCollectionSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/SingleCollectionSelectionResolverTest.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\HeadlessBundle\Tests\Unit\Content\ContentTypeResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\CollectionSelectionResolver; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\SingleCollectionSelectionResolver; @@ -22,6 +23,8 @@ class SingleCollectionSelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var SingleCollectionSelectionResolver */ diff --git a/Tests/Unit/Content/ContentTypeResolver/SingleContactSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/SingleContactSelectionResolverTest.php index f536624..3552213 100644 --- a/Tests/Unit/Content/ContentTypeResolver/SingleContactSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/SingleContactSelectionResolverTest.php @@ -16,6 +16,7 @@ use JMS\Serializer\SerializationContext; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\ContactBundle\Api\Contact; use Sulu\Bundle\ContactBundle\Contact\ContactManager; @@ -27,6 +28,8 @@ class SingleContactSelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var ContactManager|ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/SingleMediaSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/SingleMediaSelectionResolverTest.php index 86bb9c4..82026f3 100644 --- a/Tests/Unit/Content/ContentTypeResolver/SingleMediaSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/SingleMediaSelectionResolverTest.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\HeadlessBundle\Tests\Unit\Content\ContentTypeResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\MediaSelectionResolver; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\SingleMediaSelectionResolver; @@ -22,6 +23,8 @@ class SingleMediaSelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var SingleMediaSelectionResolver */ diff --git a/Tests/Unit/Content/ContentTypeResolver/SinglePageSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/SinglePageSelectionResolverTest.php index fd50e9b..3e4909e 100644 --- a/Tests/Unit/Content/ContentTypeResolver/SinglePageSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/SinglePageSelectionResolverTest.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\HeadlessBundle\Tests\Unit\Content\ContentTypeResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\PageSelectionResolver; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\SinglePageSelectionResolver; @@ -22,6 +23,8 @@ class SinglePageSelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var SinglePageSelectionResolver */ diff --git a/Tests/Unit/Content/ContentTypeResolver/SingleSnippetSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/SingleSnippetSelectionResolverTest.php index 0d6948c..dfbb54f 100644 --- a/Tests/Unit/Content/ContentTypeResolver/SingleSnippetSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/SingleSnippetSelectionResolverTest.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\HeadlessBundle\Tests\Unit\Content\ContentTypeResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\SingleSnippetSelectionResolver; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\SnippetSelectionResolver; @@ -29,6 +30,8 @@ class SingleSnippetSelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var ObjectProphecy|ContentMapperInterface */ diff --git a/Tests/Unit/Content/ContentTypeResolver/SmartContentResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/SmartContentResolverTest.php index d6bb8cd..190cf36 100644 --- a/Tests/Unit/Content/ContentTypeResolver/SmartContentResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/SmartContentResolverTest.php @@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\AudienceTargetingBundle\TargetGroup\TargetGroupStoreInterface; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\SmartContentResolver; @@ -34,6 +35,8 @@ class SmartContentResolverTest extends TestCase { + use ProphecyTrait; + /** * @var DataProviderResolverInterface|ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/SnippetSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/SnippetSelectionResolverTest.php index 3efc423..ddbc011 100644 --- a/Tests/Unit/Content/ContentTypeResolver/SnippetSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/SnippetSelectionResolverTest.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\HeadlessBundle\Tests\Unit\Content\ContentTypeResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\SnippetSelectionResolver; use Sulu\Bundle\HeadlessBundle\Content\ContentView; @@ -28,6 +29,8 @@ class SnippetSelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var ObjectProphecy|ContentMapperInterface */ diff --git a/Tests/Unit/Content/ContentTypeResolver/TeaserSelectionResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/TeaserSelectionResolverTest.php index 052edb9..4ce2ec9 100644 --- a/Tests/Unit/Content/ContentTypeResolver/TeaserSelectionResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/TeaserSelectionResolverTest.php @@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\TeaserSelectionResolver; use Sulu\Bundle\HeadlessBundle\Content\Serializer\TeaserSerializerInterface; @@ -24,6 +25,8 @@ class TeaserSelectionResolverTest extends TestCase { + use ProphecyTrait; + /** * @var TeaserManagerInterface|ObjectProphecy */ diff --git a/Tests/Unit/Content/ContentTypeResolver/TextEditorResolverTest.php b/Tests/Unit/Content/ContentTypeResolver/TextEditorResolverTest.php index d61f766..de25e5f 100644 --- a/Tests/Unit/Content/ContentTypeResolver/TextEditorResolverTest.php +++ b/Tests/Unit/Content/ContentTypeResolver/TextEditorResolverTest.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\HeadlessBundle\Tests\Unit\Content\ContentTypeResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\ContentTypeResolver\TextEditorResolver; use Sulu\Bundle\HeadlessBundle\Content\ContentView; @@ -22,6 +23,8 @@ class TextEditorResolverTest extends TestCase { + use ProphecyTrait; + /** * @var MarkupParserInterface|ObjectProphecy */ diff --git a/Tests/Unit/Content/DataProviderResolver/AccountDataProviderResolverTest.php b/Tests/Unit/Content/DataProviderResolver/AccountDataProviderResolverTest.php index 97940ee..0e0489c 100644 --- a/Tests/Unit/Content/DataProviderResolver/AccountDataProviderResolverTest.php +++ b/Tests/Unit/Content/DataProviderResolver/AccountDataProviderResolverTest.php @@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\ContactBundle\Api\Account; use Sulu\Bundle\ContactBundle\Entity\AccountInterface; @@ -28,6 +29,8 @@ class AccountDataProviderResolverTest extends TestCase { + use ProphecyTrait; + /** * @var AccountDataProvider|ObjectProphecy */ diff --git a/Tests/Unit/Content/DataProviderResolver/ContactDataProviderResolverTest.php b/Tests/Unit/Content/DataProviderResolver/ContactDataProviderResolverTest.php index 5234b6a..dc80a67 100644 --- a/Tests/Unit/Content/DataProviderResolver/ContactDataProviderResolverTest.php +++ b/Tests/Unit/Content/DataProviderResolver/ContactDataProviderResolverTest.php @@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\ContactBundle\Api\Contact; use Sulu\Bundle\ContactBundle\Entity\ContactInterface; @@ -28,6 +29,8 @@ class ContactDataProviderResolverTest extends TestCase { + use ProphecyTrait; + /** * @var ContactDataProvider|ObjectProphecy */ diff --git a/Tests/Unit/Content/DataProviderResolver/MediaDataProviderResolverTest.php b/Tests/Unit/Content/DataProviderResolver/MediaDataProviderResolverTest.php index d3cc04b..1537bd3 100644 --- a/Tests/Unit/Content/DataProviderResolver/MediaDataProviderResolverTest.php +++ b/Tests/Unit/Content/DataProviderResolver/MediaDataProviderResolverTest.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\HeadlessBundle\Tests\Unit\Content\DataProviderResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\DataProviderResolver\MediaDataProviderResolver; use Sulu\Bundle\HeadlessBundle\Content\Serializer\MediaSerializerInterface; @@ -27,6 +28,8 @@ class MediaDataProviderResolverTest extends TestCase { + use ProphecyTrait; + /** * @var MediaDataProvider|ObjectProphecy */ diff --git a/Tests/Unit/Content/DataProviderResolver/PageDataProviderResolverTest.php b/Tests/Unit/Content/DataProviderResolver/PageDataProviderResolverTest.php index 3eee637..64337fa 100644 --- a/Tests/Unit/Content/DataProviderResolver/PageDataProviderResolverTest.php +++ b/Tests/Unit/Content/DataProviderResolver/PageDataProviderResolverTest.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\HeadlessBundle\Tests\Unit\Content\DataProviderResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\DataProviderResolver\PageDataProviderResolver; use Sulu\Bundle\HeadlessBundle\Content\StructureResolverInterface; @@ -28,6 +29,8 @@ class PageDataProviderResolverTest extends TestCase { + use ProphecyTrait; + /** * @var PageDataProvider|ObjectProphecy */ diff --git a/Tests/Unit/Content/DataProviderResolver/SnippetDataProviderResolverTest.php b/Tests/Unit/Content/DataProviderResolver/SnippetDataProviderResolverTest.php index 43f52e1..0c06bfc 100644 --- a/Tests/Unit/Content/DataProviderResolver/SnippetDataProviderResolverTest.php +++ b/Tests/Unit/Content/DataProviderResolver/SnippetDataProviderResolverTest.php @@ -14,6 +14,7 @@ namespace Sulu\Bundle\HeadlessBundle\Tests\Unit\Content\DataProviderResolver; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\DataProviderResolver\SnippetDataProviderResolver; use Sulu\Bundle\HeadlessBundle\Content\StructureResolverInterface; @@ -28,6 +29,8 @@ class SnippetDataProviderResolverTest extends TestCase { + use ProphecyTrait; + /** * @var DataProviderInterface|ObjectProphecy */ diff --git a/Tests/Unit/Content/Serializer/AccountSerializerTest.php b/Tests/Unit/Content/Serializer/AccountSerializerTest.php index 6c43422..8e09be3 100644 --- a/Tests/Unit/Content/Serializer/AccountSerializerTest.php +++ b/Tests/Unit/Content/Serializer/AccountSerializerTest.php @@ -16,6 +16,7 @@ use JMS\Serializer\SerializationContext; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\ContactBundle\Api\Account; use Sulu\Bundle\ContactBundle\Contact\AccountManager; @@ -31,6 +32,8 @@ class AccountSerializerTest extends TestCase { + use ProphecyTrait; + /** * @var AccountManager|ObjectProphecy */ diff --git a/Tests/Unit/Content/Serializer/CategorySerializerTest.php b/Tests/Unit/Content/Serializer/CategorySerializerTest.php index 2f329c1..7b088df 100644 --- a/Tests/Unit/Content/Serializer/CategorySerializerTest.php +++ b/Tests/Unit/Content/Serializer/CategorySerializerTest.php @@ -15,6 +15,7 @@ use JMS\Serializer\SerializationContext; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\CategoryBundle\Api\Category; use Sulu\Bundle\CategoryBundle\Category\CategoryManagerInterface; @@ -28,6 +29,8 @@ class CategorySerializerTest extends TestCase { + use ProphecyTrait; + /** * @var CategoryManagerInterface|ObjectProphecy */ diff --git a/Tests/Unit/Content/Serializer/ContactSerializerTest.php b/Tests/Unit/Content/Serializer/ContactSerializerTest.php index ebe9109..36e0fe1 100644 --- a/Tests/Unit/Content/Serializer/ContactSerializerTest.php +++ b/Tests/Unit/Content/Serializer/ContactSerializerTest.php @@ -16,6 +16,7 @@ use JMS\Serializer\SerializationContext; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\ContactBundle\Api\Contact; use Sulu\Bundle\ContactBundle\Contact\ContactManager; @@ -35,6 +36,8 @@ class ContactSerializerTest extends TestCase { + use ProphecyTrait; + /** * @var ContactManager|ObjectProphecy */ diff --git a/Tests/Unit/Content/Serializer/MediaSerializerTest.php b/Tests/Unit/Content/Serializer/MediaSerializerTest.php index 7dbc6a0..c50b871 100644 --- a/Tests/Unit/Content/Serializer/MediaSerializerTest.php +++ b/Tests/Unit/Content/Serializer/MediaSerializerTest.php @@ -16,6 +16,7 @@ use JMS\Serializer\SerializationContext; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\Serializer\MediaSerializer; use Sulu\Bundle\HeadlessBundle\Content\Serializer\MediaSerializerInterface; @@ -33,6 +34,8 @@ class MediaSerializerTest extends TestCase { + use ProphecyTrait; + /** * @var MediaManagerInterface|ObjectProphecy */ diff --git a/Tests/Unit/Content/Serializer/TeaserSerializerTest.php b/Tests/Unit/Content/Serializer/TeaserSerializerTest.php index 7e33208..0e44b92 100644 --- a/Tests/Unit/Content/Serializer/TeaserSerializerTest.php +++ b/Tests/Unit/Content/Serializer/TeaserSerializerTest.php @@ -16,6 +16,7 @@ use JMS\Serializer\SerializationContext; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\HeadlessBundle\Content\Serializer\MediaSerializerInterface; use Sulu\Bundle\HeadlessBundle\Content\Serializer\TeaserSerializer; @@ -30,6 +31,8 @@ class TeaserSerializerTest extends TestCase { + use ProphecyTrait; + /** * @var ArraySerializerInterface|ObjectProphecy */ diff --git a/Tests/Unit/Content/StructureResolverTest.php b/Tests/Unit/Content/StructureResolverTest.php index 6fc8cf9..21b77ef 100644 --- a/Tests/Unit/Content/StructureResolverTest.php +++ b/Tests/Unit/Content/StructureResolverTest.php @@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\DocumentManagerBundle\Bridge\DocumentInspector; use Sulu\Bundle\HeadlessBundle\Content\ContentResolverInterface; @@ -33,6 +34,8 @@ class StructureResolverTest extends TestCase { + use ProphecyTrait; + /** * @var StructureBridge|ObjectProphecy */ diff --git a/composer.json b/composer.json index 9537f0f..221ea29 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ "jangregor/phpstan-prophecy": "^1.0", "php-cs-fixer/shim": "^3.0", "phpspec/prophecy": "^1.8", + "phpspec/prophecy-phpunit": "^2.0", "phpstan/phpstan": "^1.0", "phpstan/phpstan-doctrine": "^1.0", "phpstan/phpstan-phpunit": "^1.0", From c675b6f75fbf1c8007872a9dc63d9eeda54f9269 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 10 Jun 2024 13:01:31 +0200 Subject: [PATCH 09/10] Fix some linting errors --- Content/Serializer/MediaSerializer.php | 2 +- Tests/Functional/Controller/NavigationControllerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Content/Serializer/MediaSerializer.php b/Content/Serializer/MediaSerializer.php index 19941e5..c4a502f 100644 --- a/Content/Serializer/MediaSerializer.php +++ b/Content/Serializer/MediaSerializer.php @@ -96,7 +96,7 @@ public function serialize(MediaInterface $media, string $locale, ?SerializationC $fileName = \pathinfo($fileName)['filename'] . '.' . $preferredExtension; // extension brackets cannot be added here because of the urlencoding - $fileName = \pathinfo($fileName)['filename'] . '.' . 'extension'; + $fileName = \pathinfo($fileName)['filename'] . '.extension'; $formatUri = $this->formatCache->getMediaUrl( $formatMediaApi->getId(), $fileName, diff --git a/Tests/Functional/Controller/NavigationControllerTest.php b/Tests/Functional/Controller/NavigationControllerTest.php index 61668a7..45557d7 100644 --- a/Tests/Functional/Controller/NavigationControllerTest.php +++ b/Tests/Functional/Controller/NavigationControllerTest.php @@ -21,7 +21,7 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Component\HttpFoundation\Response; -class NavigationControllerTest2 extends BaseTestCase +class NavigationControllerTest extends BaseTestCase { use CreateMediaTrait; use CreatePageTrait; From 115cf3098dde6d6b9fa1a7bc09cfcd9ec4f1948a Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 10 Jun 2024 13:04:33 +0200 Subject: [PATCH 10/10] Fix php cs --- .php-cs-fixer.dist.php | 1 + 1 file changed, 1 insertion(+) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 7434ac2..3165f8f 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -49,6 +49,7 @@ 'ignored_tags' => ['todo', 'var'], ], 'trailing_comma_in_multiline' => ['elements' => ['arrays', /*'arguments', 'parameters' */]], + 'modernize_strpos' => false, // remove when min requirement PHP 8 ]) ->setFinder($finder);