init
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\OceanpaymentKlarna\Test\Unit\Model;
|
||||
|
||||
use Esun\OceanpaymentKlarna\Model\Config;
|
||||
use Esun\OceanpaymentKlarna\Model\SecretValueDecoder;
|
||||
use Magento\Framework\App\Config\ScopeConfigInterface;
|
||||
use Magento\Store\Model\ScopeInterface;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class EnvironmentCredentialsTest extends TestCase
|
||||
{
|
||||
public static function environmentProvider(): array
|
||||
{
|
||||
return [
|
||||
'sandbox' => [true, 'sandbox_account', 'sandbox-value'],
|
||||
'production' => [false, 'production_account', 'production-value'],
|
||||
];
|
||||
}
|
||||
|
||||
#[DataProvider('environmentProvider')]
|
||||
public function testSelectsCredentialsForTheActiveEnvironment(
|
||||
bool $sandbox,
|
||||
string $field,
|
||||
string $expected
|
||||
): void {
|
||||
$scopeConfig = $this->createMock(ScopeConfigInterface::class);
|
||||
$scopeConfig->method('isSetFlag')
|
||||
->with(
|
||||
'payment/' . Config::METHOD_CODE . '/sandbox',
|
||||
ScopeInterface::SCOPE_STORE,
|
||||
1
|
||||
)
|
||||
->willReturn($sandbox);
|
||||
$scopeConfig->method('getValue')
|
||||
->with(
|
||||
'payment/' . Config::METHOD_CODE . '/' . $field,
|
||||
ScopeInterface::SCOPE_STORE,
|
||||
1
|
||||
)
|
||||
->willReturn($expected);
|
||||
|
||||
$config = new Config(
|
||||
$scopeConfig,
|
||||
new SecretValueDecoder($this->createMock(\Magento\Framework\Encryption\EncryptorInterface::class))
|
||||
);
|
||||
|
||||
self::assertSame($expected, $config->getSecret('account', 1));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user