diff --git a/Content/Application/Message/CreateContentMessage.php b/Content/Application/Message/CreateContentMessage.php index 9d232632..ed18440d 100644 --- a/Content/Application/Message/CreateContentMessage.php +++ b/Content/Application/Message/CreateContentMessage.php @@ -28,13 +28,13 @@ class CreateContentMessage private $data; /** - * @var array + * @var mixed[] */ private $dimensionAttributes; /** * @param mixed[] $data - * @param array $dimensionAttributes + * @param mixed[] $dimensionAttributes */ public function __construct(ContentInterface $content, array $data, array $dimensionAttributes) { @@ -57,7 +57,7 @@ public function getData(): array } /** - * @return array + * @return mixed[] */ public function getDimensionAttributes(): array { diff --git a/Content/Application/Message/LoadContentMessage.php b/Content/Application/Message/LoadContentMessage.php index 5bbeeaa9..495c27c2 100644 --- a/Content/Application/Message/LoadContentMessage.php +++ b/Content/Application/Message/LoadContentMessage.php @@ -23,12 +23,12 @@ class LoadContentMessage private $content; /** - * @var array + * @var mixed[] */ private $dimensionAttributes; /** - * @param array $dimensionAttributes + * @param mixed[] $dimensionAttributes */ public function __construct(ContentInterface $content, array $dimensionAttributes) { @@ -42,7 +42,7 @@ public function getContent(): ContentInterface } /** - * @return array + * @return mixed[] */ public function getDimensionAttributes(): array { diff --git a/Content/Application/Message/ModifyContentMessage.php b/Content/Application/Message/ModifyContentMessage.php index f1467cd1..222238c9 100644 --- a/Content/Application/Message/ModifyContentMessage.php +++ b/Content/Application/Message/ModifyContentMessage.php @@ -28,13 +28,13 @@ class ModifyContentMessage private $data; /** - * @var array + * @var mixed[] */ private $dimensionAttributes; /** * @param mixed[] $data - * @param array $dimensionAttributes + * @param mixed[] $dimensionAttributes */ public function __construct(ContentInterface $content, array $data, array $dimensionAttributes) { @@ -57,7 +57,7 @@ public function getData(): array } /** - * @return array + * @return mixed[] */ public function getDimensionAttributes(): array { diff --git a/Content/Domain/Model/ExcerptInterface.php b/Content/Domain/Model/ExcerptInterface.php index b010d965..6f404983 100644 --- a/Content/Domain/Model/ExcerptInterface.php +++ b/Content/Domain/Model/ExcerptInterface.php @@ -61,22 +61,22 @@ public function getExcerptTagNames(): array; public function setExcerptTags(array $excerptTags): void; /** - * @return array|null + * @return mixed[]|null */ public function getExcerptImage(): ?array; /** - * @param array|null $excerptImage + * @param mixed[]|null $excerptImage */ public function setExcerptImage(?array $excerptImage): void; /** - * @return array|null + * @return mixed[]|null */ public function getExcerptIcon(): ?array; /** - * @param array|null $excerptIcon + * @param mixed[]|null $excerptIcon */ public function setExcerptIcon(?array $excerptIcon): void; } diff --git a/Content/Domain/Model/ExcerptTrait.php b/Content/Domain/Model/ExcerptTrait.php index f4fbecd9..d229f03c 100644 --- a/Content/Domain/Model/ExcerptTrait.php +++ b/Content/Domain/Model/ExcerptTrait.php @@ -159,7 +159,7 @@ public function setExcerptTags(array $excerptTags): void } /** - * @return array{id: int}|null + * @return mixed[]|null */ public function getExcerptImage(): ?array { @@ -173,7 +173,7 @@ public function getExcerptImage(): ?array } /** - * @param array{id: int}|null $excerptImage + * @param mixed[]|null $excerptImage */ public function setExcerptImage(?array $excerptImage): void { @@ -181,7 +181,7 @@ public function setExcerptImage(?array $excerptImage): void } /** - * @return array{id: int}|null + * @return mixed[]|null */ public function getExcerptIcon(): ?array { @@ -195,7 +195,7 @@ public function getExcerptIcon(): ?array } /** - * @param array{id: int}|null $excerptIcon + * @param mixed[]|null $excerptIcon */ public function setExcerptIcon(?array $excerptIcon): void { diff --git a/Dimension/Domain/Factory/DimensionCollectionFactory.php b/Dimension/Domain/Factory/DimensionCollectionFactory.php index 00b8fae1..8b1cf5fc 100644 --- a/Dimension/Domain/Factory/DimensionCollectionFactory.php +++ b/Dimension/Domain/Factory/DimensionCollectionFactory.php @@ -32,7 +32,7 @@ public function __construct(DimensionRepositoryInterface $dimensionRepository) } /** - * @param array $dimensionAttributes + * @param mixed[] $dimensionAttributes */ public function create(array $dimensionAttributes): DimensionCollectionInterface { diff --git a/Dimension/Domain/Factory/DimensionCollectionFactoryInterface.php b/Dimension/Domain/Factory/DimensionCollectionFactoryInterface.php index 13d4050e..a7a81c1b 100644 --- a/Dimension/Domain/Factory/DimensionCollectionFactoryInterface.php +++ b/Dimension/Domain/Factory/DimensionCollectionFactoryInterface.php @@ -18,7 +18,7 @@ interface DimensionCollectionFactoryInterface { /** - * @param array $dimensionAttributes + * @param mixed[] $dimensionAttributes */ public function create(array $dimensionAttributes): DimensionCollectionInterface; } diff --git a/Dimension/Domain/Model/DimensionCollection.php b/Dimension/Domain/Model/DimensionCollection.php index 510b9dc3..3e85125f 100644 --- a/Dimension/Domain/Model/DimensionCollection.php +++ b/Dimension/Domain/Model/DimensionCollection.php @@ -19,17 +19,17 @@ class DimensionCollection implements \IteratorAggregate, DimensionCollectionInterface { /** - * @var array + * @var mixed[] */ private $attributes; /** - * @var array|null + * @var mixed[]|null */ private $localizedAttributes; /** - * @var array + * @var mixed[] */ private $unlocalizedAttributes; @@ -49,7 +49,7 @@ class DimensionCollection implements \IteratorAggregate, DimensionCollectionInte private $unlocalizedDimension; /** - * @param array $attributes + * @param mixed[] $attributes * @param DimensionInterface[] $dimensions */ public function __construct(array $attributes, array $dimensions) @@ -67,7 +67,7 @@ public function __construct(array $attributes, array $dimensions) $criteria = Criteria::create(); foreach ($this->unlocalizedAttributes as $key => $value) { - $criteria->andWhere($criteria->expr()->eq($key, $value)); + $criteria->andWhere($criteria->expr()->eq((string) $key, $value)); } $this->unlocalizedDimension = $this->dimensions->matching($criteria)->first() ?: null; @@ -75,14 +75,14 @@ public function __construct(array $attributes, array $dimensions) if ($this->localizedAttributes) { $criteria = Criteria::create(); foreach ($this->localizedAttributes as $key => $value) { - $criteria->andWhere($criteria->expr()->eq($key, $value)); + $criteria->andWhere($criteria->expr()->eq((string) $key, $value)); } $this->localizedDimension = $this->dimensions->matching($criteria)->first() ?: null; } } /** - * @return array + * @return mixed[] */ public function getAttributes(): array { @@ -90,7 +90,7 @@ public function getAttributes(): array } /** - * @return array + * @return mixed[] */ public function getUnlocalizedAttributes(): array { @@ -98,7 +98,7 @@ public function getUnlocalizedAttributes(): array } /** - * @return array + * @return mixed[] */ public function getLocalizedAttributes(): ?array { diff --git a/Dimension/Domain/Model/DimensionCollectionInterface.php b/Dimension/Domain/Model/DimensionCollectionInterface.php index 90965dbb..ff4a247a 100644 --- a/Dimension/Domain/Model/DimensionCollectionInterface.php +++ b/Dimension/Domain/Model/DimensionCollectionInterface.php @@ -19,17 +19,17 @@ interface DimensionCollectionInterface extends \Traversable, \Countable { /** - * @return array|null + * @return mixed[]|null */ public function getLocalizedAttributes(): ?array; /** - * @return array + * @return mixed[] */ public function getUnlocalizedAttributes(): array; /** - * @return array + * @return mixed[] */ public function getAttributes(): array; diff --git a/Dimension/Domain/Model/DimensionInterface.php b/Dimension/Domain/Model/DimensionInterface.php index a11a0369..0b4e422d 100644 --- a/Dimension/Domain/Model/DimensionInterface.php +++ b/Dimension/Domain/Model/DimensionInterface.php @@ -25,7 +25,7 @@ public function getLocale(): ?string; public function getWorkflowStage(): string; /** - * @return array + * @return mixed[] */ public function getAttributes(): array; diff --git a/Dimension/Domain/Repository/DimensionRepositoryInterface.php b/Dimension/Domain/Repository/DimensionRepositoryInterface.php index 3981f0b4..ffe9127e 100644 --- a/Dimension/Domain/Repository/DimensionRepositoryInterface.php +++ b/Dimension/Domain/Repository/DimensionRepositoryInterface.php @@ -19,7 +19,7 @@ interface DimensionRepositoryInterface { /** - * @param array $attributes + * @param mixed[] $attributes */ public function create( ?string $id = null, @@ -31,7 +31,7 @@ public function add(DimensionInterface $directory): void; public function remove(DimensionInterface $directory): void; /** - * @param array $attributes + * @param mixed[] $attributes */ public function findByAttributes(array $attributes): DimensionCollectionInterface; diff --git a/Dimension/Infrastructure/Doctrine/DimensionRepository.php b/Dimension/Infrastructure/Doctrine/DimensionRepository.php index 2beb052c..abe1fef0 100644 --- a/Dimension/Infrastructure/Doctrine/DimensionRepository.php +++ b/Dimension/Infrastructure/Doctrine/DimensionRepository.php @@ -26,7 +26,7 @@ class DimensionRepository implements DimensionRepositoryInterface { /** - * @var class-string + * @var string */ private $className; @@ -98,9 +98,9 @@ public function findBy(array $criteria): iterable /** * Less specific should be returned first to merge correctly. * - * @param array $attributes + * @param mixed[] $attributes */ - private function addSortBy(QueryBuilder $queryBuilder, $attributes): void + private function addSortBy(QueryBuilder $queryBuilder, array $attributes): void { foreach ($attributes as $key => $value) { $queryBuilder->addOrderBy('dimension.' . $key); @@ -108,7 +108,7 @@ private function addSortBy(QueryBuilder $queryBuilder, $attributes): void } /** - * @param array $attributes + * @param mixed[] $attributes */ private function getAttributesCriteria(string $dimensionAlias, array $attributes): Criteria { @@ -130,9 +130,9 @@ private function getAttributesCriteria(string $dimensionAlias, array $attributes } /** - * @param array $attributes + * @param mixed[] $attributes * - * @return array + * @return mixed[] */ private function getNormalizedAttributes(array $attributes): array { diff --git a/TestCases/Content/ExcerptTestCaseTrait.php b/TestCases/Content/ExcerptTestCaseTrait.php index bd32208d..fb1a8843 100644 --- a/TestCases/Content/ExcerptTestCaseTrait.php +++ b/TestCases/Content/ExcerptTestCaseTrait.php @@ -55,6 +55,7 @@ public function testGetSetExcerptImageId(): void $model = $this->getExcerptInstance(); $this->assertNull($model->getExcerptImage()); $model->setExcerptImage(['id' => 1]); + $this->assertNotNull($model->getExcerptImage()); $this->assertSame(['id' => 1], $model->getExcerptImage()); } @@ -63,6 +64,7 @@ public function testGetSetExcerptIconId(): void $model = $this->getExcerptInstance(); $this->assertNull($model->getExcerptIcon()); $model->setExcerptIcon(['id' => 2]); + $this->assertNotNull($model->getExcerptIcon()); $this->assertSame(['id' => 2], $model->getExcerptIcon()); } diff --git a/Tests/Functional/Content/Infrastructure/CategoryFactoryTest.php b/Tests/Functional/Content/Infrastructure/Doctrine/CategoryFactoryTest.php similarity index 85% rename from Tests/Functional/Content/Infrastructure/CategoryFactoryTest.php rename to Tests/Functional/Content/Infrastructure/Doctrine/CategoryFactoryTest.php index 4da9df27..ac8dffc6 100644 --- a/Tests/Functional/Content/Infrastructure/CategoryFactoryTest.php +++ b/Tests/Functional/Content/Infrastructure/Doctrine/CategoryFactoryTest.php @@ -11,7 +11,7 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\ContentBundle\Tests\Content\Infrastructure\Doctrine; +namespace Sulu\Bundle\ContentBundle\Tests\Functional\Content\Infrastructure\Doctrine; use Sulu\Bundle\CategoryBundle\Entity\CategoryInterface; use Sulu\Bundle\ContentBundle\Content\Domain\Factory\CategoryFactoryInterface; @@ -32,8 +32,10 @@ public function createCategoryFactory(): CategoryFactoryInterface /** * @dataProvider dataProvider + * + * @param int[] $categoryIds */ - public function testCreate($categoryIds): void + public function testCreate(array $categoryIds): void { $categoryFactory = $this->createCategoryFactory(); @@ -48,7 +50,7 @@ function (CategoryInterface $category) { ); } - public function dataProvider() + public function dataProvider(): \Generator { yield [ [ diff --git a/Tests/Functional/Content/Infrastructure/TagFactoryTest.php b/Tests/Functional/Content/Infrastructure/Doctrine/TagFactoryTest.php similarity index 87% rename from Tests/Functional/Content/Infrastructure/TagFactoryTest.php rename to Tests/Functional/Content/Infrastructure/Doctrine/TagFactoryTest.php index 8ef6e459..4b2fbab7 100644 --- a/Tests/Functional/Content/Infrastructure/TagFactoryTest.php +++ b/Tests/Functional/Content/Infrastructure/Doctrine/TagFactoryTest.php @@ -11,7 +11,7 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\ContentBundle\Tests\Content\Infrastructure\Doctrine; +namespace Sulu\Bundle\ContentBundle\Tests\Functional\Content\Infrastructure\Doctrine; use Sulu\Bundle\ContentBundle\Content\Domain\Factory\TagFactoryInterface; use Sulu\Bundle\ContentBundle\Tests\Functional\BaseTestCase; @@ -26,6 +26,9 @@ public function setUp(): void self::purgeDatabase(); } + /** + * @param string[] $existTagNames + */ protected function createTagFactory(array $existTagNames = []): TagFactoryInterface { /** @var TagRepositoryInterface $tagRepository */ @@ -47,8 +50,11 @@ protected function createTagFactory(array $existTagNames = []): TagFactoryInterf /** * @dataProvider dataProvider + * + * @param string[] $tagNames + * @param string[] $existTags */ - public function testCreate($tagNames, $existTags): void + public function testCreate(array $tagNames, array $existTags): void { $tagFactory = $this->createTagFactory($existTags); @@ -63,7 +69,7 @@ function (TagInterface $tag) { ); } - public function dataProvider() + public function dataProvider(): \Generator { yield [ [ diff --git a/Tests/Unit/Content/Application/ContentDimensionFactory/ContentDimensionCollectionFactoryTest.php b/Tests/Unit/Content/Application/ContentDimensionFactory/ContentDimensionCollectionFactoryTest.php index 78a865c1..15eb9e10 100644 --- a/Tests/Unit/Content/Application/ContentDimensionFactory/ContentDimensionCollectionFactoryTest.php +++ b/Tests/Unit/Content/Application/ContentDimensionFactory/ContentDimensionCollectionFactoryTest.php @@ -11,7 +11,7 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\ContentDimensionCollection; +namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\ContentDimensionFactory; use Doctrine\Common\Collections\ArrayCollection; use PHPUnit\Framework\TestCase; @@ -24,12 +24,12 @@ class ContentDimensionCollectionFactoryTest extends TestCase { - protected function createContentDimensionCollectionFactoryInstance(iterable $mappers) + protected function createContentDimensionCollectionFactoryInstance(iterable $mappers): ContentDimensionCollectionFactory { return new ContentDimensionCollectionFactory($mappers); } - public function testCreateWithoutMapperExistContentDimension() + public function testCreateWithoutMapperExistContentDimension(): void { $contentDimension1 = $this->prophesize(ContentDimensionInterface::class); $contentDimension1->getDimensionId()->willReturn('123-456'); @@ -68,7 +68,7 @@ public function testCreateWithoutMapperExistContentDimension() ], iterator_to_array($contentDimensionCollection)); } - public function testCreateWithoutUnlocalizedContentDimension() + public function testCreateWithoutUnlocalizedContentDimension(): void { $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('The "$dimensionCollection" should contain atleast a unlocalizedDimension.'); @@ -104,7 +104,7 @@ public function testCreateWithoutUnlocalizedContentDimension() ); } - public function testCreateWithoutMapperNotExistContentDimension() + public function testCreateWithoutMapperNotExistContentDimension(): void { $contentDimension1 = $this->prophesize(ContentDimensionInterface::class); $contentDimension1->getDimensionId()->willReturn('123-456'); @@ -145,7 +145,7 @@ public function testCreateWithoutMapperNotExistContentDimension() ], iterator_to_array($contentDimensionCollection)); } - public function testCreateWithMappers() + public function testCreateWithMappers(): void { $contentDimension1 = $this->prophesize(ContentDimensionInterface::class); $contentDimension1->getDimensionId()->willReturn('123-456'); diff --git a/Tests/Unit/Content/Application/ContentDimensionFactory/Mapper/ExcerptMapperTest.php b/Tests/Unit/Content/Application/ContentDimensionFactory/Mapper/ExcerptMapperTest.php index 2c645c46..1ec36d48 100644 --- a/Tests/Unit/Content/Application/ContentDimensionFactory/Mapper/ExcerptMapperTest.php +++ b/Tests/Unit/Content/Application/ContentDimensionFactory/Mapper/ExcerptMapperTest.php @@ -11,7 +11,7 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\ContentDimensionCollection\Mapper; +namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\ContentDimensionFactory\Mapper; use PHPUnit\Framework\TestCase; use Sulu\Bundle\ContentBundle\Content\Application\ContentDimensionFactory\Mapper\ExcerptMapper; @@ -26,7 +26,7 @@ class ExcerptMapperTest extends TestCase protected function createExcerptMapperInstance( TagFactoryInterface $tagFactory, CategoryFactoryInterface $categoryFactory - ) { + ): ExcerptMapper { return new ExcerptMapper($tagFactory, $categoryFactory); } @@ -49,9 +49,8 @@ public function testMapNoExcerpt(): void $categoryFactory = $this->prophesize(CategoryFactoryInterface::class); $excerptMapper = $this->createExcerptMapperInstance($tagFactory->reveal(), $categoryFactory->reveal()); - $this->assertNull( - $excerptMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()) - ); + $excerptMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()); + $this->assertTrue(true); // Avoid risky test as this is an early return test } public function testMapLocalizedNoExcerpt(): void @@ -78,9 +77,7 @@ public function testMapLocalizedNoExcerpt(): void $excerptMapper = $this->createExcerptMapperInstance($tagFactory->reveal(), $categoryFactory->reveal()); - $this->assertNull( - $excerptMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()) - ); + $excerptMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()); } public function testMapUnlocalizedExcerpt(): void diff --git a/Tests/Unit/Content/Application/ContentDimensionFactory/Mapper/SeoMapperTest.php b/Tests/Unit/Content/Application/ContentDimensionFactory/Mapper/SeoMapperTest.php index 2e006661..70601abb 100644 --- a/Tests/Unit/Content/Application/ContentDimensionFactory/Mapper/SeoMapperTest.php +++ b/Tests/Unit/Content/Application/ContentDimensionFactory/Mapper/SeoMapperTest.php @@ -11,7 +11,7 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\ContentDimensionCollection\Mapper; +namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\ContentDimensionFactory\Mapper; use PHPUnit\Framework\TestCase; use Sulu\Bundle\ContentBundle\Content\Application\ContentDimensionFactory\Mapper\SeoMapper; @@ -20,7 +20,7 @@ class SeoMapperTest extends TestCase { - protected function createSeoMapperInstance() + protected function createSeoMapperInstance(): SeoMapper { return new SeoMapper(); } @@ -41,9 +41,8 @@ public function testMapNoSeo(): void $localizedContentDimension = $this->prophesize(ContentDimensionInterface::class); $seoMapper = $this->createSeoMapperInstance(); - $this->assertNull( - $seoMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()) - ); + $seoMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()); + $this->assertTrue(true); // Avoid risky test as this is an early return test } public function testMapLocalizedNoSeo(): void @@ -67,9 +66,7 @@ public function testMapLocalizedNoSeo(): void $seoMapper = $this->createSeoMapperInstance(); - $this->assertNull( - $seoMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()) - ); + $seoMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()); } public function testMapUnlocalizedSeo(): void diff --git a/Tests/Unit/Content/Application/ContentDimensionFactory/Mapper/TemplateMapperTest.php b/Tests/Unit/Content/Application/ContentDimensionFactory/Mapper/TemplateMapperTest.php index a4253e91..2953c886 100644 --- a/Tests/Unit/Content/Application/ContentDimensionFactory/Mapper/TemplateMapperTest.php +++ b/Tests/Unit/Content/Application/ContentDimensionFactory/Mapper/TemplateMapperTest.php @@ -11,7 +11,7 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\ContentDimensionCollection\Mapper; +namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\ContentDimensionFactory\Mapper; use PHPUnit\Framework\TestCase; use Sulu\Bundle\ContentBundle\Content\Application\ContentDimensionFactory\Mapper\TemplateMapper; @@ -23,8 +23,9 @@ class TemplateMapperTest extends TestCase { - protected function createTemplateMapperInstance(StructureMetadataFactoryInterface $structureMetadataFactory) - { + protected function createTemplateMapperInstance( + StructureMetadataFactoryInterface $structureMetadataFactory + ): TemplateMapper { return new TemplateMapper($structureMetadataFactory); } @@ -41,10 +42,9 @@ public function testMapNoTemplateInstance(): void $contentDimension = $this->prophesize(ContentDimensionInterface::class); $localizedContentDimension = $this->prophesize(ContentDimensionInterface::class); - $seoMapper = $this->createTemplateMapperInstance($structureMetadataFactory->reveal()); - $this->assertNull( - $seoMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()) - ); + $templateMapper = $this->createTemplateMapperInstance($structureMetadataFactory->reveal()); + $templateMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()); + $this->assertTrue(true); // Avoid risky test as this is an early return test } public function testMapLocalizedNoTemplateKey(): void @@ -60,11 +60,9 @@ public function testMapLocalizedNoTemplateKey(): void $localizedContentDimension = $this->prophesize(ContentDimensionInterface::class); - $seoMapper = $this->createTemplateMapperInstance($structureMetadataFactory->reveal()); + $templateMapper = $this->createTemplateMapperInstance($structureMetadataFactory->reveal()); - $this->assertNull( - $seoMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()) - ); + $templateMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()); } public function testMapLocalizedNoTemplateInstance(): void @@ -95,11 +93,9 @@ public function testMapLocalizedNoTemplateInstance(): void $contentDimension->willImplement(TemplateInterface::class); $contentDimension->getTemplateType()->willReturn('example')->shouldBeCalled(); - $seoMapper = $this->createTemplateMapperInstance($structureMetadataFactory->reveal()); + $templateMapper = $this->createTemplateMapperInstance($structureMetadataFactory->reveal()); - $this->assertNull( - $seoMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()) - ); + $templateMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()); } public function testMapLocalizedNoStructureFound(): void @@ -123,11 +119,9 @@ public function testMapLocalizedNoStructureFound(): void $localizedContentDimension = $this->prophesize(ContentDimensionInterface::class); - $seoMapper = $this->createTemplateMapperInstance($structureMetadataFactory->reveal()); + $templateMapper = $this->createTemplateMapperInstance($structureMetadataFactory->reveal()); - $this->assertNull( - $seoMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()) - ); + $templateMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()); } public function testMapUnlocalizedTemplate(): void @@ -159,9 +153,9 @@ public function testMapUnlocalizedTemplate(): void 'template-key' )->willReturn($structureMetadata->reveal())->shouldBeCalled(); - $seoMapper = $this->createTemplateMapperInstance($structureMetadataFactory->reveal()); + $templateMapper = $this->createTemplateMapperInstance($structureMetadataFactory->reveal()); - $seoMapper->map($data, $contentDimension->reveal()); + $templateMapper->map($data, $contentDimension->reveal()); } public function testMapLocalizedTemplate(): void @@ -202,9 +196,9 @@ public function testMapLocalizedTemplate(): void 'template-key' )->willReturn($structureMetadata->reveal())->shouldBeCalled(); - $seoMapper = $this->createTemplateMapperInstance($structureMetadataFactory->reveal()); + $templateMapper = $this->createTemplateMapperInstance($structureMetadataFactory->reveal()); - $seoMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()); + $templateMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()); } public function testMapFloatValueTemplate(): void @@ -245,8 +239,8 @@ public function testMapFloatValueTemplate(): void 'template-key' )->willReturn($structureMetadata->reveal())->shouldBeCalled(); - $seoMapper = $this->createTemplateMapperInstance($structureMetadataFactory->reveal()); + $templateMapper = $this->createTemplateMapperInstance($structureMetadataFactory->reveal()); - $seoMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()); + $templateMapper->map($data, $contentDimension->reveal(), $localizedContentDimension->reveal()); } } diff --git a/Tests/Unit/Content/Application/Message/CreateContentMessageTest.php b/Tests/Unit/Content/Application/Message/CreateContentMessageTest.php index c3455559..dfc04349 100644 --- a/Tests/Unit/Content/Application/Message/CreateContentMessageTest.php +++ b/Tests/Unit/Content/Application/Message/CreateContentMessageTest.php @@ -23,7 +23,7 @@ class CreateContentMessageTest extends TestCase { /** * @param mixed[] $data - * @param array $dimensionAttributes + * @param mixed[] $dimensionAttributes */ protected function createCreateContentMessageInstance( ContentInterface $content, diff --git a/Tests/Unit/Content/Application/Message/LoadContentMessageTest.php b/Tests/Unit/Content/Application/Message/LoadContentMessageTest.php index e6cdf665..8e23f2f9 100644 --- a/Tests/Unit/Content/Application/Message/LoadContentMessageTest.php +++ b/Tests/Unit/Content/Application/Message/LoadContentMessageTest.php @@ -22,7 +22,7 @@ class LoadContentMessageTest extends TestCase { /** - * @param array $dimensionAttributes + * @param mixed[] $dimensionAttributes */ protected function createLoadContentMessageInstance( ContentInterface $content, diff --git a/Tests/Unit/Content/Application/Message/ModifyContentMessageTest.php b/Tests/Unit/Content/Application/Message/ModifyContentMessageTest.php index b2d0e42b..8d32f02e 100644 --- a/Tests/Unit/Content/Application/Message/ModifyContentMessageTest.php +++ b/Tests/Unit/Content/Application/Message/ModifyContentMessageTest.php @@ -23,7 +23,7 @@ class ModifyContentMessageTest extends TestCase { /** * @param mixed[] $data - * @param array $dimensionAttributes + * @param mixed[] $dimensionAttributes */ protected function createModifyContentMessageInstance( ContentInterface $content, diff --git a/Tests/Unit/Content/Application/MessageHandler/CreateContentMessageHandlerTest.php b/Tests/Unit/Content/Application/MessageHandler/CreateContentMessageHandlerTest.php index 753d9ba3..434d4efb 100644 --- a/Tests/Unit/Content/Application/MessageHandler/CreateContentMessageHandlerTest.php +++ b/Tests/Unit/Content/Application/MessageHandler/CreateContentMessageHandlerTest.php @@ -11,7 +11,7 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\ViewFactory; +namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\MessageHandler; use PHPUnit\Framework\TestCase; use Sulu\Bundle\ContentBundle\Content\Application\Message\CreateContentMessage; @@ -54,7 +54,7 @@ public static function getResourceKey(): string public function createDimension(string $dimensionId): ContentDimensionInterface { - return new \RuntimeException('Should not be called in a unit test.'); + throw new \RuntimeException('Should not be called in a unit test.'); } }; } diff --git a/Tests/Unit/Content/Application/MessageHandler/LoadContentMessageHandlerTest.php b/Tests/Unit/Content/Application/MessageHandler/LoadContentMessageHandlerTest.php index a92fdb1a..3cb44062 100644 --- a/Tests/Unit/Content/Application/MessageHandler/LoadContentMessageHandlerTest.php +++ b/Tests/Unit/Content/Application/MessageHandler/LoadContentMessageHandlerTest.php @@ -11,9 +11,8 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\ViewFactory; +namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\MessageHandler; -use Doctrine\Common\Collections\ArrayCollection; use PHPUnit\Framework\TestCase; use Sulu\Bundle\ContentBundle\Content\Application\Message\LoadContentMessage; use Sulu\Bundle\ContentBundle\Content\Application\MessageHandler\LoadContentMessageHandler; @@ -47,14 +46,7 @@ protected function createLoadContentMessageHandlerInstance( */ protected function createContentInstance(array $dimensions): ContentInterface { - return new class($dimensions) extends AbstractContent { - protected $dimensions; - - public function __construct($dimensions) - { - $this->dimensions = new ArrayCollection($dimensions); - } - + $content = new class() extends AbstractContent { public static function getResourceKey(): string { return 'example'; @@ -62,9 +54,15 @@ public static function getResourceKey(): string public function createDimension(string $dimensionId): ContentDimensionInterface { - return new \RuntimeException('Should not be called in a unit test.'); + throw new \RuntimeException('Should not be called in a unit test.'); } }; + + foreach ($dimensions as $dimension) { + $content->addDimension($dimension); + } + + return $content; } public function testInvoke(): void diff --git a/Tests/Unit/Content/Application/MessageHandler/ModifyContentMessageHandlerTest.php b/Tests/Unit/Content/Application/MessageHandler/ModifyContentMessageHandlerTest.php index fe504a00..b48205e2 100644 --- a/Tests/Unit/Content/Application/MessageHandler/ModifyContentMessageHandlerTest.php +++ b/Tests/Unit/Content/Application/MessageHandler/ModifyContentMessageHandlerTest.php @@ -11,7 +11,7 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\ViewFactory; +namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\MessageHandler; use PHPUnit\Framework\TestCase; use Sulu\Bundle\ContentBundle\Content\Application\Message\ModifyContentMessage; @@ -54,7 +54,7 @@ public static function getResourceKey(): string public function createDimension(string $dimensionId): ContentDimensionInterface { - return new \RuntimeException('Should not be called in a unit test.'); + throw new \RuntimeException('Should not be called in a unit test.'); } }; } diff --git a/Tests/Unit/Dimension/Domain/Model/DimensionCollectionTest.php b/Tests/Unit/Dimension/Domain/Model/DimensionCollectionTest.php index 73a3d008..538ff6d8 100644 --- a/Tests/Unit/Dimension/Domain/Model/DimensionCollectionTest.php +++ b/Tests/Unit/Dimension/Domain/Model/DimensionCollectionTest.php @@ -22,7 +22,7 @@ class DimensionCollectionTest extends TestCase { /** - * @param array $attributes + * @param mixed[] $attributes * @param DimensionInterface[] $dimensions */ protected function createDimensionCollection( @@ -32,6 +32,9 @@ protected function createDimensionCollection( return new DimensionCollection($attributes, $dimensions); } + /** + * @param mixed[] $attributes + */ protected function createDimension(?string $id, array $attributes = []): DimensionInterface { return new Dimension($id, $attributes);