Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing test for default-parameter "currency" #12

Open
prilka opened this issue Aug 15, 2018 · 2 comments
Open

Failing test for default-parameter "currency" #12

prilka opened this issue Aug 15, 2018 · 2 comments

Comments

@prilka
Copy link

prilka commented Aug 15, 2018

This assertion in GatewayTestCase::testDefaultParametersHaveMatchingMethods() will fail for the parameter currency

$this->assertSame($value, $this->gateway->$getter());

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
Copy link
Member

judgej commented Aug 15, 2018

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:

thephpleague/omnipay-common#192 (comment)

@prilka
Copy link
Author

prilka commented Aug 15, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants