-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue Preventing Checkout with Configurable Products in Low Stock (#62)
* #59 Configuration provider * Formatting * Write unit tests * Fix unit tests --------- Co-authored-by: Sushmita Thakur <[email protected]> Co-authored-by: Khushboo <[email protected]> Co-authored-by: Can Demiralp <[email protected]> Co-authored-by: Can Demiralp <[email protected]>
- Loading branch information
1 parent
e318ec2
commit 11e6f49
Showing
5 changed files
with
122 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Adyen\Hyva\Model; | ||
|
||
use Magento\Checkout\Model\ConfigProviderInterface; | ||
class CompositeConfigProvider implements ConfigProviderInterface | ||
{ | ||
/** | ||
* @param array $configProviders | ||
*/ | ||
public function __construct( | ||
private readonly array $configProviders | ||
) { } | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getConfig(): array | ||
{ | ||
$config = []; | ||
|
||
foreach ($this->configProviders as $configProvider) { | ||
$config = array_merge_recursive($config, $configProvider->getConfig()); | ||
} | ||
|
||
return $config; | ||
} | ||
} |
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,65 @@ | ||
<?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]> | ||
*/ | ||
|
||
namespace Adyen\Hyva\Test\Unit\Model; | ||
|
||
use Adyen\Hyva\Model\CompositeConfigProvider; | ||
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase; | ||
use Magento\Checkout\Model\ConfigProviderInterface; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
|
||
class CompositeConfigProviderTest extends AbstractAdyenTestCase | ||
{ | ||
protected ?CompositeConfigProvider $compositeConfigProvider; | ||
protected MockObject|array $configProvidersMock; | ||
protected MockObject|ConfigProviderInterface $singleConfigProviderMock; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->singleConfigProviderMock = $this->createMock(ConfigProviderInterface::class); | ||
$this->configProvidersMock[] = $this->singleConfigProviderMock; | ||
|
||
$this->compositeConfigProvider = new CompositeConfigProvider($this->configProvidersMock); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function tearDown(): void | ||
{ | ||
$this->compositeConfigProvider = null; | ||
} | ||
|
||
/** | ||
* Test case to assert all available config values provided through di.xml | ||
* | ||
* @return void | ||
*/ | ||
public function testGetConfig() | ||
{ | ||
$configMock = [ | ||
'config1' => 'value1', | ||
'config2' => 'value2' | ||
]; | ||
|
||
$this->singleConfigProviderMock->expects($this->once()) | ||
->method('getConfig') | ||
->willReturn($configMock); | ||
|
||
$result = $this->compositeConfigProvider->getConfig(); | ||
$this->assertEquals($configMock, $result); | ||
} | ||
} |
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