Skip to content

Commit

Permalink
OXDEV-5736 Cleanup usage of "resource" loading for Customer namespace
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Fedurtsya <[email protected]>
  • Loading branch information
Sieg committed Jun 6, 2024
1 parent 26c04c3 commit 5247768
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 30 deletions.
4 changes: 3 additions & 1 deletion services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ services:

OxidEsales\GraphQL\Storefront\:
resource: 'src/*'
exclude: 'src/**/{DataType,Exception,Shop,Event,Subscriber}'
exclude:
- 'src/**/{DataType,Exception,Shop,Event,Subscriber}'
- 'src/Customer'
public: true

OxidEsales\GraphQL\Storefront\Shared\Service\NamespaceMapper:
Expand Down
2 changes: 1 addition & 1 deletion src/Address/Service/InvoiceAddressInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use OxidEsales\GraphQL\Base\Service\Authentication;
use OxidEsales\GraphQL\Storefront\Address\DataType\InvoiceAddress;
use OxidEsales\GraphQL\Storefront\Address\Infrastructure\InvoiceAddressFactory;
use OxidEsales\GraphQL\Storefront\Customer\Service\Customer as CustomerService;
use OxidEsales\GraphQL\Storefront\Customer\Service\CustomerInterface as CustomerService;
use TheCodingMachine\GraphQLite\Annotations\Factory;
use TheCodingMachine\GraphQLite\Types\ID;

Expand Down
2 changes: 1 addition & 1 deletion src/Basket/Service/Basket.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use OxidEsales\GraphQL\Storefront\Country\Service\Country as CountryService;
use OxidEsales\GraphQL\Storefront\Customer\Exception\CustomerNotFound;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\Customer as CustomerInfrastructure;
use OxidEsales\GraphQL\Storefront\Customer\Service\Customer as CustomerService;
use OxidEsales\GraphQL\Storefront\Customer\Service\CustomerInterface as CustomerService;
use OxidEsales\GraphQL\Storefront\DeliveryMethod\DataType\BasketDeliveryMethod as BasketDeliveryMethodDataType;
use OxidEsales\GraphQL\Storefront\DeliveryMethod\Exception\UnavailableDeliveryMethod;
use OxidEsales\GraphQL\Storefront\Payment\DataType\BasketPayment;
Expand Down
2 changes: 1 addition & 1 deletion src/Basket/Service/PlaceOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use OxidEsales\GraphQL\Storefront\Basket\Infrastructure\Basket as BasketInfrastructure;
use OxidEsales\GraphQL\Storefront\Basket\Service\Basket as BasketService;
use OxidEsales\GraphQL\Storefront\Customer\DataType\Customer as CustomerDataType;
use OxidEsales\GraphQL\Storefront\Customer\Service\Customer as CustomerService;
use OxidEsales\GraphQL\Storefront\Customer\Service\CustomerInterface as CustomerService;
use OxidEsales\GraphQL\Storefront\DeliveryMethod\DataType\DeliveryMethod as DeliveryMethodDataType;
use OxidEsales\GraphQL\Storefront\DeliveryMethod\Exception\MissingDeliveryMethod;
use OxidEsales\GraphQL\Storefront\DeliveryMethod\Exception\UnavailableDeliveryMethod;
Expand Down
2 changes: 1 addition & 1 deletion src/Customer/Controller/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use DateTimeInterface;
use OxidEsales\GraphQL\Base\Service\Authentication;
use OxidEsales\GraphQL\Storefront\Customer\DataType\Customer as CustomerDataType;
use OxidEsales\GraphQL\Storefront\Customer\Service\Customer as CustomerService;
use OxidEsales\GraphQL\Storefront\Customer\Service\CustomerInterface as CustomerService;
use TheCodingMachine\GraphQLite\Annotations\HideIfUnauthorized;
use TheCodingMachine\GraphQLite\Annotations\Logged;
use TheCodingMachine\GraphQLite\Annotations\Mutation;
Expand Down
2 changes: 1 addition & 1 deletion src/Customer/Service/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use OxidEsales\GraphQL\Storefront\Customer\Exception\CustomerNotDeletable;
use OxidEsales\GraphQL\Storefront\Customer\Exception\CustomerNotFound;
use OxidEsales\GraphQL\Storefront\Customer\Exception\InvalidEmail;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\Repository as CustomerRepository;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\RepositoryInterface as CustomerRepository;
use OxidEsales\GraphQL\Storefront\Shared\Infrastructure\Repository;
use TheCodingMachine\GraphQLite\Security\AuthorizationServiceInterface;

Expand Down
6 changes: 3 additions & 3 deletions src/Customer/Service/CustomerRegisterInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
use OxidEsales\GraphQL\Storefront\Customer\Exception\InvalidEmail;
use OxidEsales\GraphQL\Storefront\Customer\Exception\PasswordValidationException;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\CustomerRegisterFactory;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\Repository;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\RepositoryInterface;
use TheCodingMachine\GraphQLite\Annotations\Factory;

final class CustomerRegisterInput
{
/** @var Repository */
/** @var RepositoryInterface */
private $repository;

/** @var Legacy */
Expand All @@ -31,7 +31,7 @@ final class CustomerRegisterInput
private $customerRegisterFactory;

public function __construct(
Repository $repository,
RepositoryInterface $repository,
Legacy $legacyService,
CustomerRegisterFactory $customerRegisterFactory
) {
Expand Down
2 changes: 1 addition & 1 deletion src/Customer/Service/RelationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use OxidEsales\GraphQL\Storefront\Basket\Service\BasketFinder as BasketFinderService;
use OxidEsales\GraphQL\Storefront\Customer\DataType\Customer as CustomerDataType;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\Customer as CustomerInfrastructure;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\Repository as CustomerRepository;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\RepositoryInterface as CustomerRepository;
use OxidEsales\GraphQL\Storefront\NewsletterStatus\DataType\NewsletterStatus as NewsletterStatusType;
use OxidEsales\GraphQL\Storefront\NewsletterStatus\Exception\NewsletterStatusForUserNotFound;
use OxidEsales\GraphQL\Storefront\NewsletterStatus\Service\NewsletterStatus as NewsletterStatusService;
Expand Down
34 changes: 24 additions & 10 deletions src/Customer/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,37 @@ services:
_defaults:
public: false
autowire: true
# bind:
# OxidEsales\Eshop\Core\InputValidator: '@=service("OxidEsales\\Storefront\\Core\\Registry").getInputValidator()'
#
bind:
OxidEsales\Eshop\Core\InputValidator: '@=service("OxidEsales\\Storefront\\Core\\Registry").getInputValidator()'

OxidEsales\GraphQL\Storefront\Customer\Service\PasswordInterface:
class: OxidEsales\GraphQL\Storefront\Customer\Service\Password
OxidEsales\GraphQL\Storefront\Customer\Controller\:
resource: 'Controller'
public: true

OxidEsales\GraphQL\Storefront\Customer\Infrastructure\Customer:
public: true

OxidEsales\GraphQL\Storefront\Customer\Infrastructure\CustomerRegisterFactory:

OxidEsales\GraphQL\Storefront\Customer\Infrastructure\PasswordInterface:
class: OxidEsales\GraphQL\Storefront\Customer\Infrastructure\Password

OxidEsales\GraphQL\Storefront\Customer\Infrastructure\RepositoryInterface:
class: OxidEsales\GraphQL\Storefront\Customer\Infrastructure\Repository
public: true

OxidEsales\GraphQL\Storefront\Customer\Service\CustomerInterface:
class: OxidEsales\GraphQL\Storefront\Customer\Service\Customer
public: true

OxidEsales\GraphQL\Storefront\Customer\Service\CustomerRegisterInput:
public: true

OxidEsales\GraphQL\Storefront\Customer\Service\PasswordInterface:
class: OxidEsales\GraphQL\Storefront\Customer\Service\Password

OxidEsales\GraphQL\Storefront\Customer\Service\RelationService:
public: true

TheCodingMachine\GraphQLite\Security\AuthorizationServiceInterface:
class: OxidEsales\GraphQL\Storefront\Shared\Service\Authorization
Expand All @@ -24,8 +43,3 @@ services:
OxidEsales\Storefront\Core\Registry:
class: OxidEsales\Eshop\Core\Registry
public: true

OxidEsales\Eshop\Core\InputValidator:
# the first argument is the class and the second argument is the static method
factory: [ '@OxidEsales\Storefront\Core\Registry', 'getInputValidator' ]

2 changes: 1 addition & 1 deletion src/NewsletterStatus/Infrastructure/NewsletterStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use OxidEsales\GraphQL\Base\Infrastructure\Legacy as LegacyService;
use OxidEsales\GraphQL\Storefront\Customer\DataType\Customer as CustomerDataType;
use OxidEsales\GraphQL\Storefront\Customer\Exception\CustomerNotFound;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\Repository as CustomerRepository;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\RepositoryInterface as CustomerRepository;
use OxidEsales\GraphQL\Storefront\NewsletterStatus\DataType\NewsletterStatus as NewsletterStatusType;
use OxidEsales\GraphQL\Storefront\NewsletterStatus\DataType\NewsletterStatusSubscribe as NewsletterStatusSubscribeType;
use OxidEsales\GraphQL\Storefront\NewsletterStatus\DataType\Subscriber as SubscriberDataType;
Expand Down
10 changes: 5 additions & 5 deletions tests/Integration/Customer/Infrastructure/RepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use OxidEsales\Eshop\Application\Model\User;
use OxidEsales\Eshop\Application\Model\User as EshopModelUser;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\Repository;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\RepositoryInterface;
use OxidEsales\GraphQL\Storefront\Tests\Integration\BaseTestCase;
use PHPUnit\Framework\Attributes\Test;

Expand All @@ -25,8 +25,8 @@ public function testChangePassword(): void
{
$customer = $this->createTestUserWithUpdateKey('coolUpdateKey_123');

/** @var Repository $sut */
$sut = $this->get(Repository::class);
/** @var RepositoryInterface $sut */
$sut = $this->get(RepositoryInterface::class);
$sut->saveNewPasswordForCustomer($customer, 'newPassword');

$customerAfterSave = oxNew(User::class);
Expand All @@ -43,8 +43,8 @@ public function testGetCustomerByPasswordUpdateHashReturnsUser(): void
$updateId = 'foobar';
$customer = $this->createTestUserWithUpdateKey($updateId);

/** @var Repository $sut */
$sut = $this->get(Repository::class);
/** @var RepositoryInterface $sut */
$sut = $this->get(RepositoryInterface::class);
$updateHash = md5($customer->getId() . $customer->getShopId() . $updateId);
$customerByUpdateId = $sut->getCustomerByPasswordUpdateHash($updateHash);

Expand Down
7 changes: 4 additions & 3 deletions tests/Integration/Customer/Service/CustomerServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
use OxidEsales\Eshop\Core\Registry as EshopRegistry;
use OxidEsales\GraphQL\Storefront\Customer\Exception\CustomerNotDeletable;
use OxidEsales\GraphQL\Storefront\Customer\Service\Customer;
use OxidEsales\GraphQL\Storefront\Shared\Service\Authorization;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\Repository as CustomerRepository;
use OxidEsales\GraphQL\Storefront\Customer\Service\Customer as CustomerService;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\RepositoryInterface as CustomerRepository;
use OxidEsales\GraphQL\Storefront\Customer\Service\CustomerInterface as CustomerService;
use OxidEsales\GraphQL\Storefront\Shared\Infrastructure\Repository;
use OxidEsales\GraphQL\Storefront\Customer\Exception\CustomerNotFound;
use OxidEsales\GraphQL\Base\Tests\Integration\TestCase;
Expand Down Expand Up @@ -102,7 +103,7 @@ public function testDeleteCustomerNotPossible(): void
->method('getUser')
->willReturn($userDataType);

$customerService = new CustomerService(
$customerService = new Customer(
new Repository(
$container->get(QueryBuilderFactoryInterface::class),
new ListConfiguration()
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Service/BasketServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use OxidEsales\GraphQL\Storefront\Basket\Service\BasketFinder;
use OxidEsales\GraphQL\Storefront\Country\Service\Country as CountryService;
use OxidEsales\GraphQL\Storefront\Customer\Infrastructure\Customer as CustomerInfrastructure;
use OxidEsales\GraphQL\Storefront\Customer\Service\Customer as CustomerService;
use OxidEsales\GraphQL\Storefront\Customer\Service\CustomerInterface as CustomerService;
use OxidEsales\GraphQL\Storefront\Shared\Infrastructure\Basket as SharedBasketInfrastructure;
use OxidEsales\GraphQL\Storefront\Shared\Infrastructure\ListConfiguration;
use OxidEsales\GraphQL\Storefront\Shared\Infrastructure\Repository;
Expand Down

0 comments on commit 5247768

Please sign in to comment.