From 0f3dd703d32861ea922bacec23b242bb556c84a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Wed, 16 Sep 2020 09:11:52 +0200 Subject: [PATCH 1/3] EZP-31810: Adapted code for 6.13 requirements (#3063) --- .../AbstractPropertyWhitelistNormalizer.php | 4 +--- .../Serializer/CompoundMatcherNormalizer.php | 2 +- .../Serializer/HostElementNormalizer.php | 4 +--- .../Serializer/HostTextNormalizer.php | 4 +--- .../Component/Serializer/MapNormalizer.php | 2 -- .../Serializer/RegexHostNormalizer.php | 4 +--- .../Component/Serializer/RegexNormalizer.php | 4 +--- .../Serializer/RegexURINormalizer.php | 4 +--- .../Serializer/URIElementNormalizer.php | 4 +--- .../Component/Serializer/URITextNormalizer.php | 4 +--- .../CompoundMatcherNormalizerTest.php | 6 ++---- .../Serializer/HostElementNormalizerTest.php | 6 ++---- .../Serializer/HostTextNormalizerTest.php | 6 ++---- .../Tests/Serializer/MapNormalizerTest.php | 6 ++---- .../Serializer/RegexHostNormalizerTest.php | 6 ++---- .../Tests/Serializer/RegexNormalizerTest.php | 16 ++++------------ .../Serializer/RegexURINormalizerTest.php | 6 ++---- .../Tests/Serializer/Stubs/CompoundStub.php | 2 -- .../Tests/Serializer/Stubs/MatcherStub.php | 2 -- .../Tests/Serializer/Stubs/RegexMatcher.php | 18 ++++++++++++++++++ .../Tests/Serializer/Stubs/SerializerStub.php | 2 -- .../Serializer/URIElementNormalizerTest.php | 6 ++---- .../Tests/Serializer/URITextNormalizerTest.php | 6 ++---- .../Tests/MatcherSerializationTest.php | 6 +++--- 24 files changed, 50 insertions(+), 80 deletions(-) create mode 100644 eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/Stubs/RegexMatcher.php diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/AbstractPropertyWhitelistNormalizer.php b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/AbstractPropertyWhitelistNormalizer.php index 8f1b0eddc5..662a3e7d35 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/AbstractPropertyWhitelistNormalizer.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/AbstractPropertyWhitelistNormalizer.php @@ -4,8 +4,6 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Serializer; use Symfony\Component\Serializer\Normalizer\PropertyNormalizer; @@ -27,5 +25,5 @@ public function normalize($object, $format = null, array $context = []) /** * @return string[] */ - abstract protected function getAllowedProperties(): array; + abstract protected function getAllowedProperties(); } diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizer.php b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizer.php index 6534e322c6..a166b7d70e 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizer.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/CompoundMatcherNormalizer.php @@ -22,7 +22,7 @@ public function normalize($object, $format = null, array $context = []) return $data; } - protected function getAllowedProperties(): array + protected function getAllowedProperties() { return ['subMatchers']; } diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/HostElementNormalizer.php b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/HostElementNormalizer.php index 6a58a004e3..cad22286b6 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/HostElementNormalizer.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/HostElementNormalizer.php @@ -4,8 +4,6 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Serializer; use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostElement; @@ -20,7 +18,7 @@ public function supportsNormalization($data, $format = null) /** * @see \eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostElement::__sleep */ - protected function getAllowedProperties(): array + protected function getAllowedProperties() { return ['elementNumber', 'hostElements']; } diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/HostTextNormalizer.php b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/HostTextNormalizer.php index 18450f0189..be75abdb06 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/HostTextNormalizer.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/HostTextNormalizer.php @@ -4,15 +4,13 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Serializer; use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostText; final class HostTextNormalizer extends AbstractPropertyWhitelistNormalizer { - protected function getAllowedProperties(): array + protected function getAllowedProperties() { return ['siteAccessesConfiguration']; } diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/MapNormalizer.php b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/MapNormalizer.php index f70499174e..4c3fa5315b 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/MapNormalizer.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/MapNormalizer.php @@ -4,8 +4,6 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Serializer; use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map; diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/RegexHostNormalizer.php b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/RegexHostNormalizer.php index b1f718199c..6255ddf536 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/RegexHostNormalizer.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/RegexHostNormalizer.php @@ -4,15 +4,13 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Serializer; use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\Host; final class RegexHostNormalizer extends AbstractPropertyWhitelistNormalizer { - protected function getAllowedProperties(): array + protected function getAllowedProperties() { return ['siteAccessesConfiguration']; } diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/RegexNormalizer.php b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/RegexNormalizer.php index c4532ba8b0..ad26856e59 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/RegexNormalizer.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/RegexNormalizer.php @@ -4,8 +4,6 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Serializer; use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex; @@ -20,7 +18,7 @@ public function supportsNormalization($data, $format = null) /** * @see \eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex::__sleep */ - protected function getAllowedProperties(): array + protected function getAllowedProperties() { return ['regex', 'itemNumber', 'matchedSiteAccess']; } diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/RegexURINormalizer.php b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/RegexURINormalizer.php index f14c0b9fe0..dd2624b181 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/RegexURINormalizer.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/RegexURINormalizer.php @@ -4,15 +4,13 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Serializer; use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\URI; final class RegexURINormalizer extends AbstractPropertyWhitelistNormalizer { - protected function getAllowedProperties(): array + protected function getAllowedProperties() { return ['siteAccessesConfiguration']; } diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/URIElementNormalizer.php b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/URIElementNormalizer.php index 794455517c..1ad99e572f 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/URIElementNormalizer.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/URIElementNormalizer.php @@ -4,8 +4,6 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Serializer; use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIElement; @@ -20,7 +18,7 @@ public function supportsNormalization($data, $format = null) /** * @see \eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIElement::__sleep */ - protected function getAllowedProperties(): array + protected function getAllowedProperties() { return ['elementNumber', 'uriElements']; } diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/URITextNormalizer.php b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/URITextNormalizer.php index 650153a50a..bf5eec6e9a 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Serializer/URITextNormalizer.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Serializer/URITextNormalizer.php @@ -4,15 +4,13 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Serializer; use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIText; final class URITextNormalizer extends AbstractPropertyWhitelistNormalizer { - protected function getAllowedProperties(): array + protected function getAllowedProperties() { return ['siteAccessesConfiguration']; } diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/CompoundMatcherNormalizerTest.php b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/CompoundMatcherNormalizerTest.php index b77380f684..1559223f3c 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/CompoundMatcherNormalizerTest.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/CompoundMatcherNormalizerTest.php @@ -4,8 +4,6 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer; use eZ\Publish\Core\MVC\Symfony\Component\Serializer\CompoundMatcherNormalizer; @@ -18,7 +16,7 @@ final class CompoundMatcherNormalizerTest extends TestCase { - public function testNormalization(): void + public function testNormalization() { $matcher = new CompoundStub([]); $matcher->setSubMatchers([ @@ -44,7 +42,7 @@ public function testNormalization(): void ); } - public function testSupportsNormalization(): void + public function testSupportsNormalization() { $normalizer = new CompoundMatcherNormalizer(); diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/HostElementNormalizerTest.php b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/HostElementNormalizerTest.php index 1f5d02ecfb..e03fc5547a 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/HostElementNormalizerTest.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/HostElementNormalizerTest.php @@ -4,8 +4,6 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer; use eZ\Publish\Core\MVC\Symfony\Component\Serializer\HostElementNormalizer; @@ -17,7 +15,7 @@ final class HostElementNormalizerTest extends TestCase { - public function testNormalization(): void + public function testNormalization() { $normalizer = new HostElementNormalizer(); $normalizer->setSerializer(new SerializerStub()); @@ -39,7 +37,7 @@ public function testNormalization(): void ); } - public function testSupportsNormalization(): void + public function testSupportsNormalization() { $normalizer = new HostElementNormalizer(); diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/HostTextNormalizerTest.php b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/HostTextNormalizerTest.php index 83340e3b9b..adeaf3b102 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/HostTextNormalizerTest.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/HostTextNormalizerTest.php @@ -4,8 +4,6 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer; use eZ\Publish\Core\MVC\Symfony\Component\Serializer\HostTextNormalizer; @@ -16,7 +14,7 @@ final class HostTextNormalizerTest extends TestCase { - public function testNormalize(): void + public function testNormalize() { $normalizer = new HostTextNormalizer(); $normalizer->setSerializer(new SerializerStub()); @@ -37,7 +35,7 @@ public function testNormalize(): void ); } - public function testSupportsNormalization(): void + public function testSupportsNormalization() { $normalizer = new HostTextNormalizer(); diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/MapNormalizerTest.php b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/MapNormalizerTest.php index d1c4c44887..fc779ea437 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/MapNormalizerTest.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/MapNormalizerTest.php @@ -4,8 +4,6 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer; use eZ\Publish\Core\MVC\Symfony\Component\Serializer\MapNormalizer; @@ -15,7 +13,7 @@ final class MapNormalizerTest extends TestCase { - public function testNormalization(): void + public function testNormalization() { $normalizer = new MapNormalizer(); @@ -32,7 +30,7 @@ public function testNormalization(): void ); } - public function testSupportsNormalization(): void + public function testSupportsNormalization() { $normalizer = new MapNormalizer(); diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/RegexHostNormalizerTest.php b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/RegexHostNormalizerTest.php index 9c4d10dced..02e11b70ff 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/RegexHostNormalizerTest.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/RegexHostNormalizerTest.php @@ -4,8 +4,6 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer; use eZ\Publish\Core\MVC\Symfony\Component\Serializer\RegexHostNormalizer; @@ -16,7 +14,7 @@ final class RegexHostNormalizerTest extends TestCase { - public function testNormalize(): void + public function testNormalize() { $normalizer = new RegexHostNormalizer(); $normalizer->setSerializer(new SerializerStub()); @@ -37,7 +35,7 @@ public function testNormalize(): void ); } - public function testSupportsNormalization(): void + public function testSupportsNormalization() { $normalizer = new RegexHostNormalizer(); diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/RegexNormalizerTest.php b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/RegexNormalizerTest.php index dd8efcbe30..39cc823dd2 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/RegexNormalizerTest.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/RegexNormalizerTest.php @@ -4,28 +4,20 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer; -use eZ\Publish\API\Repository\Exceptions\NotImplementedException; use eZ\Publish\Core\MVC\Symfony\Component\Serializer\RegexNormalizer; use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher; use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex as RegexMatcher; +use eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer\Stubs\RegexMatcher as RegexMatcherStub; use PHPUnit\Framework\TestCase; final class RegexNormalizerTest extends TestCase { - public function testNormalize(): void + public function testNormalize() { $normalizer = new RegexNormalizer(); - - $matcher = new class('/^Foo(.*)/(.*)/', 2) extends RegexMatcher { - public function getName() - { - throw new NotImplementedException(__METHOD__); - } - }; + $matcher = new RegexMatcherStub('/^Foo(.*)/(.*)/', 2); $this->assertEquals( [ @@ -37,7 +29,7 @@ public function getName() ); } - public function testSupportsNormalization(): void + public function testSupportsNormalization() { $normalizer = new RegexNormalizer(); diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/RegexURINormalizerTest.php b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/RegexURINormalizerTest.php index b6b5b9741b..bcf824de42 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/RegexURINormalizerTest.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/RegexURINormalizerTest.php @@ -4,8 +4,6 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer; use eZ\Publish\Core\MVC\Symfony\Component\Serializer\RegexURINormalizer; @@ -16,7 +14,7 @@ final class RegexURINormalizerTest extends TestCase { - public function testNormalize(): void + public function testNormalize() { $normalizer = new RegexURINormalizer(); $normalizer->setSerializer(new SerializerStub()); @@ -37,7 +35,7 @@ public function testNormalize(): void ); } - public function testSupportsNormalization(): void + public function testSupportsNormalization() { $normalizer = new RegexURINormalizer(); diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/Stubs/CompoundStub.php b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/Stubs/CompoundStub.php index d2d8677dd8..e788a94780 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/Stubs/CompoundStub.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/Stubs/CompoundStub.php @@ -4,8 +4,6 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer\Stubs; use eZ\Publish\API\Repository\Exceptions\NotImplementedException; diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/Stubs/MatcherStub.php b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/Stubs/MatcherStub.php index 9f47b86368..d681c7a7fa 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/Stubs/MatcherStub.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/Stubs/MatcherStub.php @@ -4,8 +4,6 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer\Stubs; use eZ\Publish\API\Repository\Exceptions\NotImplementedException; diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/Stubs/RegexMatcher.php b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/Stubs/RegexMatcher.php new file mode 100644 index 0000000000..bdc1dd8ff6 --- /dev/null +++ b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/Stubs/RegexMatcher.php @@ -0,0 +1,18 @@ +setSerializer(new SerializerStub()); @@ -36,7 +34,7 @@ public function testNormalization(): void ); } - public function testSupportsNormalization(): void + public function testSupportsNormalization() { $normalizer = new URIElementNormalizer(); diff --git a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/URITextNormalizerTest.php b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/URITextNormalizerTest.php index acc9c35753..3a1a5980a7 100644 --- a/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/URITextNormalizerTest.php +++ b/eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/URITextNormalizerTest.php @@ -4,8 +4,6 @@ * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -declare(strict_types=1); - namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer; use eZ\Publish\Core\MVC\Symfony\Component\Serializer\URITextNormalizer; @@ -16,7 +14,7 @@ final class URITextNormalizerTest extends TestCase { - public function testNormalize(): void + public function testNormalize() { $normalizer = new URITextNormalizer(); $normalizer->setSerializer(new SerializerStub()); @@ -37,7 +35,7 @@ public function testNormalize(): void ); } - public function testSupportsNormalization(): void + public function testSupportsNormalization() { $normalizer = new URITextNormalizer(); diff --git a/eZ/Publish/Core/MVC/Symfony/SiteAccess/Tests/MatcherSerializationTest.php b/eZ/Publish/Core/MVC/Symfony/SiteAccess/Tests/MatcherSerializationTest.php index 2e3cc0b877..38ae1f3246 100644 --- a/eZ/Publish/Core/MVC/Symfony/SiteAccess/Tests/MatcherSerializationTest.php +++ b/eZ/Publish/Core/MVC/Symfony/SiteAccess/Tests/MatcherSerializationTest.php @@ -138,7 +138,7 @@ public function matcherProvider() ]; } - private function getMapPortMatcherTestCase(): array + private function getMapPortMatcherTestCase() { $matcherBeforeSerialization = new Matcher\Map\Port(['map' => ['key' => 'value']]); $matcherBeforeSerialization->setMapKey('map'); @@ -149,7 +149,7 @@ private function getMapPortMatcherTestCase(): array return [$matcherBeforeSerialization, $matcherAfterDeserialization]; } - private function getMapHostMatcherTestCase(): array + private function getMapHostMatcherTestCase() { $matcherBeforeSerialization = new Matcher\Map\Host(['map' => ['key' => 'value']]); $matcherBeforeSerialization->setMapKey('map'); @@ -160,7 +160,7 @@ private function getMapHostMatcherTestCase(): array return [$matcherBeforeSerialization, $matcherAfterDeserialization]; } - private function getMapURIMatcherTestCase(): array + private function getMapURIMatcherTestCase() { $matcherBeforeSerialization = new Matcher\Map\URI(['map' => ['key' => 'value']]); $matcherBeforeSerialization->setMapKey('map'); From daa76b8d962a7b1a7e43e99d79596e9071ce0387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Wed, 16 Sep 2020 13:08:23 +0200 Subject: [PATCH 2/3] Fixed comparator function in LocationServiceTest::testLoadLocationsContent (#3064) --- .../API/Repository/Tests/LocationServiceTest.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/eZ/Publish/API/Repository/Tests/LocationServiceTest.php b/eZ/Publish/API/Repository/Tests/LocationServiceTest.php index 8969f63d0d..a1de933636 100644 --- a/eZ/Publish/API/Repository/Tests/LocationServiceTest.php +++ b/eZ/Publish/API/Repository/Tests/LocationServiceTest.php @@ -531,28 +531,22 @@ public function testLoadLocations() */ public function testLoadLocationsContent(array $locations) { - $repository = $this->getRepository(); - $locationService = $repository->getLocationService(); - $this->assertEquals(1, count($locations)); foreach ($locations as $loadedLocation) { - $this->assertInstanceOf( - '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Location', - $loadedLocation - ); + self::assertInstanceOf(Location::class, $loadedLocation); } usort( $locations, - function ($a, $b) { - strcmp($a->id, $b->id); + static function ($a, $b) { + return strcmp($a->id, $b->id); } ); $this->assertEquals( [$this->generateId('location', 5)], array_map( - function (Location $location) { + static function (Location $location) { return $location->id; }, $locations From 42fee313e0d30cce0e6a300c2b96717f94cf00d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petar=20=C5=A0panja?= Date: Mon, 5 Oct 2020 13:56:25 +0200 Subject: [PATCH 3/3] EZP-31837: Creating an additional Content Location does not repect Content visibility (#3066) --- .../Repository/Tests/LocationServiceTest.php | 41 +++++++++++++++++++ .../Repository/Values/Content/Location.php | 6 +-- eZ/Publish/Core/Repository/ContentService.php | 3 +- .../Core/Repository/Helper/DomainMapper.php | 8 ++-- .../Core/Repository/LocationService.php | 3 +- .../Tests/Service/Mock/ContentTest.php | 9 ++-- 6 files changed, 59 insertions(+), 11 deletions(-) diff --git a/eZ/Publish/API/Repository/Tests/LocationServiceTest.php b/eZ/Publish/API/Repository/Tests/LocationServiceTest.php index 203080673b..d595bbff99 100644 --- a/eZ/Publish/API/Repository/Tests/LocationServiceTest.php +++ b/eZ/Publish/API/Repository/Tests/LocationServiceTest.php @@ -130,6 +130,47 @@ public function testCreateLocation() ]; } + /** + * Test for the createLocation() method. + * + * @covers \eZ\Publish\API\Repository\LocationService::createLocation + * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCreateLocation + * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testHideContent + */ + public function testCreateLocationChecksContentVisibility(): void + { + $repository = $this->getRepository(); + + $contentId = $this->generateId('object', 41); + $parentLocationId = $this->generateId('location', 5); + /* BEGIN: Use Case */ + // $contentId is the ID of an existing content object + // $parentLocationId is the ID of an existing location + $contentService = $repository->getContentService(); + $locationService = $repository->getLocationService(); + + // ContentInfo for "How to use eZ Publish" + $contentInfo = $contentService->loadContentInfo($contentId); + $contentService->hideContent($contentInfo); + + $locationCreate = $locationService->newLocationCreateStruct($parentLocationId); + $locationCreate->priority = 23; + $locationCreate->hidden = false; + $locationCreate->remoteId = 'sindelfingen'; + $locationCreate->sortField = Location::SORT_FIELD_NODE_ID; + $locationCreate->sortOrder = Location::SORT_ORDER_DESC; + + $location = $locationService->createLocation( + $contentInfo, + $locationCreate + ); + /* END: Use Case */ + + self::assertInstanceOf(Location::class, $location); + + self::assertTrue($location->invisible); + } + /** * Test for the createLocation() method with utilizing default ContentType sorting options. * diff --git a/eZ/Publish/API/Repository/Values/Content/Location.php b/eZ/Publish/API/Repository/Values/Content/Location.php index cc263fa239..9c2d19fffe 100644 --- a/eZ/Publish/API/Repository/Values/Content/Location.php +++ b/eZ/Publish/API/Repository/Values/Content/Location.php @@ -18,7 +18,7 @@ * @property-read mixed $id the id of the location * @property-read int $priority Position of the Location among its siblings when sorted using priority * @property-read bool $hidden Indicates that the Location entity is hidden (explicitly or hidden by content). - * @property-read bool $invisible Indicates that the Location is implicitly marked as hidden by a parent location + * @property-read bool $invisible Indicates that the Location is not visible, being either marked as hidden itself, or implicitly hidden by its Content or an ancestor Location * @property-read bool $explicitlyHidden Indicates that the Location entity has been explicitly marked as hidden. * @property-read string $remoteId a global unique id of the content object * @property-read mixed $parentLocationId the id of the parent location @@ -119,8 +119,8 @@ abstract class Location extends ValueObject protected $hidden; /** - * Indicates that the Location is implicitly marked as hidden by a parent - * location. + * Indicates that the Location is not visible, being either marked as hidden itself, + * or implicitly hidden by its Content or an ancestor Location. * * @var bool */ diff --git a/eZ/Publish/Core/Repository/ContentService.php b/eZ/Publish/Core/Repository/ContentService.php index ba9bfceff6..56beb95b6b 100644 --- a/eZ/Publish/Core/Repository/ContentService.php +++ b/eZ/Publish/Core/Repository/ContentService.php @@ -879,7 +879,8 @@ protected function buildSPILocationCreateStructs(array $locationCreateStructs) $mainLocation, // For Content draft contentId and contentVersionNo are set in ContentHandler upon draft creation null, - null + null, + false ); // First Location in the list will be created as main Location diff --git a/eZ/Publish/Core/Repository/Helper/DomainMapper.php b/eZ/Publish/Core/Repository/Helper/DomainMapper.php index e3bcb67545..2e2be4e1d9 100644 --- a/eZ/Publish/Core/Repository/Helper/DomainMapper.php +++ b/eZ/Publish/Core/Repository/Helper/DomainMapper.php @@ -683,6 +683,7 @@ public function buildLocationDomainObjectsOnSearchResult(SearchResult $result, a * @param mixed $mainLocation * @param mixed $contentId * @param mixed $contentVersionNo + * @param bool $isContentHidden * * @return \eZ\Publish\SPI\Persistence\Content\Location\CreateStruct */ @@ -691,7 +692,8 @@ public function buildSPILocationCreateStruct( APILocation $parentLocation, $mainLocation, $contentId, - $contentVersionNo + $contentVersionNo, + bool $isContentHidden ) { if (!$this->isValidLocationPriority($locationCreateStruct->priority)) { throw new InvalidArgumentValue('priority', $locationCreateStruct->priority, 'LocationCreateStruct'); @@ -733,10 +735,10 @@ public function buildSPILocationCreateStruct( 'priority' => $locationCreateStruct->priority, 'hidden' => $locationCreateStruct->hidden, // If we declare the new Location as hidden, it is automatically invisible - // Otherwise it picks up visibility from parent Location + // Otherwise it picks up visibility from parent Location and Content // Note: There is no need to check for hidden status of parent, as hidden Location // is always invisible as well - 'invisible' => ($locationCreateStruct->hidden === true || $parentLocation->invisible), + 'invisible' => ($locationCreateStruct->hidden === true || $parentLocation->invisible || $isContentHidden), 'remoteId' => $remoteId, 'contentId' => $contentId, 'contentVersion' => $contentVersionNo, diff --git a/eZ/Publish/Core/Repository/LocationService.php b/eZ/Publish/Core/Repository/LocationService.php index 88386a932c..7d2375ae13 100644 --- a/eZ/Publish/Core/Repository/LocationService.php +++ b/eZ/Publish/Core/Repository/LocationService.php @@ -468,7 +468,8 @@ public function createLocation(ContentInfo $contentInfo, LocationCreateStruct $l $parentLocation, $contentInfo->mainLocationId ?? true, $contentInfo->id, - $contentInfo->currentVersionNo + $contentInfo->currentVersionNo, + $contentInfo->isHidden ); $this->repository->beginTransaction(); diff --git a/eZ/Publish/Core/Repository/Tests/Service/Mock/ContentTest.php b/eZ/Publish/Core/Repository/Tests/Service/Mock/ContentTest.php index e1e675e2ef..b0d3b2bcd6 100644 --- a/eZ/Publish/Core/Repository/Tests/Service/Mock/ContentTest.php +++ b/eZ/Publish/Core/Repository/Tests/Service/Mock/ContentTest.php @@ -2510,7 +2510,8 @@ public function testCreateContentWithLocations() $this->equalTo($parentLocation), $this->equalTo(true), $this->equalTo(null), - $this->equalTo(null) + $this->equalTo(null), + $this->equalTo(false) )->will($this->returnValue($spiLocationCreateStruct)); $domainMapperMock->expects($this->at(2)) @@ -2520,7 +2521,8 @@ public function testCreateContentWithLocations() $this->equalTo($parentLocation), $this->equalTo(false), $this->equalTo(null), - $this->equalTo(null) + $this->equalTo(null), + $this->equalTo(false) )->will($this->returnValue($spiLocationCreateStruct)); $spiContentCreateStruct = new SPIContentCreateStruct( @@ -2689,7 +2691,8 @@ function ($object) use ($that, $contentCreateStruct) { $this->equalTo($parentLocation), $this->equalTo(true), $this->equalTo(null), - $this->equalTo(null) + $this->equalTo(null), + $this->equalTo(false) )->will($this->returnValue($spiLocationCreateStruct)); $mockedService->createContent(