From c8311d8567717ab49a0cc84c8a1cb14e51079f91 Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Wed, 22 Oct 2025 08:31:50 +0200 Subject: [PATCH 01/17] NGSTACK-1000 upgrade bundle to use Ibexa 5 --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 9d818b5..8535b7e 100644 --- a/composer.json +++ b/composer.json @@ -18,15 +18,15 @@ } ], "require": { - "php": "^8.1", - "ibexa/core": "^4.4", + "php": "^8.3", + "ibexa/core": "^5.0", "twig/twig": "^3.0" }, "require-dev": { - "ibexa/fieldtype-richtext": "^4.4", - "phpunit/phpunit": "^9.6", - "matthiasnoback/symfony-config-test": "^5.0", - "matthiasnoback/symfony-dependency-injection-test": "^5.0" + "ibexa/fieldtype-richtext": "^5.0", + "phpunit/phpunit": "^12.0", + "matthiasnoback/symfony-config-test": "^6.0", + "matthiasnoback/symfony-dependency-injection-test": "^6.0" }, "minimum-stability": "dev", "prefer-stable": true, From 5ed6538f985ad085dbc9804986f83096fdd0e2e7 Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Wed, 22 Oct 2025 08:37:31 +0200 Subject: [PATCH 02/17] NGSTACK-1000 modify multiple classes to use constructor promotion for its properties --- bundle/Handler/FieldType/Handler.php | 9 +++------ bundle/Handler/FieldType/Image.php | 16 ++++------------ bundle/Handler/Literal/CanonicalUrl.php | 13 ++++--------- bundle/Handler/Literal/Url.php | 9 +++------ bundle/MetaTag/Collector.php | 17 +++++------------ bundle/MetaTag/Item.php | 13 ++++--------- .../Twig/Extension/NetgenOpenGraphRuntime.php | 18 +++++------------- 7 files changed, 28 insertions(+), 67 deletions(-) diff --git a/bundle/Handler/FieldType/Handler.php b/bundle/Handler/FieldType/Handler.php index 749c309..11be254 100644 --- a/bundle/Handler/FieldType/Handler.php +++ b/bundle/Handler/FieldType/Handler.php @@ -15,12 +15,9 @@ abstract class Handler extends BaseHandler { - protected FieldHelper $fieldHelper; - - public function __construct(FieldHelper $fieldHelper) - { - $this->fieldHelper = $fieldHelper; - } + public function __construct( + protected FieldHelper $fieldHelper, + ) {} public function getMetaTags(string $tagName, array $params = []): array { diff --git a/bundle/Handler/FieldType/Image.php b/bundle/Handler/FieldType/Image.php index 267562f..b87c048 100644 --- a/bundle/Handler/FieldType/Image.php +++ b/bundle/Handler/FieldType/Image.php @@ -21,23 +21,15 @@ final class Image extends Handler { - private VariationHandler $imageVariationService; - - private RequestStack $requestStack; - - private LoggerInterface $logger; - public function __construct( FieldHelper $fieldHelper, - VariationHandler $imageVariationService, - RequestStack $requestStack, - ?LoggerInterface $logger = null, + private readonly VariationHandler $imageVariationService, + private readonly RequestStack $requestStack, + private ?LoggerInterface $logger = null, ) { parent::__construct($fieldHelper); - $this->imageVariationService = $imageVariationService; - $this->requestStack = $requestStack; - $this->logger = $logger ?? new NullLogger(); + $this->logger ??= new NullLogger(); } protected function getFieldValue(Field $field, string $tagName, array $params = []): string diff --git a/bundle/Handler/Literal/CanonicalUrl.php b/bundle/Handler/Literal/CanonicalUrl.php index b63e659..ebf8cf2 100644 --- a/bundle/Handler/Literal/CanonicalUrl.php +++ b/bundle/Handler/Literal/CanonicalUrl.php @@ -15,15 +15,10 @@ final class CanonicalUrl implements HandlerInterface { - private RequestStack $requestStack; - - private UrlGeneratorInterface $urlGenerator; - - public function __construct(RequestStack $requestStack, UrlGeneratorInterface $urlGenerator) - { - $this->requestStack = $requestStack; - $this->urlGenerator = $urlGenerator; - } + public function __construct( + private readonly RequestStack $requestStack, + private readonly UrlGeneratorInterface $urlGenerator, + ) {} public function getMetaTags($tagName, array $params = []): array { diff --git a/bundle/Handler/Literal/Url.php b/bundle/Handler/Literal/Url.php index dd1548a..1501603 100644 --- a/bundle/Handler/Literal/Url.php +++ b/bundle/Handler/Literal/Url.php @@ -15,12 +15,9 @@ final class Url implements HandlerInterface { - private RequestStack $requestStack; - - public function __construct(RequestStack $requestStack) - { - $this->requestStack = $requestStack; - } + public function __construct( + private readonly RequestStack $requestStack, + ) {} public function getMetaTags(string $tagName, array $params = []): array { diff --git a/bundle/MetaTag/Collector.php b/bundle/MetaTag/Collector.php index c825457..ddb0f6e 100644 --- a/bundle/MetaTag/Collector.php +++ b/bundle/MetaTag/Collector.php @@ -16,18 +16,11 @@ final class Collector implements CollectorInterface { - private Registry $metaTagHandlers; - - private ContentTypeService $contentTypeService; - - private ConfigResolverInterface $configResolver; - - public function __construct(Registry $metaTagHandlers, ContentTypeService $contentTypeService, ConfigResolverInterface $configResolver) - { - $this->metaTagHandlers = $metaTagHandlers; - $this->contentTypeService = $contentTypeService; - $this->configResolver = $configResolver; - } + public function __construct( + private readonly Registry $metaTagHandlers, + private readonly ContentTypeService $contentTypeService, + private readonly ConfigResolverInterface $configResolver, + ) {} public function collect(Content $content): array { diff --git a/bundle/MetaTag/Item.php b/bundle/MetaTag/Item.php index 0268279..f17416a 100644 --- a/bundle/MetaTag/Item.php +++ b/bundle/MetaTag/Item.php @@ -6,15 +6,10 @@ final class Item { - private string $tagName; - - private string $tagValue; - - public function __construct(string $tagName, string $tagValue) - { - $this->tagName = $tagName; - $this->tagValue = $tagValue; - } + public function __construct( + private readonly string $tagName, + private readonly string $tagValue, + ) {} /** * Returns tag name. diff --git a/bundle/Templating/Twig/Extension/NetgenOpenGraphRuntime.php b/bundle/Templating/Twig/Extension/NetgenOpenGraphRuntime.php index 12a07db..38898a9 100644 --- a/bundle/Templating/Twig/Extension/NetgenOpenGraphRuntime.php +++ b/bundle/Templating/Twig/Extension/NetgenOpenGraphRuntime.php @@ -13,26 +13,18 @@ final class NetgenOpenGraphRuntime { - private CollectorInterface $tagCollector; - - private RendererInterface $tagRenderer; - - private LoggerInterface $logger; - private bool $throwExceptions = true; public function __construct( - CollectorInterface $tagCollector, - RendererInterface $tagRenderer, - ?LoggerInterface $logger = null, + private readonly CollectorInterface $tagCollector, + private readonly RendererInterface $tagRenderer, + private ?LoggerInterface $logger = null, ) { - $this->tagCollector = $tagCollector; - $this->tagRenderer = $tagRenderer; - $this->logger = $logger ?? new NullLogger(); + $this->logger ??= new NullLogger(); } /** - * Sets the flag that determines if the exceptions will thrown instead of logged. + * Sets the flag that determines if the exceptions will be thrown instead of logged. */ public function setThrowExceptions(bool $throwExceptions = true): void { From 06074b0d5c1a593c910097cce33785535461616b Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Wed, 22 Oct 2025 08:38:02 +0200 Subject: [PATCH 03/17] NGSTACK-1000 replace 'mb_strpos' with 'str_starts_with' method in Image fieldType handler --- bundle/Handler/FieldType/Image.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundle/Handler/FieldType/Image.php b/bundle/Handler/FieldType/Image.php index b87c048..e9284b0 100644 --- a/bundle/Handler/FieldType/Image.php +++ b/bundle/Handler/FieldType/Image.php @@ -17,7 +17,7 @@ use Symfony\Component\HttpFoundation\RequestStack; use function ltrim; -use function mb_strpos; +use function str_starts_with; final class Image extends Handler { @@ -40,7 +40,7 @@ protected function getFieldValue(Field $field, string $tagName, array $params = try { $variationUri = $this->imageVariationService->getVariation($field, $this->content->getVersionInfo(), $variationName)->uri; - if (mb_strpos($variationUri, '/') === 0 && ($request = $this->requestStack->getCurrentRequest()) !== null) { + if (str_starts_with($variationUri, '/') && ($request = $this->requestStack->getCurrentRequest()) !== null) { $variationUri = $request->getUriForPath('/' . ltrim($variationUri, '/')); } From a021bef1012ef865da1f67b83b644801900dc6ed Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Wed, 22 Oct 2025 08:51:05 +0200 Subject: [PATCH 04/17] NGSTACK-1000 migrate phpunit.xml to a newer version --- phpunit.xml | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 148ef7c..cd47c66 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,12 +1,10 @@ - @@ -15,18 +13,17 @@ tests - - + + + bundle - - bundle/Resources - - - + + + bundle/Resources + + + - - - - + From 94c5750f857974f0b05bc3e015cf1fbf2d658d61 Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Wed, 22 Oct 2025 08:51:24 +0200 Subject: [PATCH 05/17] NGSTACK-1000 modify tests to be compatible with PHP8 and PHPUnit12 --- .../NetgenOpenGraphExtensionTest.php | 5 ++-- tests/Handler/Literal/UrlTest.php | 13 ++++---- tests/Handler/RegistryTest.php | 4 +-- tests/MetaTag/CollectorTest.php | 30 ++++++------------- tests/NetgenOpenGraphBundleTest.php | 2 +- 5 files changed, 19 insertions(+), 35 deletions(-) diff --git a/tests/DependencyInjection/NetgenOpenGraphExtensionTest.php b/tests/DependencyInjection/NetgenOpenGraphExtensionTest.php index dd361cf..19a25d4 100644 --- a/tests/DependencyInjection/NetgenOpenGraphExtensionTest.php +++ b/tests/DependencyInjection/NetgenOpenGraphExtensionTest.php @@ -6,12 +6,11 @@ use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; use Netgen\Bundle\OpenGraphBundle\DependencyInjection\NetgenOpenGraphExtension; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; final class NetgenOpenGraphExtensionTest extends AbstractExtensionTestCase { - /** - * @doesNotPerformAssertions - */ + #[DoesNotPerformAssertions] public function testItSetsValidContainerParameters(): void { $this->container->setParameter('ibexa.site_access.list', []); diff --git a/tests/Handler/Literal/UrlTest.php b/tests/Handler/Literal/UrlTest.php index 73b61ab..29a6fc6 100644 --- a/tests/Handler/Literal/UrlTest.php +++ b/tests/Handler/Literal/UrlTest.php @@ -8,6 +8,7 @@ use Netgen\Bundle\OpenGraphBundle\Handler\HandlerInterface; use Netgen\Bundle\OpenGraphBundle\Handler\Literal\Url; use Netgen\Bundle\OpenGraphBundle\MetaTag\Item; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; @@ -37,9 +38,7 @@ public function testGettingTagsWithEmptyParams(): void $this->url->getMetaTags('some_tag'); } - /** - * @dataProvider validResultProvider - */ + #[DataProvider('validResultProvider')] public function testGettingTagsWithValidResult(string $input, string $output): void { $request = Request::create('https://domain.com'); @@ -54,7 +53,7 @@ public function testGettingTagsWithValidResult(string $input, string $output): v self::assertSame($output, $result[0]->getTagValue()); } - public function validResultProvider(): iterable + public static function validResultProvider(): iterable { return [ ['https://other.domain.com/some/path', 'https://other.domain.com/some/path'], @@ -66,9 +65,7 @@ public function validResultProvider(): iterable ]; } - /** - * @dataProvider validResultProviderWithoutRequest - */ + #[DataProvider('validResultProviderWithoutRequest')] public function testGettingTagsWithValidResultAndWithoutRequest(string $input, string $output): void { $result = $this->url->getMetaTags('some_tag', [$input]); @@ -79,7 +76,7 @@ public function testGettingTagsWithValidResultAndWithoutRequest(string $input, s self::assertSame($output, $result[0]->getTagValue()); } - public function validResultProviderWithoutRequest(): iterable + public static function validResultProviderWithoutRequest(): iterable { return [ ['https://other.domain.com/some/path', 'https://other.domain.com/some/path'], diff --git a/tests/Handler/RegistryTest.php b/tests/Handler/RegistryTest.php index 3d529ce..fa64348 100644 --- a/tests/Handler/RegistryTest.php +++ b/tests/Handler/RegistryTest.php @@ -20,7 +20,7 @@ protected function setUp(): void public function testAddingHandlers(): void { - $handler = $this->getMockForAbstractClass(HandlerInterface::class); + $handler = $this->createStub(HandlerInterface::class); $this->registry->addHandler('some_handler', $handler); self::assertSame($this->registry->getHandler('some_handler'), $handler); @@ -28,7 +28,7 @@ public function testAddingHandlers(): void public function testGettingHandlers(): void { - $handler = $this->getMockForAbstractClass(HandlerInterface::class); + $handler = $this->createStub(HandlerInterface::class); $this->registry->addHandler('some_handler', $handler); $returnedHandler = $this->registry->getHandler('some_handler'); diff --git a/tests/MetaTag/CollectorTest.php b/tests/MetaTag/CollectorTest.php index 26b7ce1..7d22f33 100644 --- a/tests/MetaTag/CollectorTest.php +++ b/tests/MetaTag/CollectorTest.php @@ -48,17 +48,9 @@ protected function setUp(): void public function testCollect(): void { - $this->config->expects(self::at(0)) + $this->config ->method('hasParameter') - ->willReturn(true); - - $this->config->expects(self::at(1)) - ->method('getParameter') - ->willReturn([]); - - $this->config->expects(self::at(2)) - ->method('hasParameter') - ->willReturn(true); + ->willReturnOnConsecutiveCalls(true, true); $handlers = [ 'article' => [ @@ -72,9 +64,9 @@ public function testCollect(): void ], ]; - $this->config->expects(self::at(3)) + $this->config ->method('getParameter') - ->willReturn($handlers); + ->willReturnOnConsecutiveCalls([], $handlers); $versionInfo = new VersionInfo( [ @@ -100,7 +92,7 @@ public function testCollect(): void 'fieldDefinitions' => [ new FieldDefinition( [ - 'id' => 'id', + 'id' => 42, 'identifier' => 'name', 'fieldTypeIdentifier' => 'eztext', ], @@ -136,18 +128,14 @@ public function testCollectWithLogicException(): void $handlers = ['all_content_types' => $handlerArray]; - $this->config->expects(self::at(0)) + $this->config ->method('hasParameter') - ->willReturn(true); + ->willReturnOnConsecutiveCalls(true, false); - $this->config->expects(self::at(1)) + $this->config ->method('getParameter') ->willReturn($handlers); - $this->config->expects(self::at(2)) - ->method('hasParameter') - ->willReturn(false); - $versionInfo = new VersionInfo( [ 'contentInfo' => new ContentInfo( @@ -172,7 +160,7 @@ public function testCollectWithLogicException(): void 'fieldDefinitions' => [ new FieldDefinition( [ - 'id' => 'id', + 'id' => 42, 'identifier' => 'name', 'fieldTypeIdentifier' => 'eztext', ], diff --git a/tests/NetgenOpenGraphBundleTest.php b/tests/NetgenOpenGraphBundleTest.php index e7c2e55..595f097 100644 --- a/tests/NetgenOpenGraphBundleTest.php +++ b/tests/NetgenOpenGraphBundleTest.php @@ -18,7 +18,7 @@ public function testItAddsCompilerPass(): void ->onlyMethods(['addCompilerPass']) ->getMock(); - $container->expects(self::at(0)) + $container->expects(self::exactly(0)) ->method('addCompilerPass') ->with(new MetaTagHandlersCompilerPass()); From 753633c1080e9d44a45b0886ef89441c8ffe1f2c Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Wed, 22 Oct 2025 08:51:45 +0200 Subject: [PATCH 06/17] NGSTACK-1000 add '.phpunit.cache' folder to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4f3f0d5..a60bd7d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ vendor composer.lock .idea build +.phpunit.cache From 81224b9af37eac763c13eb018a2b680b432b2a7b Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Wed, 22 Oct 2025 08:52:18 +0200 Subject: [PATCH 07/17] NGSTACK-1000 bump versions of PHP to 8.3 and Symfony to 7.3 in 'tests' GitHub workflow --- .github/workflows/tests.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a04383d..908027f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,15 +15,10 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.1'] - symfony: ['~5.4.0'] + php: ['8.3'] + symfony: ['~7.3.0'] phpunit: ['phpunit.xml'] deps: ['normal'] - include: - - php: '8.1' - symfony: '~5.4.0' - phpunit: 'phpunit.xml' - deps: 'low' steps: - uses: actions/checkout@v2 From 469ba37beb1c0b876bd3aea956c3c70e19de889a Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Wed, 22 Oct 2025 11:32:39 +0200 Subject: [PATCH 08/17] NGSTACK-1000 set php-cs-fixer rule to allow FQCN in PHPDocs --- .php-cs-fixer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index f6a8302..0e06cc8 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -29,6 +29,7 @@ 'single_line_comment_style' => false, 'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments', 'match', 'parameters']], 'yoda_style' => false, + 'fully_qualified_strict_types' => false, // Additional rules 'date_time_immutable' => true, From f9f2de25c384f24c93cad44caecafd815fc67c01 Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Wed, 22 Oct 2025 11:33:12 +0200 Subject: [PATCH 09/17] NGSTACK-1000 apply php-cs-fixer fixes to 'Collector' class --- bundle/MetaTag/Collector.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bundle/MetaTag/Collector.php b/bundle/MetaTag/Collector.php index ddb0f6e..73f6ca0 100644 --- a/bundle/MetaTag/Collector.php +++ b/bundle/MetaTag/Collector.php @@ -26,14 +26,14 @@ public function collect(Content $content): array { $metaTags = []; - $allHandlers = $this->configResolver->hasParameter('global_handlers', 'netgen_open_graph') ? - $this->configResolver->getParameter('global_handlers', 'netgen_open_graph') : - []; + $allHandlers = $this->configResolver->hasParameter('global_handlers', 'netgen_open_graph') + ? $this->configResolver->getParameter('global_handlers', 'netgen_open_graph') + : []; $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId); - $contentTypeHandlers = $this->configResolver->hasParameter('content_type_handlers', 'netgen_open_graph') ? - $this->configResolver->getParameter('content_type_handlers', 'netgen_open_graph') : - []; + $contentTypeHandlers = $this->configResolver->hasParameter('content_type_handlers', 'netgen_open_graph') + ? $this->configResolver->getParameter('content_type_handlers', 'netgen_open_graph') + : []; if (isset($contentTypeHandlers[$contentType->identifier])) { $allHandlers = array_merge( From 58c25d4e490a5c80335d2aa19d7594752883e5d3 Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Wed, 22 Oct 2025 11:33:45 +0200 Subject: [PATCH 10/17] NGSTACK-1000 update php-cs-fixer workflow to use docker image that uses PHP 8.3 --- .github/workflows/coding_standards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coding_standards.yml b/.github/workflows/coding_standards.yml index 4c963b9..b961cc2 100644 --- a/.github/workflows/coding_standards.yml +++ b/.github/workflows/coding_standards.yml @@ -14,6 +14,6 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: docker://oskarstark/php-cs-fixer-ga + - uses: docker://oskarstark/php-cs-fixer-ga:3.26.0 with: args: --diff --dry-run From 9825a718946d8e9069d22b9825d8f95ff8aca339 Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Thu, 23 Oct 2025 13:28:47 +0200 Subject: [PATCH 11/17] NGSTACK-1000 remove specific version of php-cs-fixer image from 'coding_standards.yml' file --- .github/workflows/coding_standards.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coding_standards.yml b/.github/workflows/coding_standards.yml index b961cc2..4c963b9 100644 --- a/.github/workflows/coding_standards.yml +++ b/.github/workflows/coding_standards.yml @@ -14,6 +14,6 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: docker://oskarstark/php-cs-fixer-ga:3.26.0 + - uses: docker://oskarstark/php-cs-fixer-ga with: args: --diff --dry-run From f99c1654415fe88901e320418efe96a09942ce9b Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Thu, 23 Oct 2025 13:29:04 +0200 Subject: [PATCH 12/17] NGSTACK-1000 apply some php-cs-fixer fixes --- bundle/MetaTag/Collector.php | 4 ++-- tests/Handler/RegistryTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bundle/MetaTag/Collector.php b/bundle/MetaTag/Collector.php index 73f6ca0..91d17d5 100644 --- a/bundle/MetaTag/Collector.php +++ b/bundle/MetaTag/Collector.php @@ -54,8 +54,8 @@ public function collect(Content $content): array foreach ($newMetaTags as $metaTag) { if (!$metaTag instanceof Item) { throw new LogicException( - '\'' . $handler['handler'] . '\' handler returned wrong value.' . - ' Expected \'Netgen\Bundle\OpenGraphBundle\MetaTag\Item\', got \'' . get_class($metaTag) . '\'.', + '\'' . $handler['handler'] . '\' handler returned wrong value.' + . ' Expected \'Netgen\Bundle\OpenGraphBundle\MetaTag\Item\', got \'' . get_class($metaTag) . '\'.', ); } diff --git a/tests/Handler/RegistryTest.php b/tests/Handler/RegistryTest.php index fa64348..0094af7 100644 --- a/tests/Handler/RegistryTest.php +++ b/tests/Handler/RegistryTest.php @@ -20,7 +20,7 @@ protected function setUp(): void public function testAddingHandlers(): void { - $handler = $this->createStub(HandlerInterface::class); + $handler = self::createStub(HandlerInterface::class); $this->registry->addHandler('some_handler', $handler); self::assertSame($this->registry->getHandler('some_handler'), $handler); @@ -28,7 +28,7 @@ public function testAddingHandlers(): void public function testGettingHandlers(): void { - $handler = $this->createStub(HandlerInterface::class); + $handler = self::createStub(HandlerInterface::class); $this->registry->addHandler('some_handler', $handler); $returnedHandler = $this->registry->getHandler('some_handler'); From 42852da7ad2734a574eb9835b9f6768fcee6d9b5 Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Fri, 24 Oct 2025 13:25:35 +0200 Subject: [PATCH 13/17] NGSTACK-1000 comment out 'mb_str_functions' key in '.php-cs-fixer.php' file in order for php-cs-fixer workflow to pass --- .php-cs-fixer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 0e06cc8..775f131 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -40,7 +40,7 @@ 'import_functions' => true, ], 'heredoc_indentation' => ['indentation' => 'same_as_start'], - 'mb_str_functions' => true, + // 'mb_str_functions' => true, 'native_constant_invocation' => true, 'nullable_type_declaration_for_default_null_value' => true, 'static_lambda' => true, From 7c644ab1bcd132212b8356b18d78af6248f71adc Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Fri, 24 Oct 2025 13:26:09 +0200 Subject: [PATCH 14/17] NGSTACK-1000 add missing 'FieldHelper' property to 'Image' class config --- bundle/Resources/config/handlers.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/bundle/Resources/config/handlers.yaml b/bundle/Resources/config/handlers.yaml index 4148c66..6098c65 100644 --- a/bundle/Resources/config/handlers.yaml +++ b/bundle/Resources/config/handlers.yaml @@ -58,6 +58,7 @@ services: class: Netgen\Bundle\OpenGraphBundle\Handler\FieldType\Image parent: netgen_open_graph.handler.field_type.abstract arguments: + - "@Ibexa\\Core\\Helper\\FieldHelper" - "@Ibexa\\Contracts\\Core\\Variation\\VariationHandler" - "@request_stack" - "@?logger" From efa576ac6ba11ff48018dd839e311cda1ae14055 Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Fri, 24 Oct 2025 13:27:01 +0200 Subject: [PATCH 15/17] NGSTACK-1000 downgrade version of PHPUnit in order for Twig Extension tests to pass --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8535b7e..c9c7193 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ }, "require-dev": { "ibexa/fieldtype-richtext": "^5.0", - "phpunit/phpunit": "^12.0", + "phpunit/phpunit": "^10.0", "matthiasnoback/symfony-config-test": "^6.0", "matthiasnoback/symfony-dependency-injection-test": "^6.0" }, From 52fc86f40b1dc321bd46558990066c7549796878 Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Fri, 24 Oct 2025 13:27:44 +0200 Subject: [PATCH 16/17] NGSTACK-1000 fix remaining tests that were failing --- tests/Handler/FieldType/ImageTest.php | 34 ++++++++++++++++++++++++++- tests/NetgenOpenGraphBundleTest.php | 2 +- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/tests/Handler/FieldType/ImageTest.php b/tests/Handler/FieldType/ImageTest.php index 89dddba..9586332 100644 --- a/tests/Handler/FieldType/ImageTest.php +++ b/tests/Handler/FieldType/ImageTest.php @@ -129,12 +129,23 @@ public function testGettingTagsWithExceptionThrownByVariationHandler(): void ->method('getField') ->willReturn($this->field); + $this->fieldHelper->expects(self::once()) + ->method('isFieldEmpty') + ->willReturn(false); + + $this->variationHandler->expects(self::once()) + ->method('getVariation') + ->willThrowException(new \Exception('Variation handler error')); + $request = Request::create('/'); $this->requestStack->expects(self::once()) ->method('getCurrentRequest') ->willReturn($request); + $this->logger->expects(self::once()) + ->method('error'); + $this->image->getMetaTags('some_tag', ['some_value', 'some_value_2', 'some_value_3']); } @@ -221,6 +232,27 @@ public function testGettingTagsWithMultipleArgumentsInArray(): void ->method('getField') ->willReturn($this->field); - $this->image->getMetaTags('some_tag', ['some_value', 'some_value_2']); + $this->fieldHelper->expects(self::once()) + ->method('isFieldEmpty') + ->willReturn(false); + + $variation = new Variation(['uri' => '/some/uri']); + + $this->variationHandler->expects(self::once()) + ->method('getVariation') + ->willReturn($variation); + + $request = Request::create('/'); + + $this->requestStack->expects(self::exactly(1)) + ->method('getCurrentRequest') + ->willReturn($request); + + $result = $this->image->getMetaTags('some_tag', ['some_value', 'some_value_2']); + + self::assertCount(1, $result); + self::assertInstanceOf('Netgen\Bundle\OpenGraphBundle\MetaTag\Item', $result[0]); + self::assertSame('some_tag', $result[0]->getTagName()); + self::assertSame('http://localhost/some/uri', $result[0]->getTagValue()); } } diff --git a/tests/NetgenOpenGraphBundleTest.php b/tests/NetgenOpenGraphBundleTest.php index 595f097..c3c2462 100644 --- a/tests/NetgenOpenGraphBundleTest.php +++ b/tests/NetgenOpenGraphBundleTest.php @@ -18,7 +18,7 @@ public function testItAddsCompilerPass(): void ->onlyMethods(['addCompilerPass']) ->getMock(); - $container->expects(self::exactly(0)) + $container->expects(self::exactly(1)) ->method('addCompilerPass') ->with(new MetaTagHandlersCompilerPass()); From c5c34d2b5c198ab3bcab05d24511b65af0ad3ee0 Mon Sep 17 00:00:00 2001 From: Ante Prkacin Date: Fri, 24 Oct 2025 15:56:38 +0200 Subject: [PATCH 17/17] Revert "NGSTACK-1000 add missing 'FieldHelper' property to 'Image' class config" This reverts commit 7c644ab1bcd132212b8356b18d78af6248f71adc. --- bundle/Resources/config/handlers.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/bundle/Resources/config/handlers.yaml b/bundle/Resources/config/handlers.yaml index 6098c65..4148c66 100644 --- a/bundle/Resources/config/handlers.yaml +++ b/bundle/Resources/config/handlers.yaml @@ -58,7 +58,6 @@ services: class: Netgen\Bundle\OpenGraphBundle\Handler\FieldType\Image parent: netgen_open_graph.handler.field_type.abstract arguments: - - "@Ibexa\\Core\\Helper\\FieldHelper" - "@Ibexa\\Contracts\\Core\\Variation\\VariationHandler" - "@request_stack" - "@?logger"