Skip to content

Commit

Permalink
Gopay - remote authentication, test localizing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenekdrahos committed Sep 23, 2015
1 parent d464e39 commit e499462
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/nbproject/
/bin/
!/bin/jenkins.sh
/var/
/var/
/phpunit.xml
6 changes: 6 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@
</testsuite>
</testsuites>

<php>
<env name="goid" value="" />
<env name="clientId" value="" />
<env name="clientSecret" value="" />
</php>

</phpunit>
49 changes: 49 additions & 0 deletions tests/remote/RemoteApiTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace GoPay;

use GoPay\Definition\Language;
use GoPay\Definition\TokenScope;

class RemoteApiTest extends \PHPUnit_Framework_TestCase
{
/** @dataProvider provideLanguage */
public function testErrorIsLocalized($language, $expectedError)
{
$gopay = $this->givenGopay([
'clientSecret' => 'invalid secret',
'language' => $language
]);
$response = $gopay->getStatus('payment id');
assertThat($response->hasSucceed(), is(false));
assertThat($response->statusCode, is(403));
assertThat($response->json['errors'][0], identicalTo([
'scope' => 'G',
'field' => null,
'error_code' => 202,
'error_name' => 'AUTH_WRONG_CREDENTIALS',
'message' => $expectedError,
'description' => null
]));
}

public function provideLanguage()
{
return [
[Language::CZECH, 'Chybné přihlašovací údaje. Pokuste se provést přihlášení znovu.'],
[Language::RUSSIAN, 'Wrong credentials. Try sign in again.']
];
}

private function givenGopay(array $userConfig = [])
{
return payments($userConfig + [
'goid' => getenv('goid'),
'clientId' => getenv('clientId'),
'clientSecret' => getenv('clientSecret'),
'isProductionMode' => false,
'scope' => TokenScope::ALL,
'language' => Language::CZECH
]);
}
}

0 comments on commit e499462

Please sign in to comment.