Skip to content

Commit

Permalink
Fix tests namespaces (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
rvitaliy authored Oct 30, 2020
1 parent 9118cce commit 4353c4a
Show file tree
Hide file tree
Showing 37 changed files with 266 additions and 334 deletions.
12 changes: 11 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,20 @@

<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/sebastianbergmann/phpunit/8.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="tests/bootstrap.php"
colors="true"
>
<php>
<ini name="display_errors" value="On"/>
<ini name="memory_limit" value="-1"/>
<ini name="max_execution_time" value="0"/>
<ini name="display_startup_errors" value="On"/>
<ini name="error_reporting" value="E_ALL"/>
<ini name="date.timezone" value="UTC"/>
<server name="SHELL_VERBOSITY" value="-1"/>
</php>

<testsuites>
<testsuite name="unit">
<directory>./tests/Unit</directory>
Expand Down
10 changes: 5 additions & 5 deletions tests/Integration/BinLookupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
*
*/

namespace Adyen\Integration;
namespace Adyen\Tests\Integration;

use Adyen\TestCase;
use Adyen\Service;
use Adyen\Service\BinLookup;
use Adyen\Tests\TestCase;

class BinLookupTest extends TestCase
{
Expand All @@ -34,7 +34,7 @@ public function testValid3dsCard()
$client = $this->createClient();

// initialize service
$service = new Service\BinLookup($client);
$service = new BinLookup($client);

$json = '{
"cardNumber": "5454545454545454",
Expand All @@ -57,7 +57,7 @@ public function testInvalid3dsCard()
$client = $this->createClient();

// initialize service
$service = new Service\BinLookup($client);
$service = new BinLookup($client);

$json = '{
"cardNumber": "1111111111111111",
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Builder/AddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace Adyen\Tests\Integration\Builder;

use Adyen\Service\Builder\Address;
use Adyen\TestCase;
use Adyen\Tests\TestCase;

class AddressTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Builder/BrowserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace Adyen\Tests\Integration\Builder;

use Adyen\Service\Builder\Browser;
use Adyen\TestCase;
use Adyen\Tests\TestCase;

class BrowserTest extends TestCase
{
Expand Down
3 changes: 1 addition & 2 deletions tests/Integration/Builder/CustomerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
*
*/


namespace Adyen\Tests\Integration\Builder;

use Adyen\Service\Builder\Customer;
use Adyen\TestCase;
use Adyen\Tests\TestCase;

class CustomerTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Builder/OpenInvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace Adyen\Tests\Integration\Builder;

use Adyen\Service\Builder\OpenInvoice;
use Adyen\TestCase;
use Adyen\Tests\TestCase;

class OpenInvoiceTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Builder/PaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace Adyen\Tests\Integration\Builder;

use Adyen\Service\Builder\Payment;
use Adyen\TestCase;
use Adyen\Tests\TestCase;

class PaymentTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Builder/RefundTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace Adyen\Tests\Integration\Builder;

use Adyen\Service\Builder\Refund;
use Adyen\TestCase;
use Adyen\Tests\TestCase;

class RefundTest extends TestCase
{
Expand Down
14 changes: 7 additions & 7 deletions tests/Integration/CheckoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
*
*/

namespace Adyen\Integration;
namespace Adyen\Tests\Integration;

use Adyen\TestCase;
use Adyen\Service;
use Adyen\Service\Checkout;
use Adyen\Tests\TestCase;
use Adyen\Util\Uuid;

class CheckoutTest extends TestCase
Expand All @@ -45,7 +45,7 @@ public function testPaymentMethods()
{
$client = $this->createCheckoutAPIClient();

$service = new Service\Checkout($client);
$service = new Checkout($client);

$params = array(
'amount' => array(
Expand Down Expand Up @@ -76,7 +76,7 @@ public function testBlockedPaymentMethods()
{
$client = $this->createCheckoutAPIClient();

$service = new Service\Checkout($client);
$service = new Checkout($client);

$params = array(
'amount' => 1000,
Expand Down Expand Up @@ -106,7 +106,7 @@ public function testPaymentsSuccess()
$client = $this->createCheckoutAPIClient();

// initialize service
$service = new \Adyen\Service\Checkout($client);
$service = new Checkout($client);

$params = array(
'merchantAccount' => $this->merchantAccount,
Expand All @@ -133,7 +133,7 @@ public function testPaymentsSuccessWithIdempotencyKey()
$client = $this->createCheckoutAPIClient();

// initialize service
$service = new \Adyen\Service\Checkout($client);
$service = new Checkout($client);

$params = array(
'merchantAccount' => $this->merchantAccount,
Expand Down
22 changes: 8 additions & 14 deletions tests/Integration/CreatePaymentRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,11 @@
*
*/

namespace Adyen\Integration;
namespace Adyen\Tests\Integration;

use Adyen\TestCase;
use Adyen\Service;
use Adyen\Service\Payment;
use Adyen\Tests\TestCase;

/**
* Created by PhpStorm.
* User: rikt
* Date: 11/3/15
* Time: 10:27 AM
*/
class CreatePaymentRequestTest extends TestCase
{
public function testCreatePaymentSuccess()
Expand All @@ -40,7 +34,7 @@ public function testCreatePaymentSuccess()
$client = $this->createClient();

// initialize service
$service = new Service\Payment($client);
$service = new Payment($client);

$json = '{
"card": {
Expand Down Expand Up @@ -82,7 +76,7 @@ public function testCreatePaymentWithRecurringSuccess()
$client = $this->createClient();

// initialize service
$service = new Service\Payment($client);
$service = new Payment($client);

$json = '{
"amount": {
Expand Down Expand Up @@ -131,7 +125,7 @@ public function testCreatePaymentSuccessWithMerchantAccountInClient()
$client = $this->createClientWithMerchantAccount();

// initialize service
$service = new Service\Payment($client);
$service = new Payment($client);

$json = '{
"card": {
Expand Down Expand Up @@ -178,7 +172,7 @@ public function testCreatePaymentSuccessJson()
$this->assertEquals('json', $client->getConfig()->getOutputType());

// initialize service
$service = new Service\Payment($client);
$service = new Payment($client);

$json = '{
"card": {
Expand Down Expand Up @@ -226,7 +220,7 @@ public function testCreatePaymentWrongCvc()
$client = $this->createClient();

// initialize service
$service = new Service\Payment($client);
$service = new Payment($client);

$json = '{
"card": {
Expand Down
17 changes: 9 additions & 8 deletions tests/Integration/DirectoryLookupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
*
*/

namespace Adyen\Integration;
namespace Adyen\Tests\Integration;

use Adyen\TestCase;
use Adyen\Service;
use Adyen\AdyenException;
use Adyen\Service\DirectoryLookup;
use Adyen\Tests\TestCase;
use Adyen\Util\Util;

class DirectoryLookupTest extends TestCase
Expand All @@ -36,7 +37,7 @@ public function testDirectoryLookup()
$client = $this->createClient();

// initialize service
$service = new Service\DirectoryLookup($client);
$service = new DirectoryLookup($client);
$sessionValidity = date(
DATE_ATOM,
mktime(date("H") + 10, date("i"), date("s"), date("m"), date("j"), date("Y"))
Expand Down Expand Up @@ -86,15 +87,15 @@ public function testDirectoryLookupEmptyParameters()
$client = $this->createClient();

// initialize service
$service = new Service\DirectoryLookup($client);
$service = new DirectoryLookup($client);

$e = null;
try {
$result = $service->directoryLookup("");
} catch (\Exception $e) {
}

$this->assertEquals('Adyen\AdyenException', get_class($e));
$this->assertEquals(AdyenException::class, get_class($e));
$this->assertEquals("The parameters in the request are empty", $e->getMessage());
$this->assertEquals('0', $e->getCode());
}
Expand All @@ -106,7 +107,7 @@ public function testDirectoryLookupFailed()
$client = $this->createClient();

// initialize service
$service = new Service\DirectoryLookup($client);
$service = new DirectoryLookup($client);

$sessionValidity = date(
DATE_ATOM,
Expand Down Expand Up @@ -134,7 +135,7 @@ public function testDirectoryLookupFailed()
} catch (\Exception $e) {
}

$this->assertEquals('Adyen\AdyenException', get_class($e));
$this->assertEquals(AdyenException::class, get_class($e));
$this->assertEquals("The result is empty, looks like your request is invalid", $e->getMessage());
$this->assertEquals('0', $e->getCode());
}
Expand Down
39 changes: 18 additions & 21 deletions tests/Integration/ExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,33 @@
*
*/

/**
* Created by PhpStorm.
* User: rikt
* Date: 11/18/15
* Time: 12:01 PM
*/

namespace Adyen\Integration;
namespace Adyen\Tests\Integration;

use Adyen\TestCase;
use Adyen\Service;
use Adyen\AdyenException;
use Adyen\Client;
use Adyen\Contract;
use Adyen\Environment;
use Adyen\Service\Recurring;
use Adyen\Tests\TestCase;

class ExceptionTest extends \Adyen\TestCase
class ExceptionTest extends TestCase
{
public function testExceptionMissingEnvironmentValue()
{
$client = new \Adyen\Client();
$client = new Client();
$client->setApplicationName("My Test Application");
$client->setUsername('username');
$client->setPassword('password');
// do not set environment to test exception


try {
$service = new Service\Recurring($client);
$service = new Recurring($client);
} catch (\Exception $e) {
}

// should have environment exception
$this->assertEquals('Adyen\AdyenException', get_class($e));
$this->assertEquals(AdyenException::class, get_class($e));
$this->assertEquals('The Client does not have a correct environment, use test or live', $e->getMessage());
}

Expand All @@ -61,7 +58,7 @@ public function testExceptionMisspelledContractParameterValue()
$client = $this->createClient();

// initialize service
$service = new Service\Recurring($client);
$service = new Recurring($client);

$recurring = array('contract' => "WRONG PARAMETER");
$params = array(
Expand All @@ -76,25 +73,25 @@ public function testExceptionMisspelledContractParameterValue()
}

// check if exception is correct
$this->assertEquals('Adyen\AdyenException', get_class($e));
$this->assertEquals(AdyenException::class, get_class($e));
$this->assertEquals('Invalid contract', $e->getMessage());
$this->assertEquals('802', $e->getCode());
}

public function testExceptionMissingUsernamePassword()
{
// initialize client
$client = new \Adyen\Client();
$client = new Client();
$client->setApplicationName("Adyen PHP Api Library");
$client->setUsername("");
$client->setPassword("");
$client->setEnvironment(\Adyen\Environment::TEST);
$client->setEnvironment(Environment::TEST);

// initialize service
$service = new Service\Recurring($client);
$service = new Recurring($client);

// in a model form ?
$recurring = array('contract' => \Adyen\Contract::RECURRING);
$recurring = array('contract' => Contract::RECURRING);
$params = array(
'merchantAccount' => $this->getMerchantAccount(),
'recurring' => $recurring,
Expand All @@ -108,7 +105,7 @@ public function testExceptionMissingUsernamePassword()
}

// check if exception is correct
$this->assertEquals('Adyen\AdyenException', get_class($e));
$this->assertEquals(AdyenException::class, get_class($e));
$this->assertEquals("HTTP Status Response - Unauthorized", $e->getMessage());
$this->assertEquals('0', $e->getCode());
$this->assertEquals('401', $e->getStatus());
Expand Down
Loading

0 comments on commit 4353c4a

Please sign in to comment.