This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -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));
}
}