thephpleague / omnipay-tests

Test components for the Omnipay PHP payment processing library
MIT License
10 stars 35 forks source link

Failing test for default-parameter "currency" #12

Open prilka opened 6 years ago

prilka commented 6 years ago

This assertion in GatewayTestCase::testDefaultParametersHaveMatchingMethods() will fail for the parameter currency https://github.com/thephpleague/omnipay-tests/blob/599d41855be3c284e37417215add14426363491e/src/GatewayTestCase.php#L51

The reason is the strtoupper() in AbstractGateway::getCurrency()

The message will look like this

1) Omnipay\Tests\Foo\GatewayTest::testDefaultParametersHaveMatchingMethods
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'5b73ed8edf6e5'
+'5B73ED8EDF6E5'

To reproduce this, simply create a gateway with the key currency in his getDefaultParameters()-Result.

    public function getDefaultParameters()
    {
        return [
            'currency' => 'EUR',
        ];
    }
judgej commented 6 years ago

I encountered this too, with my own default parameters that used a getter that manipulates what it returns. The currency happens to be a built-in example, but it's not the only one. The short-term solution will be to remove the currency from the list of default values, which I realise is not ideal.

Ah, here we go, mentioned along with a related issue with default parameters (they bypass the validate() checks:

https://github.com/thephpleague/omnipay-common/issues/192#issuecomment-407334382

prilka commented 6 years ago

I implemented a similar solution only in my tests. But it's a pain to override all the buggy core-tests. In my opinion, the tests make no sense inside the base class.