-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
187 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment Module | ||
* | ||
* Copyright (c) 2024 Adyen N.V. | ||
* This file is open source and available under the MIT license. | ||
* See the LICENSE file for more info. | ||
* | ||
* Author: Adyen <[email protected]> | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Adyen\Payment\Model\Resolver\StoreConfig; | ||
|
||
use Adyen\Payment\Helper\Data; | ||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Magento\GraphQl\Model\Query\Context; | ||
use Magento\Store\Api\Data\StoreInterface; | ||
use Reflet\GraphQlFaker\Attribute\FakeResolver; | ||
use Reflet\GraphQlFaker\Model\Resolver\NullResolver; | ||
|
||
class StoreLocale implements ResolverInterface | ||
{ | ||
protected Data $dataHelper; | ||
|
||
/** | ||
* @param Data $adyenHelper | ||
*/ | ||
public function __construct( | ||
Data $adyenHelper | ||
) { | ||
$this->adyenHelper = $adyenHelper; | ||
} | ||
|
||
/** | ||
* @param Context $context | ||
* @inheritDoc | ||
*/ | ||
public function resolve( | ||
Field $field, | ||
$context, | ||
ResolveInfo $info, | ||
array $value = null, | ||
array $args = null | ||
): ?string { | ||
/** @var StoreInterface $store */ | ||
$store = $context->getExtensionAttributes()->getStore(); | ||
return $this->adyenHelper->getStoreLocale((int)$store->getId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment module (https://www.adyen.com/) | ||
* | ||
* Copyright (c) 2024 Adyen N.V. (https://www.adyen.com/) | ||
* See LICENSE.txt for license details. | ||
* | ||
* Author: Adyen <[email protected]> | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Adyen\Payment\Test\Unit\Model\Resolver\StoreConfig; | ||
|
||
use Adyen\Payment\Helper\Data; | ||
use Adyen\Payment\Model\Resolver\StoreConfig\StoreLocale; | ||
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase; | ||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Magento\GraphQl\Model\Query\Context; | ||
use Magento\GraphQl\Model\Query\ContextExtensionInterface; | ||
use Magento\Store\Model\Store; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
|
||
/** | ||
* @coversDefaultClass \Adyen\Payment\Model\Resolver\StoreConfig\StoreLocale | ||
*/ | ||
class StoreLocaleTest extends AbstractAdyenTestCase | ||
{ | ||
private MockObject&Context $contextMock; | ||
private MockObject&Field $fieldMock; | ||
private MockObject&ResolveInfo $infoMock; | ||
private MockObject&Data $dataHelperMock; | ||
private MockObject&ContextExtensionInterface $contextExtensionMock; | ||
private StoreLocale $storeLocale; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->contextExtensionMock = $this->createGeneratedMock( | ||
ContextExtensionInterface::class, | ||
['getStore'] | ||
); | ||
|
||
$this->contextMock = $this->getMockBuilder(Context::class) | ||
->disableOriginalConstructor() | ||
->onlyMethods(['getExtensionAttributes']) | ||
->getMock(); | ||
|
||
$this->fieldMock = $this->createMock(Field::class); | ||
$this->infoMock = $this->createMock(ResolveInfo::class); | ||
|
||
$this->dataHelperMock = $this->getMockBuilder(Data::class) | ||
->disableOriginalConstructor() | ||
->onlyMethods(['getStoreLocale']) | ||
->getMock(); | ||
|
||
$this->storeLocale = new StoreLocale($this->dataHelperMock); | ||
} | ||
|
||
/** | ||
* @return void | ||
* @throws \Exception | ||
* @covers ::resolve | ||
*/ | ||
public function testGetStoreLocale(): void | ||
{ | ||
$storeMock = $this->createConfiguredMock(Store::class, [ | ||
'getId' => 1, | ||
]); | ||
|
||
$this->contextExtensionMock | ||
->expects($this->once()) | ||
->method('getStore') | ||
->willReturn($storeMock); | ||
|
||
$this->contextMock | ||
->expects($this->once()) | ||
->method('getExtensionAttributes') | ||
->willReturn($this->contextExtensionMock); | ||
|
||
$this->dataHelperMock | ||
->expects($this->once()) | ||
->method('getStoreLocale') | ||
->willReturn('fr_FR'); | ||
|
||
$this->assertEquals( | ||
'fr_FR', | ||
$this->storeLocale->resolve($this->fieldMock, $this->contextMock, $this->infoMock, [], []) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.