diff --git a/tests/PHPUnit/ApiClient/Factory/AmountFactoryTest.php b/tests/PHPUnit/ApiClient/Factory/AmountFactoryTest.php index a8b375a73..c24abfa70 100644 --- a/tests/PHPUnit/ApiClient/Factory/AmountFactoryTest.php +++ b/tests/PHPUnit/ApiClient/Factory/AmountFactoryTest.php @@ -6,6 +6,7 @@ namespace WooCommerce\PayPalCommerce\ApiClient\Factory; use WooCommerce\PayPalCommerce\ApiClient\Entity\Item; use WooCommerce\PayPalCommerce\ApiClient\Entity\Money; use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException; +use WooCommerce\PayPalCommerce\Helper\CurrencyGetterStub; use WooCommerce\PayPalCommerce\TestCase; use Mockery; use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; @@ -15,6 +16,7 @@ use function Brain\Monkey\Functions\when; class AmountFactoryTest extends TestCase { private $currency = 'EUR'; + private $currencyGetter; private $itemFactory; private $moneyFactory; @@ -26,7 +28,8 @@ class AmountFactoryTest extends TestCase $this->itemFactory = Mockery::mock(ItemFactory::class); $this->moneyFactory = new MoneyFactory(); - $this->testee = new AmountFactory($this->itemFactory, $this->moneyFactory, $this->currency); + $this->currencyGetter = new CurrencyGetterStub($this->currency); + $this->testee = new AmountFactory($this->itemFactory, $this->moneyFactory, $this->currencyGetter); } public function testFromWcCartDefault() diff --git a/tests/PHPUnit/ApiClient/Factory/ItemFactoryTest.php b/tests/PHPUnit/ApiClient/Factory/ItemFactoryTest.php index 65d41e881..53f7a23c7 100644 --- a/tests/PHPUnit/ApiClient/Factory/ItemFactoryTest.php +++ b/tests/PHPUnit/ApiClient/Factory/ItemFactoryTest.php @@ -5,6 +5,7 @@ namespace WooCommerce\PayPalCommerce\ApiClient\Factory; use WooCommerce\PayPalCommerce\ApiClient\Entity\Item; use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException; +use WooCommerce\PayPalCommerce\Helper\CurrencyGetterStub; use WooCommerce\PayPalCommerce\TestCase; use function Brain\Monkey\Functions\expect; use function Brain\Monkey\Functions\when; @@ -12,9 +13,16 @@ use Mockery; class ItemFactoryTest extends TestCase { - private $currency = 'EUR'; + private $currency; - public function testFromCartDefault() + public function setUp(): void + { + parent::setUp(); + + $this->currency = new CurrencyGetterStub(); + } + + public function testFromCartDefault() { $testee = new ItemFactory($this->currency); @@ -169,7 +177,7 @@ class ItemFactoryTest extends TestCase $order = Mockery::mock(\WC_Order::class); $order ->expects('get_currency') - ->andReturn($this->currency); + ->andReturn($this->currency->get()); $order ->expects('get_items') ->andReturn([$item]); @@ -228,7 +236,7 @@ class ItemFactoryTest extends TestCase $order = Mockery::mock(\WC_Order::class); $order ->expects('get_currency') - ->andReturn($this->currency); + ->andReturn($this->currency->get()); $order ->expects('get_items') ->andReturn([$item]); @@ -357,7 +365,7 @@ class ItemFactoryTest extends TestCase 'quantity' => 1, 'unit_amount' => (object) [ 'value' => 1, - 'currency_code' => $this->currency, + 'currency_code' => $this->currency->get(), ], 'category' => Item::DIGITAL_GOODS, ]; diff --git a/tests/PHPUnit/Helper/CurrencyGetterStub.php b/tests/PHPUnit/Helper/CurrencyGetterStub.php new file mode 100644 index 000000000..46eb892e1 --- /dev/null +++ b/tests/PHPUnit/Helper/CurrencyGetterStub.php @@ -0,0 +1,21 @@ +currency = $currency; + } + + public function get(): string + { + return $this->currency; + } +} diff --git a/tests/PHPUnit/WcGateway/Assets/SettingsPagesAssetsTest.php b/tests/PHPUnit/WcGateway/Assets/SettingsPagesAssetsTest.php index 931c55fcf..5bb29b95a 100644 --- a/tests/PHPUnit/WcGateway/Assets/SettingsPagesAssetsTest.php +++ b/tests/PHPUnit/WcGateway/Assets/SettingsPagesAssetsTest.php @@ -4,6 +4,7 @@ namespace WooCommerce\PayPalCommerce\WcGateway\Assets; use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\BillingAgreementsEndpoint; +use WooCommerce\PayPalCommerce\Helper\CurrencyGetterStub; use WooCommerce\PayPalCommerce\Onboarding\Environment; use WooCommerce\PayPalCommerce\WcSubscriptions\Helper\SubscriptionHelper; use WooCommerce\PayPalCommerce\TestCase; @@ -25,7 +26,7 @@ class SettingsPagesAssetsTest extends TestCase $modulePath, $subscriptionsHelper, '123', - 'EUR', + new CurrencyGetterStub(), 'DE', Mockery::mock(Environment::class), true,