From 3290871453cecf16c12771f1fc9c6f66f8920a8e Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Wed, 8 May 2019 20:36:29 +0200 Subject: [PATCH] Added a few basic tests for all payment methods --- Tests/Unit/Model/Methods/AbstractMethodTest.php | 15 ++++++++++----- Tests/Unit/Model/Methods/ApplePayTest.php | 2 +- Tests/Unit/Model/Methods/BancontactTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/BanktransferTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/BelfiusTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/CreditcardTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/EpsTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/GiftcardTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/GiropayTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/IdealTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/InghomepayTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/KbcTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/KlarnapaylaterTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/KlarnasliceitTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/PaymentlinkTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/PaypalTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/PaysafecardTest.php | 12 ++++++++++++ Tests/Unit/Model/Methods/Przelewy24Test.php | 12 ++++++++++++ Tests/Unit/Model/Methods/SofortTest.php | 12 ++++++++++++ 19 files changed, 215 insertions(+), 6 deletions(-) create mode 100644 Tests/Unit/Model/Methods/BancontactTest.php create mode 100644 Tests/Unit/Model/Methods/BanktransferTest.php create mode 100644 Tests/Unit/Model/Methods/BelfiusTest.php create mode 100644 Tests/Unit/Model/Methods/CreditcardTest.php create mode 100644 Tests/Unit/Model/Methods/EpsTest.php create mode 100644 Tests/Unit/Model/Methods/GiftcardTest.php create mode 100644 Tests/Unit/Model/Methods/GiropayTest.php create mode 100644 Tests/Unit/Model/Methods/IdealTest.php create mode 100644 Tests/Unit/Model/Methods/InghomepayTest.php create mode 100644 Tests/Unit/Model/Methods/KbcTest.php create mode 100644 Tests/Unit/Model/Methods/KlarnapaylaterTest.php create mode 100644 Tests/Unit/Model/Methods/KlarnasliceitTest.php create mode 100644 Tests/Unit/Model/Methods/PaymentlinkTest.php create mode 100644 Tests/Unit/Model/Methods/PaypalTest.php create mode 100644 Tests/Unit/Model/Methods/PaysafecardTest.php create mode 100644 Tests/Unit/Model/Methods/Przelewy24Test.php create mode 100644 Tests/Unit/Model/Methods/SofortTest.php diff --git a/Tests/Unit/Model/Methods/AbstractMethodTest.php b/Tests/Unit/Model/Methods/AbstractMethodTest.php index 62335ec40bf..05473765f0c 100644 --- a/Tests/Unit/Model/Methods/AbstractMethodTest.php +++ b/Tests/Unit/Model/Methods/AbstractMethodTest.php @@ -7,7 +7,6 @@ use Mollie\Api\Resources\Method; use Mollie\Api\Endpoints\MethodEndpoint; use Mollie\Api\Resources\MethodCollection; -use Mollie\Payment\Model\Methods\ApplePay; use Mollie\Payment\Model\MollieConfigProvider; use Mollie\Payment\Helper\General as MollieHelper; use Magento\Framework\App\Config\ScopeConfigInterface; @@ -53,7 +52,7 @@ public function testHasTheCorrectCode() $reflection = new \ReflectionClass($this->instance); $instance = $reflection->newInstanceWithoutConstructor(); - $this->assertEquals($this->code, $instance->getCode()); + $this->assertEquals('mollie_methods_' . $this->code, $instance->getCode()); } public function testIsListedAsActiveMethod() @@ -72,14 +71,19 @@ public function testIsListedAsActiveMethod() $methods = $helper->getAllActiveMethods(1); - $this->assertArrayHasKey($this->code, $methods); + if ($this->code == 'paymentlink') { + $this->assertArrayNotHasKey('mollie_methods_' . $this->code, $methods); + return; + } + + $this->assertArrayHasKey('mollie_methods_' . $this->code, $methods); } public function testThatTheMethodIsActive() { /** @var Method $method */ $method = $this->objectManager->getObject(Method::class); - $method->id = 'applepay'; + $method->id = $this->code; $method->image = new \stdClass; $method->image->size2x = 'http://www.example.com/image.png'; @@ -95,6 +99,7 @@ public function testThatTheMethodIsActive() $instance = $this->objectManager->getObject(MollieConfigProvider::class); $methods = $instance->getActiveMethods($mollieApiClient); - $this->assertArrayHasKey($this->code, $methods); + $this->assertArrayHasKey('mollie_methods_' . $this->code, $methods); + $this->assertEquals($method->image->size2x, $methods['mollie_methods_' . $this->code]['image']); } } \ No newline at end of file diff --git a/Tests/Unit/Model/Methods/ApplePayTest.php b/Tests/Unit/Model/Methods/ApplePayTest.php index 27398b5129c..be490ea1227 100644 --- a/Tests/Unit/Model/Methods/ApplePayTest.php +++ b/Tests/Unit/Model/Methods/ApplePayTest.php @@ -11,7 +11,7 @@ class ApplePayTest extends AbstractMethodTest { protected $instance = ApplePay::class; - protected $code = 'mollie_methods_applepay'; + protected $code = 'applepay'; public function testTheIncludeWalletsParameterIsUsed() { diff --git a/Tests/Unit/Model/Methods/BancontactTest.php b/Tests/Unit/Model/Methods/BancontactTest.php new file mode 100644 index 00000000000..2bc03c7f25e --- /dev/null +++ b/Tests/Unit/Model/Methods/BancontactTest.php @@ -0,0 +1,12 @@ +