Commit 52b17c07 authored by Rik ter Beek's avatar Rik ter Beek

Use strpos so we can remove length check added test cases in magento convention

parent 4a4f0e48
......@@ -5,6 +5,6 @@
**Tested scenarios**
<!-- Description of tested scenarios -->
<!-- Please verify that the unit tests are passing by running "vendor/bin/phpunit -c ." -->
<!-- Please verify that the unit tests are passing by running "vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist vendor/adyen/module-payment/Test/" -->
**Fixed issue**: <!-- #-prefixed issue number -->
\ No newline at end of file
......@@ -847,11 +847,13 @@ class Data extends AbstractHelper
*/
public function isPaymentMethodOpenInvoiceMethod($paymentMethod)
{
if (strlen($paymentMethod) >= 9 && substr($paymentMethod, 0, 9) == 'afterpay_') {
echo strpos($paymentMethod, 'klarna');
if (strpos($paymentMethod, 'afterpay') !== false) {
return true;
} elseif (strlen($paymentMethod) >= 6 && substr($paymentMethod, 0, 6) == 'klarna') {
} elseif (strpos($paymentMethod, 'klarna') !== false) {
return true;
} elseif (strlen($paymentMethod) >= 7 && substr($paymentMethod, 0, 7) == 'ratepay') {
} elseif (strpos($paymentMethod, 'ratepay') !== false) {
return true;
}
......
......@@ -24,9 +24,8 @@
namespace Adyen\Payment\Tests\Helper;
use Adyen\Payment\Helper\Data;
use PHPUnit\Framework\TestCase;
class DataTest extends TestCase
class DataTest extends \PHPUnit_Framework_TestCase
{
private $dataHelper;
......@@ -59,4 +58,16 @@ class DataTest extends TestCase
$this->assertEquals("1200", $this->dataHelper->formatAmount("12.00", "USD"));
$this->assertEquals("12", $this->dataHelper->formatAmount("12.00", "JPY"));
}
public function testisPaymentMethodOpenInvoiceMethod()
{
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod("klarna"));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod("klarna_account"));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod("afterpay"));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod("afterpay_default"));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod("ratepay"));
$this->assertEquals(false, $this->dataHelper->isPaymentMethodOpenInvoiceMethod("ideal"));
$this->assertEquals(true, $this->dataHelper->isPaymentMethodOpenInvoiceMethod("test_klarna"));
}
}
......@@ -17,9 +17,6 @@
"adyen/php-api-library": "*",
"magento/framework": ">=100.1.0"
},
"require-dev": {
"phpunit/phpunit": "~5"
},
"autoload": {
"files": [
"registration.php"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment