From 148bafc39a42d818817ae9eb00ced05e40d68490 Mon Sep 17 00:00:00 2001 From: ilyakubanov Date: Mon, 5 Aug 2024 14:09:22 +0200 Subject: [PATCH 1/5] Expand user --- composer.json | 3 +- .../Transfer/amazon_quicksight.transfer.xml | 9 ++ .../AmazonQuicksightBusinessFactory.php | 9 ++ .../Business/AmazonQuicksightFacade.php | 15 ++++ .../AmazonQuicksightFacadeInterface.php | 18 ++++ .../Business/Expander/UserExpander.php | 84 +++++++++++++++++ .../Expander/UserExpanderInterface.php | 22 +++++ .../User/QuicksightUserUserExpanderPlugin.php | 38 ++++++++ .../AmazonQuicksightPersistenceFactory.php | 17 ++++ .../AmazonQuicksightRepository.php | 20 +++++ .../AmazonQuicksightRepositoryInterface.php | 6 ++ .../Propel/Mapper/QuicksightUserMapper.php | 48 ++++++++++ ...ndUserCollectionWithQuicksightUserTest.php | 90 +++++++++++++++++++ .../_support/AmazonQuicksightTester.php | 56 ++++++++++++ .../Zed/AmazonQuicksight/codeception.yml | 18 +++- tests/_data/amazon_quicksight.databuilder.xml | 15 ++++ 16 files changed, 464 insertions(+), 4 deletions(-) create mode 100644 src/SprykerEco/Zed/AmazonQuicksight/Business/Expander/UserExpander.php create mode 100644 src/SprykerEco/Zed/AmazonQuicksight/Business/Expander/UserExpanderInterface.php create mode 100644 src/SprykerEco/Zed/AmazonQuicksight/Communication/Plugin/User/QuicksightUserUserExpanderPlugin.php create mode 100644 src/SprykerEco/Zed/AmazonQuicksight/Persistence/Propel/Mapper/QuicksightUserMapper.php create mode 100644 tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/ExpandUserCollectionWithQuicksightUserTest.php create mode 100644 tests/SprykerEcoTest/Zed/AmazonQuicksight/_support/AmazonQuicksightTester.php create mode 100644 tests/_data/amazon_quicksight.databuilder.xml diff --git a/composer.json b/composer.json index cd38031..e057f3d 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,8 @@ "aws/aws-sdk-php": "^3.90.0", "php": ">=8.1", "spryker/kernel": "^3.30.0", - "spryker/user": "^3.0.0" + "spryker/user": "^3.0.0", + "spryker/user-extension": "^1.2.0" }, "require-dev": { "spryker/code-sniffer": "*", diff --git a/src/SprykerEco/Shared/AmazonQuicksight/Transfer/amazon_quicksight.transfer.xml b/src/SprykerEco/Shared/AmazonQuicksight/Transfer/amazon_quicksight.transfer.xml index 499c4e6..a06f23b 100644 --- a/src/SprykerEco/Shared/AmazonQuicksight/Transfer/amazon_quicksight.transfer.xml +++ b/src/SprykerEco/Shared/AmazonQuicksight/Transfer/amazon_quicksight.transfer.xml @@ -12,4 +12,13 @@ + + + + + + + + + diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightBusinessFactory.php b/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightBusinessFactory.php index 07adc4a..683b2b9 100644 --- a/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightBusinessFactory.php +++ b/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightBusinessFactory.php @@ -8,6 +8,8 @@ namespace SprykerEco\Zed\AmazonQuicksight\Business; use Spryker\Zed\Kernel\Business\AbstractBusinessFactory; +use SprykerEco\Zed\AmazonQuicksight\Business\Expander\UserExpander; +use SprykerEco\Zed\AmazonQuicksight\Business\Expander\UserExpanderInterface; /** * @method \SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightConfig getConfig() @@ -16,4 +18,11 @@ */ class AmazonQuicksightBusinessFactory extends AbstractBusinessFactory { + /** + * @return \SprykerEco\Zed\AmazonQuicksight\Business\Expander\UserExpanderInterface + */ + public function createUserExpander(): UserExpanderInterface + { + return new UserExpander($this->getRepository()); + } } diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacade.php b/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacade.php index c8b7f3a..06872b0 100644 --- a/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacade.php +++ b/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacade.php @@ -7,6 +7,7 @@ namespace SprykerEco\Zed\AmazonQuicksight\Business; +use Generated\Shared\Transfer\UserCollectionTransfer; use Spryker\Zed\Kernel\Business\AbstractFacade; /** @@ -16,4 +17,18 @@ */ class AmazonQuicksightFacade extends AbstractFacade implements AmazonQuicksightFacadeInterface { + /** + * {@inheritDoc} + * + * @api + * + * @param \Generated\Shared\Transfer\UserCollectionTransfer $userCollectionTransfer + * + * @return \Generated\Shared\Transfer\UserCollectionTransfer + */ + public function expandUserCollectionWithQuicksightUser( + UserCollectionTransfer $userCollectionTransfer + ): UserCollectionTransfer { + return $this->getFactory()->createUserExpander()->expandUserCollectionWithQuicksightUser($userCollectionTransfer); + } } diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacadeInterface.php b/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacadeInterface.php index 30abb24..6fb2f47 100644 --- a/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacadeInterface.php +++ b/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacadeInterface.php @@ -7,6 +7,24 @@ namespace SprykerEco\Zed\AmazonQuicksight\Business; +use Generated\Shared\Transfer\UserCollectionTransfer; + interface AmazonQuicksightFacadeInterface { + /** + * Specification: + * - Iterates over `UserCollectionTransfer.users`. + * - Requires `UserTransfer.idUser` for each user in collection to be set. + * - Finds Quicksight users by `UserTransfer.idUser` in DB. + * - Populates `UserTransfer.quicksightUser` in collection with found Quicksight users. + * + * @api + * + * @param \Generated\Shared\Transfer\UserCollectionTransfer $userCollectionTransfer + * + * @return \Generated\Shared\Transfer\UserCollectionTransfer + */ + public function expandUserCollectionWithQuicksightUser( + UserCollectionTransfer $userCollectionTransfer + ): UserCollectionTransfer; } diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Business/Expander/UserExpander.php b/src/SprykerEco/Zed/AmazonQuicksight/Business/Expander/UserExpander.php new file mode 100644 index 0000000..0fe6f8a --- /dev/null +++ b/src/SprykerEco/Zed/AmazonQuicksight/Business/Expander/UserExpander.php @@ -0,0 +1,84 @@ +amazonQuicksightRepository = $amazonQuicksightRepository; + } + + /** + * @param \Generated\Shared\Transfer\UserCollectionTransfer $userCollectionTransfer + * + * @return \Generated\Shared\Transfer\UserCollectionTransfer + */ + public function expandUserCollectionWithQuicksightUser( + UserCollectionTransfer $userCollectionTransfer + ): UserCollectionTransfer { + $userIds = $this->getUserIds($userCollectionTransfer); + $quicksightUserTransfers = $this->amazonQuicksightRepository->getQuicksightUsersByUserIds($userIds); + + if (!$quicksightUserTransfers) { + return $userCollectionTransfer; + } + + $quicksightUserTransfersIndexedByIdUser = $this->getQuicksightUserTransfersIndexedByIdUser($quicksightUserTransfers); + + foreach ($userCollectionTransfer->getUsers() as $userTransfer) { + $idUser = $userTransfer->getIdUserOrFail(); + if (isset($quicksightUserTransfersIndexedByIdUser[$idUser])) { + $userTransfer->setQuicksightUser($quicksightUserTransfersIndexedByIdUser[$idUser]); + } + } + + return $userCollectionTransfer; + } + + /** + * @param \Generated\Shared\Transfer\UserCollectionTransfer $userCollectionTransfer + * + * @return list + */ + protected function getUserIds(UserCollectionTransfer $userCollectionTransfer): array + { + $userIds = []; + foreach ($userCollectionTransfer->getUsers() as $userTransfer) { + $userIds[] = $userTransfer->getIdUserOrFail(); + } + + return $userIds; + } + + /** + * @param list<\Generated\Shared\Transfer\QuicksightUserTransfer> $quicksightUserTransfers + * + * @return array + */ + protected function getQuicksightUserTransfersIndexedByIdUser(array $quicksightUserTransfers): array + { + $quicksightUserTransfersIndexedByIdUser = []; + foreach ($quicksightUserTransfers as $quicksightUserTransfer) { + $quicksightUserTransfersIndexedByIdUser[$quicksightUserTransfer->getFkUserOrFail()] = $quicksightUserTransfer; + } + + return $quicksightUserTransfersIndexedByIdUser; + } +} diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Business/Expander/UserExpanderInterface.php b/src/SprykerEco/Zed/AmazonQuicksight/Business/Expander/UserExpanderInterface.php new file mode 100644 index 0000000..8ea11b5 --- /dev/null +++ b/src/SprykerEco/Zed/AmazonQuicksight/Business/Expander/UserExpanderInterface.php @@ -0,0 +1,22 @@ +getFacade()->expandUserCollectionWithQuicksightUser($userCollectionTransfer); + } +} diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Persistence/AmazonQuicksightPersistenceFactory.php b/src/SprykerEco/Zed/AmazonQuicksight/Persistence/AmazonQuicksightPersistenceFactory.php index 2c52f7c..da0fc03 100644 --- a/src/SprykerEco/Zed/AmazonQuicksight/Persistence/AmazonQuicksightPersistenceFactory.php +++ b/src/SprykerEco/Zed/AmazonQuicksight/Persistence/AmazonQuicksightPersistenceFactory.php @@ -7,7 +7,9 @@ namespace SprykerEco\Zed\AmazonQuicksight\Persistence; +use Orm\Zed\AmazonQuicksight\Persistence\SpyQuicksightUserQuery; use Spryker\Zed\Kernel\Persistence\AbstractPersistenceFactory; +use SprykerEco\Zed\AmazonQuicksight\Persistence\Propel\Mapper\QuicksightUserMapper; /** * @method \SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightConfig getConfig() @@ -16,4 +18,19 @@ */ class AmazonQuicksightPersistenceFactory extends AbstractPersistenceFactory { + /** + * @return \SprykerEco\Zed\AmazonQuicksight\Persistence\Propel\Mapper\QuicksightUserMapper + */ + public function createQuicksightUserMapper(): QuicksightUserMapper + { + return new QuicksightUserMapper(); + } + + /** + * @return \Orm\Zed\AmazonQuicksight\Persistence\SpyQuicksightUserQuery + */ + public function getQuicksightUserQuery(): SpyQuicksightUserQuery + { + return SpyQuicksightUserQuery::create(); + } } diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Persistence/AmazonQuicksightRepository.php b/src/SprykerEco/Zed/AmazonQuicksight/Persistence/AmazonQuicksightRepository.php index 7bdf106..9c3bebb 100644 --- a/src/SprykerEco/Zed/AmazonQuicksight/Persistence/AmazonQuicksightRepository.php +++ b/src/SprykerEco/Zed/AmazonQuicksight/Persistence/AmazonQuicksightRepository.php @@ -14,4 +14,24 @@ */ class AmazonQuicksightRepository extends AbstractRepository implements AmazonQuicksightRepositoryInterface { + /** + * @param list $userIds + * + * @return list<\Generated\Shared\Transfer\QuicksightUserTransfer> + */ + public function getQuicksightUsersByUserIds(array $userIds): array + { + $quicksightUserEntities = $this->getFactory() + ->getQuicksightUserQuery() + ->filterByFkUser_In($userIds) + ->find(); + + if (!$quicksightUserEntities->count()) { + return []; + } + + return $this->getFactory() + ->createQuicksightUserMapper() + ->mapQuicksightUserEntitiesToQuicksightUserTransfers($quicksightUserEntities, []); + } } diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Persistence/AmazonQuicksightRepositoryInterface.php b/src/SprykerEco/Zed/AmazonQuicksight/Persistence/AmazonQuicksightRepositoryInterface.php index 174fe0b..4aaecb0 100644 --- a/src/SprykerEco/Zed/AmazonQuicksight/Persistence/AmazonQuicksightRepositoryInterface.php +++ b/src/SprykerEco/Zed/AmazonQuicksight/Persistence/AmazonQuicksightRepositoryInterface.php @@ -9,4 +9,10 @@ interface AmazonQuicksightRepositoryInterface { + /** + * @param list $userIds + * + * @return list<\Generated\Shared\Transfer\QuicksightUserTransfer> + */ + public function getQuicksightUsersByUserIds(array $userIds): array; } diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Persistence/Propel/Mapper/QuicksightUserMapper.php b/src/SprykerEco/Zed/AmazonQuicksight/Persistence/Propel/Mapper/QuicksightUserMapper.php new file mode 100644 index 0000000..c0d6eb4 --- /dev/null +++ b/src/SprykerEco/Zed/AmazonQuicksight/Persistence/Propel/Mapper/QuicksightUserMapper.php @@ -0,0 +1,48 @@ + $quicksightUserEntities + * @param list<\Generated\Shared\Transfer\QuicksightUserTransfer> $quicksightUserTransfers + * + * @return list<\Generated\Shared\Transfer\QuicksightUserTransfer> + */ + public function mapQuicksightUserEntitiesToQuicksightUserTransfers( + ObjectCollection $quicksightUserEntities, + array $quicksightUserTransfers + ): array { + foreach ($quicksightUserEntities as $quicksightUserEntity) { + $quicksightUserTransfers[] = $this->mapQuicksightUserEntityToQuicksightUserTransfer( + $quicksightUserEntity, + new QuicksightUserTransfer(), + ); + } + + return $quicksightUserTransfers; + } + + /** + * @param \Orm\Zed\AmazonQuicksight\Persistence\SpyQuicksightUser $quicksightUserEntity + * @param \Generated\Shared\Transfer\QuicksightUserTransfer $quicksightUserTransfer + * + * @return \Generated\Shared\Transfer\QuicksightUserTransfer + */ + protected function mapQuicksightUserEntityToQuicksightUserTransfer( + SpyQuicksightUser $quicksightUserEntity, + QuicksightUserTransfer $quicksightUserTransfer + ): QuicksightUserTransfer { + return $quicksightUserTransfer->fromArray($quicksightUserEntity->toArray(), true); + } +} diff --git a/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/ExpandUserCollectionWithQuicksightUserTest.php b/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/ExpandUserCollectionWithQuicksightUserTest.php new file mode 100644 index 0000000..2649948 --- /dev/null +++ b/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/ExpandUserCollectionWithQuicksightUserTest.php @@ -0,0 +1,90 @@ +tester->haveUser(); + $userTransfer2 = $this->tester->haveUser(); + $this->tester->haveQuicksightUser($userTransfer2); + $userCollectionTransfer = (new UserCollectionTransfer())->addUser($userTransfer1); + + // Act + $this->tester->getFacade()->expandUserCollectionWithQuicksightUser($userCollectionTransfer); + + // Assert + $this->assertNull($userCollectionTransfer->getUsers()->offsetGet(0)->getQuicksightUser()); + } + + /** + * @return void + */ + public function testExpandsAllUsersInCollectionWhenQuicksightUsersFound(): void + { + // Arrange + $userTransfer1 = $this->tester->haveUser(); + $userTransfer2 = $this->tester->haveUser(); + $quicksightUserTransfer1 = $this->tester->haveQuicksightUser($userTransfer1); + $quicksightUserTransfer2 = $this->tester->haveQuicksightUser($userTransfer2); + $userCollectionTransfer = (new UserCollectionTransfer()) + ->addUser($userTransfer1) + ->addUser($userTransfer2); + + // Act + $this->tester->getFacade()->expandUserCollectionWithQuicksightUser($userCollectionTransfer); + + // Assert + $this->assertSame( + $quicksightUserTransfer1->getFkUser(), + $userCollectionTransfer->getUsers()->offsetGet(0)->getQuicksightUser()->getFkUser(), + ); + $this->assertSame( + $quicksightUserTransfer2->getFkUser(), + $userCollectionTransfer->getUsers()->offsetGet(1)->getQuicksightUser()->getFkUser(), + ); + } + + /** + * @return void + */ + public function testExpandsOneUserInCollectionWhenOneQuicksightUserFound(): void + { + // Arrange + $userTransfer1 = $this->tester->haveUser(); + $userTransfer2 = $this->tester->haveUser(); + $quicksightUserTransfer = $this->tester->haveQuicksightUser($userTransfer2); + $userCollectionTransfer = (new UserCollectionTransfer()) + ->addUser($userTransfer1) + ->addUser($userTransfer2); + + // Act + $this->tester->getFacade()->expandUserCollectionWithQuicksightUser($userCollectionTransfer); + + // Assert + $this->assertNull($userCollectionTransfer->getUsers()->offsetGet(0)->getQuicksightUser()); + $this->assertSame( + $quicksightUserTransfer->getFkUser(), + $userCollectionTransfer->getUsers()->offsetGet(1)->getQuicksightUser()->getFkUser(), + ); + } +} diff --git a/tests/SprykerEcoTest/Zed/AmazonQuicksight/_support/AmazonQuicksightTester.php b/tests/SprykerEcoTest/Zed/AmazonQuicksight/_support/AmazonQuicksightTester.php new file mode 100644 index 0000000..89eed46 --- /dev/null +++ b/tests/SprykerEcoTest/Zed/AmazonQuicksight/_support/AmazonQuicksightTester.php @@ -0,0 +1,56 @@ +build(); + $quicksightUserTransfer->setFkUser($userTransfer->getIdUserOrFail()); + $quicksightUserEntity = (new SpyQuicksightUser()) + ->fromArray($quicksightUserTransfer->toArray()); + $quicksightUserEntity->save(); + + $quicksightUserTransfer->setFkUser($quicksightUserEntity->getFkUser()); + + return $quicksightUserTransfer; + } +} diff --git a/tests/SprykerEcoTest/Zed/AmazonQuicksight/codeception.yml b/tests/SprykerEcoTest/Zed/AmazonQuicksight/codeception.yml index e3d070b..5f849d0 100644 --- a/tests/SprykerEcoTest/Zed/AmazonQuicksight/codeception.yml +++ b/tests/SprykerEcoTest/Zed/AmazonQuicksight/codeception.yml @@ -7,6 +7,18 @@ paths: coverage: enabled: true remote: false - whitelist: - include: - - '../../../../src/*' + whitelist: { include: ['../../../../src/*'] } + +suites: + Business: + path: . + actor: AmazonQuicksightTester + modules: + enabled: + - Asserts + - \SprykerTest\Zed\Testify\Helper\Business\BusinessHelper + - \SprykerTest\Shared\Testify\Helper\DataCleanupHelper + - \SprykerTest\Shared\Testify\Helper\Environment + - \SprykerTest\Shared\Testify\Helper\LocatorHelper + - \SprykerTest\Shared\Propel\Helper\TransactionHelper + - \SprykerTest\Shared\User\Helper\UserDataHelper diff --git a/tests/_data/amazon_quicksight.databuilder.xml b/tests/_data/amazon_quicksight.databuilder.xml new file mode 100644 index 0000000..475d0ad --- /dev/null +++ b/tests/_data/amazon_quicksight.databuilder.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + From b58afdee6d8faad636b2717aa94f0a148c4861cc Mon Sep 17 00:00:00 2001 From: ilyakubanov Date: Mon, 5 Aug 2024 14:38:21 +0200 Subject: [PATCH 2/5] Fix --- .../Persistence/Propel/Mapper/QuicksightUserMapper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Persistence/Propel/Mapper/QuicksightUserMapper.php b/src/SprykerEco/Zed/AmazonQuicksight/Persistence/Propel/Mapper/QuicksightUserMapper.php index c0d6eb4..904cce3 100644 --- a/src/SprykerEco/Zed/AmazonQuicksight/Persistence/Propel/Mapper/QuicksightUserMapper.php +++ b/src/SprykerEco/Zed/AmazonQuicksight/Persistence/Propel/Mapper/QuicksightUserMapper.php @@ -9,18 +9,18 @@ use Generated\Shared\Transfer\QuicksightUserTransfer; use Orm\Zed\AmazonQuicksight\Persistence\SpyQuicksightUser; -use Propel\Runtime\Collection\ObjectCollection; +use Propel\Runtime\Collection\Collection; class QuicksightUserMapper { /** - * @param \Propel\Runtime\Collection\ObjectCollection<\Orm\Zed\AmazonQuicksight\Persistence\SpyQuicksightUser> $quicksightUserEntities + * @param \Propel\Runtime\Collection\Collection<\Orm\Zed\AmazonQuicksight\Persistence\SpyQuicksightUser> $quicksightUserEntities * @param list<\Generated\Shared\Transfer\QuicksightUserTransfer> $quicksightUserTransfers * * @return list<\Generated\Shared\Transfer\QuicksightUserTransfer> */ public function mapQuicksightUserEntitiesToQuicksightUserTransfers( - ObjectCollection $quicksightUserEntities, + Collection $quicksightUserEntities, array $quicksightUserTransfers ): array { foreach ($quicksightUserEntities as $quicksightUserEntity) { From 2a2c8f7d7b391fff5b143bc61d7e7a3d1df1fb0d Mon Sep 17 00:00:00 2001 From: ilyakubanov Date: Mon, 5 Aug 2024 14:48:48 +0200 Subject: [PATCH 3/5] phpstan.neon --- phpstan.neon | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/phpstan.neon b/phpstan.neon index 3260382..51397b2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,3 +4,10 @@ parameters: - src/ excludePaths: - src/SprykerEco/Zed/AmazonQuicksight/Persistence/Propel/Abstract*.php + ignoreErrors: + - '#Parameter .+ of method .+ has invalid typehint type .+Transfer#' + - '#Return typehint of method .+ has invalid type .+Transfer#' + - '#Instantiated class .+Transfer not found#' + - '#Return typehint of method .+ has invalid type Orm\\.+#' + - '#Call to method .+\(\) on an unknown class Orm\\.+#' + - '#Call to static method create\(\) on an unknown class .+Query.#' From 5e7bf13023a53c2a430858d8ec4c6ce2b7e84012 Mon Sep 17 00:00:00 2001 From: ilyakubanov Date: Mon, 5 Aug 2024 14:51:51 +0200 Subject: [PATCH 4/5] phpstan.neon --- phpstan.neon | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpstan.neon b/phpstan.neon index 51397b2..42eea45 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,9 +5,11 @@ parameters: excludePaths: - src/SprykerEco/Zed/AmazonQuicksight/Persistence/Propel/Abstract*.php ignoreErrors: + - '#Call to method .+ on an unknown class .+Transfer#' - '#Parameter .+ of method .+ has invalid typehint type .+Transfer#' - '#Return typehint of method .+ has invalid type .+Transfer#' - '#Instantiated class .+Transfer not found#' - '#Return typehint of method .+ has invalid type Orm\\.+#' - '#Call to method .+\(\) on an unknown class Orm\\.+#' - '#Call to static method create\(\) on an unknown class .+Query.#' + - '#Parameter \$.+ of method .+ has invalid typehint type Orm\\.+#' From eb412993e58aa58bc116bd6ae13a080f6780dd89 Mon Sep 17 00:00:00 2001 From: ilyakubanov Date: Tue, 6 Aug 2024 11:23:53 +0200 Subject: [PATCH 5/5] Fixed comments --- .../AmazonQuicksight/Business/AmazonQuicksightFacade.php | 2 +- .../Business/AmazonQuicksightFacadeInterface.php | 4 ++-- .../AmazonQuicksight/Business/Expander/UserExpander.php | 4 ++-- ...xpanderPlugin.php => QuicksightUserExpanderPlugin.php} | 4 ++-- ...hp => ExpandUserCollectionWithQuicksightUsersTest.php} | 8 ++++---- .../AmazonQuicksight/_support/AmazonQuicksightTester.php | 2 -- tests/_data/amazon_quicksight.databuilder.xml | 2 +- 7 files changed, 12 insertions(+), 14 deletions(-) rename src/SprykerEco/Zed/AmazonQuicksight/Communication/Plugin/User/{QuicksightUserUserExpanderPlugin.php => QuicksightUserExpanderPlugin.php} (90%) rename tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/{ExpandUserCollectionWithQuicksightUserTest.php => ExpandUserCollectionWithQuicksightUsersTest.php} (94%) diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacade.php b/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacade.php index 06872b0..10ea988 100644 --- a/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacade.php +++ b/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacade.php @@ -26,7 +26,7 @@ class AmazonQuicksightFacade extends AbstractFacade implements AmazonQuicksightF * * @return \Generated\Shared\Transfer\UserCollectionTransfer */ - public function expandUserCollectionWithQuicksightUser( + public function expandUserCollectionWithQuicksightUsers( UserCollectionTransfer $userCollectionTransfer ): UserCollectionTransfer { return $this->getFactory()->createUserExpander()->expandUserCollectionWithQuicksightUser($userCollectionTransfer); diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacadeInterface.php b/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacadeInterface.php index 6fb2f47..86069e2 100644 --- a/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacadeInterface.php +++ b/src/SprykerEco/Zed/AmazonQuicksight/Business/AmazonQuicksightFacadeInterface.php @@ -13,8 +13,8 @@ interface AmazonQuicksightFacadeInterface { /** * Specification: + * - Requires `UserTransfer.idUser` for each user in `UserCollectionTransfer` to be set. * - Iterates over `UserCollectionTransfer.users`. - * - Requires `UserTransfer.idUser` for each user in collection to be set. * - Finds Quicksight users by `UserTransfer.idUser` in DB. * - Populates `UserTransfer.quicksightUser` in collection with found Quicksight users. * @@ -24,7 +24,7 @@ interface AmazonQuicksightFacadeInterface * * @return \Generated\Shared\Transfer\UserCollectionTransfer */ - public function expandUserCollectionWithQuicksightUser( + public function expandUserCollectionWithQuicksightUsers( UserCollectionTransfer $userCollectionTransfer ): UserCollectionTransfer; } diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Business/Expander/UserExpander.php b/src/SprykerEco/Zed/AmazonQuicksight/Business/Expander/UserExpander.php index 0fe6f8a..c0ef717 100644 --- a/src/SprykerEco/Zed/AmazonQuicksight/Business/Expander/UserExpander.php +++ b/src/SprykerEco/Zed/AmazonQuicksight/Business/Expander/UserExpander.php @@ -33,7 +33,7 @@ public function __construct(AmazonQuicksightRepositoryInterface $amazonQuicksigh public function expandUserCollectionWithQuicksightUser( UserCollectionTransfer $userCollectionTransfer ): UserCollectionTransfer { - $userIds = $this->getUserIds($userCollectionTransfer); + $userIds = $this->extractUserIds($userCollectionTransfer); $quicksightUserTransfers = $this->amazonQuicksightRepository->getQuicksightUsersByUserIds($userIds); if (!$quicksightUserTransfers) { @@ -57,7 +57,7 @@ public function expandUserCollectionWithQuicksightUser( * * @return list */ - protected function getUserIds(UserCollectionTransfer $userCollectionTransfer): array + protected function extractUserIds(UserCollectionTransfer $userCollectionTransfer): array { $userIds = []; foreach ($userCollectionTransfer->getUsers() as $userTransfer) { diff --git a/src/SprykerEco/Zed/AmazonQuicksight/Communication/Plugin/User/QuicksightUserUserExpanderPlugin.php b/src/SprykerEco/Zed/AmazonQuicksight/Communication/Plugin/User/QuicksightUserExpanderPlugin.php similarity index 90% rename from src/SprykerEco/Zed/AmazonQuicksight/Communication/Plugin/User/QuicksightUserUserExpanderPlugin.php rename to src/SprykerEco/Zed/AmazonQuicksight/Communication/Plugin/User/QuicksightUserExpanderPlugin.php index 4fdb9c2..09f5573 100644 --- a/src/SprykerEco/Zed/AmazonQuicksight/Communication/Plugin/User/QuicksightUserUserExpanderPlugin.php +++ b/src/SprykerEco/Zed/AmazonQuicksight/Communication/Plugin/User/QuicksightUserExpanderPlugin.php @@ -16,7 +16,7 @@ * @method \SprykerEco\Zed\AmazonQuicksight\Business\AmazonQuicksightFacadeInterface getFacade() * @method \SprykerEco\Zed\AmazonQuicksight\Communication\AmazonQuicksightCommunicationFactory getFactory() */ -class QuicksightUserUserExpanderPlugin extends AbstractPlugin implements UserExpanderPluginInterface +class QuicksightUserExpanderPlugin extends AbstractPlugin implements UserExpanderPluginInterface { /** * {@inheritDoc} @@ -33,6 +33,6 @@ class QuicksightUserUserExpanderPlugin extends AbstractPlugin implements UserExp */ public function expand(UserCollectionTransfer $userCollectionTransfer): UserCollectionTransfer { - return $this->getFacade()->expandUserCollectionWithQuicksightUser($userCollectionTransfer); + return $this->getFacade()->expandUserCollectionWithQuicksightUsers($userCollectionTransfer); } } diff --git a/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/ExpandUserCollectionWithQuicksightUserTest.php b/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/ExpandUserCollectionWithQuicksightUsersTest.php similarity index 94% rename from tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/ExpandUserCollectionWithQuicksightUserTest.php rename to tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/ExpandUserCollectionWithQuicksightUsersTest.php index 2649948..bfbc433 100644 --- a/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/ExpandUserCollectionWithQuicksightUserTest.php +++ b/tests/SprykerEcoTest/Zed/AmazonQuicksight/Business/Facade/ExpandUserCollectionWithQuicksightUsersTest.php @@ -11,7 +11,7 @@ use Generated\Shared\Transfer\UserCollectionTransfer; use SprykerEcoTest\Zed\AmazonQuicksight\AmazonQuicksightTester; -class ExpandUserCollectionWithQuicksightUserTest extends Unit +class ExpandUserCollectionWithQuicksightUsersTest extends Unit { /** * @var \SprykerEcoTest\Zed\AmazonQuicksight\AmazonQuicksightTester @@ -30,7 +30,7 @@ public function testDoesNotExpandCollectionWhenQuicksightUserNotFound(): void $userCollectionTransfer = (new UserCollectionTransfer())->addUser($userTransfer1); // Act - $this->tester->getFacade()->expandUserCollectionWithQuicksightUser($userCollectionTransfer); + $this->tester->getFacade()->expandUserCollectionWithQuicksightUsers($userCollectionTransfer); // Assert $this->assertNull($userCollectionTransfer->getUsers()->offsetGet(0)->getQuicksightUser()); @@ -51,7 +51,7 @@ public function testExpandsAllUsersInCollectionWhenQuicksightUsersFound(): void ->addUser($userTransfer2); // Act - $this->tester->getFacade()->expandUserCollectionWithQuicksightUser($userCollectionTransfer); + $this->tester->getFacade()->expandUserCollectionWithQuicksightUsers($userCollectionTransfer); // Assert $this->assertSame( @@ -78,7 +78,7 @@ public function testExpandsOneUserInCollectionWhenOneQuicksightUserFound(): void ->addUser($userTransfer2); // Act - $this->tester->getFacade()->expandUserCollectionWithQuicksightUser($userCollectionTransfer); + $this->tester->getFacade()->expandUserCollectionWithQuicksightUsers($userCollectionTransfer); // Assert $this->assertNull($userCollectionTransfer->getUsers()->offsetGet(0)->getQuicksightUser()); diff --git a/tests/SprykerEcoTest/Zed/AmazonQuicksight/_support/AmazonQuicksightTester.php b/tests/SprykerEcoTest/Zed/AmazonQuicksight/_support/AmazonQuicksightTester.php index 89eed46..a3fe1fe 100644 --- a/tests/SprykerEcoTest/Zed/AmazonQuicksight/_support/AmazonQuicksightTester.php +++ b/tests/SprykerEcoTest/Zed/AmazonQuicksight/_support/AmazonQuicksightTester.php @@ -5,8 +5,6 @@ * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. */ -declare(strict_types=1); - namespace SprykerEcoTest\Zed\AmazonQuicksight; use Codeception\Actor; diff --git a/tests/_data/amazon_quicksight.databuilder.xml b/tests/_data/amazon_quicksight.databuilder.xml index 475d0ad..d3a446b 100644 --- a/tests/_data/amazon_quicksight.databuilder.xml +++ b/tests/_data/amazon_quicksight.databuilder.xml @@ -9,7 +9,7 @@ - +