From cc78a17666a41dee783d67bfd74f24e674cbbb89 Mon Sep 17 00:00:00 2001 From: Gaurav Malhotra Date: Tue, 20 Aug 2019 22:17:28 +0100 Subject: [PATCH] Added in fix to complete coverages (#16) * Railsbank config test * Railsbank test and configuration test * No mode test * Added in Railsbank command test --- config/railsbank.config.php | 1 + src/ConfigServiceFactory.php | 9 +- src/Exception/InvalidConfigException.php | 2 +- ...RailsbankConfigurationMissingException.php | 4 +- src/Query/Me/PHPVersion.php | 19 ++ src/Query/Version/GetVersion.php | 2 +- src/QueryHandler/Me/PHPVersionHandler.php | 24 ++ .../Version/GetVersionHandler.php | 8 +- src/Railsbank.php | 2 +- src/RailsbankConfig.php | 12 +- tests/CommandOrQueryTest.php | 8 +- .../Transaction/DetailedTransactionTest.php | 116 ++++----- tests/Entity/Transaction/TransactionTest.php | 239 +++++++++++++++++- tests/Query/Me/InformationTest.php | 1 + tests/Query/Me/PHPVersionTest.php | 25 ++ ...InformationTest.php => GetVersionTest.php} | 1 + tests/RailsbankTest.php | 52 ++++ tests/configtest/emptyarrayconfig.php | 3 + tests/configtest/emptyconfig.php | 0 tests/configtest/nomode.php | 11 + tests/configtest/validconfig.php | 20 ++ 21 files changed, 474 insertions(+), 85 deletions(-) create mode 100644 src/Query/Me/PHPVersion.php create mode 100644 src/QueryHandler/Me/PHPVersionHandler.php create mode 100644 tests/Query/Me/PHPVersionTest.php rename tests/Query/Version/{InformationTest.php => GetVersionTest.php} (95%) create mode 100644 tests/RailsbankTest.php create mode 100644 tests/configtest/emptyarrayconfig.php create mode 100644 tests/configtest/emptyconfig.php create mode 100644 tests/configtest/nomode.php create mode 100644 tests/configtest/validconfig.php diff --git a/config/railsbank.config.php b/config/railsbank.config.php index 2026d0d..bd0bbe5 100644 --- a/config/railsbank.config.php +++ b/config/railsbank.config.php @@ -31,6 +31,7 @@ 'commands' => [ Query\Version\GetVersion::class => QueryHandler\Version\GetVersionHandler::class, Query\Me\Information::class => QueryHandler\Me\InformationHandler::class, + Query\Me\PHPVersion::class => QueryHandler\Me\PHPVersionHandler::class, Query\Customer\GetLedger::class => QueryHandler\Customer\GetLedgerHandler::class, Query\Customer\GetLedgers::class => QueryHandler\Customer\GetLedgersHandler::class, Query\Customer\GetEndusers::class => QueryHandler\Customer\GetEndusersHandler::class, diff --git a/src/ConfigServiceFactory.php b/src/ConfigServiceFactory.php index 680bdbd..fddcd58 100644 --- a/src/ConfigServiceFactory.php +++ b/src/ConfigServiceFactory.php @@ -65,9 +65,8 @@ public function getConfigService() :? Config private function validateConfig(Config $config) :? bool { $railsbankConfigValidator = new RailsbankConfigValidator(); - return $railsbankConfigValidator->validateConfig( - $this->getRailsbankConfiguration($config) - ); + $railsbankConfig = $this->getRailsbankConfiguration($config); + return $railsbankConfigValidator->validateConfig($railsbankConfig); } /** @@ -78,10 +77,10 @@ private function validateConfig(Config $config) :? bool */ private function getRailsbankConfiguration(Config $config) :? Config { - if (! $config = $config->offsetGet('railsbank_configuration')) { + if (! $config->offsetExists('railsbank_configuration')) { throw new RailsbankConfigurationMissingException(); } - return $config; + return $config->offsetGet('railsbank_configuration'); } } diff --git a/src/Exception/InvalidConfigException.php b/src/Exception/InvalidConfigException.php index f417c94..f03031d 100644 --- a/src/Exception/InvalidConfigException.php +++ b/src/Exception/InvalidConfigException.php @@ -6,6 +6,6 @@ class InvalidConfigException extends \Exception { public function __construct() { - parent::__construct('Configuration not valid, refer to documentation', 500); + parent::__construct('Configuration not valid, refer to documentation.', 500); } } diff --git a/src/Exception/RailsbankConfigurationMissingException.php b/src/Exception/RailsbankConfigurationMissingException.php index 4daf736..5b5ea07 100644 --- a/src/Exception/RailsbankConfigurationMissingException.php +++ b/src/Exception/RailsbankConfigurationMissingException.php @@ -2,8 +2,6 @@ namespace Railsbank\Exception; -use Throwable; - class RailsbankConfigurationMissingException extends \Exception { public function __construct($key = "") @@ -11,7 +9,7 @@ public function __construct($key = "") $message = 'Railsbank configuration missing, refer to documentation.'; if ($key !== '') { - $message .= ' Key and/or value missing=' . $key; + $message .= ' Key and/or value missing=' . $key . ' or all mode configuration are missing'; } parent::__construct($message, 500); diff --git a/src/Query/Me/PHPVersion.php b/src/Query/Me/PHPVersion.php new file mode 100644 index 0000000..5237819 --- /dev/null +++ b/src/Query/Me/PHPVersion.php @@ -0,0 +1,19 @@ +getRailsbankConfig()); - - try { - $version = $client->handleApiCall($command); - } catch (\Exception $e) { - // handle exceptions - } - + $version = $client->handleApiCall($command); return $version; } } diff --git a/src/Railsbank.php b/src/Railsbank.php index fd90630..01ce845 100644 --- a/src/Railsbank.php +++ b/src/Railsbank.php @@ -49,7 +49,7 @@ public function __construct(string $configFile = '', string $mode = 'play') private function getConfiguration(string $configFile) { if (empty($configFile)) { - return []; + throw new InvalidConfigException(); } $config = require_once($configFile); diff --git a/src/RailsbankConfig.php b/src/RailsbankConfig.php index 85d566a..0367441 100644 --- a/src/RailsbankConfig.php +++ b/src/RailsbankConfig.php @@ -35,18 +35,20 @@ class RailsbankConfig */ public function __construct(array $config = [], string $mode = null) { + if ( !empty($mode)) { + $this->mode = $mode; + } + + $mode = $this->getMode(); + $configServiceFactory = new ConfigServiceFactory($config); $this->configService = $configServiceFactory->getConfigService(); /** @var Config $railsbankConfig */ $railsbankConfig = $this->configService->get('railsbank_configuration'); - if ( !empty($mode)) { - $this->mode = $mode; - } - /** @var Config railsbankConfig */ - $this->railsbankConfig = $railsbankConfig->get($this->getMode()); + $this->railsbankConfig = $railsbankConfig->get($mode); } public function getBaseConfig() : Config diff --git a/tests/CommandOrQueryTest.php b/tests/CommandOrQueryTest.php index 6d60d0c..4a2f04f 100644 --- a/tests/CommandOrQueryTest.php +++ b/tests/CommandOrQueryTest.php @@ -6,6 +6,9 @@ use Railsbank\CommandInterface; use PHPUnit\Framework\TestCase; use Railsbank\Command; +use Railsbank\RailsbankConfig; +use Zend\Config\Config; +use Zend\InputFilter\InputFilterInterface; abstract class CommandOrQueryTest extends TestCase implements CommandOrQueryTestInterface { @@ -25,11 +28,12 @@ public function testCommand($errorExpected = false, $input = [], $response = fal /** @var CommandInterface $command */ $command = new $this->command($input); - self::assertInstanceOf(Command::class, $command); - if ($response) { + if ($response || is_array($response)) { self::assertEquals($command->getBody(), $response); } + + self::assertInstanceOf(InputFilterInterface::class, $command->getInput()); } } diff --git a/tests/Entity/Transaction/DetailedTransactionTest.php b/tests/Entity/Transaction/DetailedTransactionTest.php index 87eb0e4..0dcf4b2 100644 --- a/tests/Entity/Transaction/DetailedTransactionTest.php +++ b/tests/Entity/Transaction/DetailedTransactionTest.php @@ -9,7 +9,7 @@ class DetailedTransactionTest extends TestCase { public function testDetailedTransaction() { - $response = array( + $response = [ 'settlement_date' => '2018-05-27', 'payment_type' => 'payment-type-EU-SEPA-Step2', 'transaction_type' => 'transaction-type-send', @@ -18,30 +18,30 @@ public function testDetailedTransaction() 'amount_beneficiary_account' => '0', 'partner_product_fx' => 'PayrNet-FX-1', 'card_rules_breached' => - array( + [ 0 => 'bb8b2428-f94c-41df-8e82-a895ab4d6ac8', 1 => '8763b5df-a61c-4f77-9724-41ca9cde3654', 2 => '8763b5df-a61c-4f77-9724-41ca9cde3654', - ), + ], 'payment_method' => 'swift', 'payment_info' => - array( + [ 'foo' => 'bar', - ), + ], 'return_info' => - array( + [ 'foo' => 'bar', - ), + ], 'transaction_status' => 'transaction-status-accepted', 'transaction_audit_number' => '122436', 'conversion_rate' => '1.69', 'point_of_sale_reference' => '000000001631', 'missing_data' => - array( + [ 0 => 'keyword', 1 => 'fooBar', 2 => 'fooBar', - ), + ], 'mcc_description' => 'Veterinary Services', 'ledger_to_id' => '8763b5df-a61c-4f77-9724-41ca9cde3654', 'card_expiry_date' => '07-19', @@ -53,37 +53,37 @@ public function testDetailedTransaction() 'additional_info' => 'T6105000019203927', 'merchantbank_id' => '012216', 'transaction_info' => - array( + [ 'ultimate_receiver' => - array( + [ 'issuer' => 'string', 'birth_country' => 'abcdefghijklmnopqrstuvwxyz', 'bic' => 'abcdefghijklmnopqrstuvwxyz', 'id' => 'string', 'name' => 'John Doe', 'address' => - array( + [ 'country' => 'GB', 'lines' => '27 Old Gloucester Street London', - ), + ], 'birth_date' => 'string', 'scheme_proprietary' => 'string', 'birth_city' => 'random sequence of characters', 'scheme' => 'string', 'birth_province' => 'abcdefghijklmnopqrstuvwxyz', - ), + ], 'settlement_date' => '2017-03-01', 'end_to_end_id' => 'NOTPROVIDED', 'instructed_agent' => - array( + [ 'bic' => 'SPSRSKBAXXX', - ), + ], 'purpose_category' => 'SALA', 'receiver_account' => - array( + [ 'iban' => 'SK4402005678901234567890', - ), + ], 'currency' => 'EUR', 'settlement_method' => 'CLRG', 'charge_bearer' => 'SLEV', @@ -92,94 +92,94 @@ public function testDetailedTransaction() 'service_level' => 'SEPA', 'clearing_system_proprietary' => 'string', 'receiver_agent' => - array( + [ 'bic' => 'SPSRSKBAXXX', - ), + ], 'local_instrument_proprietary' => 'string', 'receiver' => - array( + [ 'issuer' => 'string', 'birth_country' => 'string', 'bic' => 'abcdefghijklmnopqrstuvwxyz', 'id' => 'abcdefghijklmnopqrstuvwxyz', 'name' => 'John Doe', 'address' => - array( + [ 'country' => 'GB', 'lines' => '27 Old Gloucester Street London', - ), + ], 'birth_date' => 'random sequence of characters', 'scheme_proprietary' => 'string', 'birth_city' => 'abcdefghijklmnopqrstuvwxyz', 'scheme' => 'string', 'birth_province' => 'abcdefghijklmnopqrstuvwxyz', - ), + ], 'clearing_system' => 'abcdefghijklmnopqrstuvwxyz', 'sender_account' => - array( + [ 'iban' => 'SK4402005678901234567890', - ), + ], 'ultimate_sender' => - array( + [ 'issuer' => 'abcdefghijklmnopqrstuvwxyz', 'birth_country' => 'random sequence of characters', 'bic' => 'string', 'id' => 'abcdefghijklmnopqrstuvwxyz', 'name' => 'John Doe', 'address' => - array( + [ 'country' => 'GB', 'lines' => '27 Old Gloucester Street London', - ), + ], 'birth_date' => 'abcdefghijklmnopqrstuvwxyz', 'scheme_proprietary' => 'abcdefghijklmnopqrstuvwxyz', 'birth_city' => 'string', 'scheme' => 'string', 'birth_province' => 'string', - ), + ], 'settlement_account' => - array( + [ 'iban' => 'SK4402005678901234567890', - ), + ], 'instruction_id' => 'TEST-001-INSTR', 'amount' => '1.00', 'transaction_id' => 'TEST-001-TX', 'remittance_information_unstructured' => 'this is a test payment', 'created_at' => '2000-01-01T00:00:00.000Z', 'sender_agent' => - array( + [ 'bic' => 'SPSRSKBAXXX', - ), + ], 'message_schema' => 'pacs.008.001.02', 'sender' => - array( + [ 'name' => 'Sandy Sender', 'address' => - array( + [ 'country' => 'GB', 'lines' => 'Staveley Road London', - ), - ), + ], + ], 'instructing_agent' => - array( + [ 'bic' => 'SPSRSKBAXXX', - ), + ], 'purpose' => 'SALA', 'message_id' => 'TEST-001-MSG', - ), + ], 'reference' => 'this is a test payment', 'swift_service_level' => 'service-level-same-day-value', 'merchant_details' => 'PAYBYPHONE RE ST ALBAN HATFIELD GBR', 'amount' => '0', 'failure_reasons' => - array( + [ 0 => 'contact-support', 1 => 'partner-error', 2 => 'card-rules-breached', - ), + ], 'ledger_from_id' => '8763b5df-a61c-4f77-9724-41ca9cde3654', 'transaction_id' => 'bb8b2428-f94c-41df-8e82-a895ab4d6ac8', 'amount_ledger_from' => '0', @@ -190,51 +190,51 @@ public function testDetailedTransaction() 'conversion_date' => '2018-05-26', 'beneficiary_id' => 'bb8b2428-f94c-41df-8e82-a895ab4d6ac8', 'transaction_printout' => - array( + [ 'foo' => 'bar', - ), + ], 'daily_unique_refence' => 'MDSL2EKYF', 'asset_type' => 'eur', 'asset_class' => 'currency', 'swift_charge_bearer' => 'charge-bearer-shared', 'transaction_currency' => 'GBP', 'transaction_meta' => - array( + [ 'foo' => 'bar', - ), + ], 'rejection_reasons' => - array( + [ 0 => 'beneficiary-account-closed', 1 => 'beneficiary-sort-code-and-account-number-unknown', 2 => 'account-number-invalid', - ), + ], 'invoices' => - array( + [ 0 => - array( + [ 'created_at' => '2000-01-01T00:00:00.000Z', 'document_id' => 'c91b339e-57d7-41ea-a805-8966ce8fe4ed', 'description' => 'description', - ), + ], 1 => - array( + [ 'created_at' => '2000-01-01T00:00:00.000Z', 'document_id' => 'bb8b2428-f94c-41df-8e82-a895ab4d6ac8', 'description' => 'description', - ), + ], 2 => - array( + [ 'created_at' => '2000-01-01T00:00:00.000Z', 'document_id' => '753fa673-66b4-4c94-9ddb-f9f4b5c1e9a3', 'description' => 'description', - ), - ), + ], + ], 'merchant_id' => 'a1234567', 'point_of_sale_info' => '0001110000500826AL9', 'amount_local_currency' => '1.50', 'card_transaction_type' => 'Purchase', 'beneficiary_account_id' => '6630b391-c5ce-46c1-9d23-a82a9e27f82d', - ); + ]; $entity = new DetailedTransaction($response); diff --git a/tests/Entity/Transaction/TransactionTest.php b/tests/Entity/Transaction/TransactionTest.php index b991ce4..555e16d 100644 --- a/tests/Entity/Transaction/TransactionTest.php +++ b/tests/Entity/Transaction/TransactionTest.php @@ -3,6 +3,7 @@ namespace Test\Entity\Transaction; use PHPUnit\Framework\TestCase; +use Railsbank\Entity\Transaction\DetailedTransaction; use Railsbank\Entity\Transaction\Transaction; class TransactionTest extends TestCase @@ -14,7 +15,7 @@ public function testTransaction() 'ledger_entry_id' => '1233123-123123-21321', 'transaction_id' => '123123', 'amount' => '123.22', - 'ledger_entry_type' => 'cash', + 'ledger_entry_type' => 'credit', ]; $entity = new Transaction($response); @@ -23,6 +24,240 @@ public function testTransaction() self::assertEquals('1233123-123123-21321', $entity->getLedgerEntryId()); self::assertEquals('123123', $entity->getTransactionId()); self::assertEquals('123.22', $entity->getAmount()); - self::assertEquals('cash', $entity->getLedgerEntryType()); + self::assertEquals('credit', $entity->getLedgerEntryType()); + self::assertTrue($entity->isCredit()); + self::assertFalse($entity->isDebit()); + + $response = [ + 'settlement_date' => '2018-05-27', + 'payment_type' => 'payment-type-EU-SEPA-Step2', + 'transaction_type' => 'transaction-type-send', + 'card_currency' => 'USD', + 'receipt_id' => 'a12345678901234', + 'amount_beneficiary_account' => '0', + 'partner_product_fx' => 'PayrNet-FX-1', + 'card_rules_breached' => + [ + 0 => 'bb8b2428-f94c-41df-8e82-a895ab4d6ac8', + 1 => '8763b5df-a61c-4f77-9724-41ca9cde3654', + 2 => '8763b5df-a61c-4f77-9724-41ca9cde3654', + ], + 'payment_method' => 'swift', + 'payment_info' => + [ + 'foo' => 'bar', + ], + 'return_info' => + [ + 'foo' => 'bar', + ], + 'transaction_status' => 'transaction-status-accepted', + 'transaction_audit_number' => '122436', + 'conversion_rate' => '1.69', + 'point_of_sale_reference' => '000000001631', + 'missing_data' => + [ + 0 => 'keyword', + 1 => 'fooBar', + 2 => 'fooBar', + ], + 'mcc_description' => 'Veterinary Services', + 'ledger_to_id' => '8763b5df-a61c-4f77-9724-41ca9cde3654', + 'card_expiry_date' => '07-19', + 'fixed_side' => 'beneficiary', + 'merchant_category_code' => '7523', + 'point_of_sale_country_code' => 'GB', + 'transaction_fee' => '0', + 'card_used' => '454704641', + 'additional_info' => 'T6105000019203927', + 'merchantbank_id' => '012216', + 'transaction_info' => + [ + 'ultimate_receiver' => + [ + 'issuer' => 'string', + 'birth_country' => 'abcdefghijklmnopqrstuvwxyz', + 'bic' => 'abcdefghijklmnopqrstuvwxyz', + 'id' => 'string', + 'name' => 'John Doe', + 'address' => + [ + 'country' => 'GB', + 'lines' => '27 Old Gloucester Street +London', + ], + 'birth_date' => 'string', + 'scheme_proprietary' => 'string', + 'birth_city' => 'random sequence of characters', + 'scheme' => 'string', + 'birth_province' => 'abcdefghijklmnopqrstuvwxyz', + ], + 'settlement_date' => '2017-03-01', + 'end_to_end_id' => 'NOTPROVIDED', + 'instructed_agent' => + [ + 'bic' => 'SPSRSKBAXXX', + ], + 'purpose_category' => 'SALA', + 'receiver_account' => + [ + 'iban' => 'SK4402005678901234567890', + ], + 'currency' => 'EUR', + 'settlement_method' => 'CLRG', + 'charge_bearer' => 'SLEV', + 'purpose_category_proprietary' => 'string', + 'local_instrument' => 'string', + 'service_level' => 'SEPA', + 'clearing_system_proprietary' => 'string', + 'receiver_agent' => + [ + 'bic' => 'SPSRSKBAXXX', + ], + 'local_instrument_proprietary' => 'string', + 'receiver' => + [ + 'issuer' => 'string', + 'birth_country' => 'string', + 'bic' => 'abcdefghijklmnopqrstuvwxyz', + 'id' => 'abcdefghijklmnopqrstuvwxyz', + 'name' => 'John Doe', + 'address' => + [ + 'country' => 'GB', + 'lines' => '27 Old Gloucester Street +London', + ], + 'birth_date' => 'random sequence of characters', + 'scheme_proprietary' => 'string', + 'birth_city' => 'abcdefghijklmnopqrstuvwxyz', + 'scheme' => 'string', + 'birth_province' => 'abcdefghijklmnopqrstuvwxyz', + ], + 'clearing_system' => 'abcdefghijklmnopqrstuvwxyz', + 'sender_account' => + [ + 'iban' => 'SK4402005678901234567890', + ], + 'ultimate_sender' => + [ + 'issuer' => 'abcdefghijklmnopqrstuvwxyz', + 'birth_country' => 'random sequence of characters', + 'bic' => 'string', + 'id' => 'abcdefghijklmnopqrstuvwxyz', + 'name' => 'John Doe', + 'address' => + [ + 'country' => 'GB', + 'lines' => '27 Old Gloucester Street +London', + ], + 'birth_date' => 'abcdefghijklmnopqrstuvwxyz', + 'scheme_proprietary' => 'abcdefghijklmnopqrstuvwxyz', + 'birth_city' => 'string', + 'scheme' => 'string', + 'birth_province' => 'string', + ], + 'settlement_account' => + [ + 'iban' => 'SK4402005678901234567890', + ], + 'instruction_id' => 'TEST-001-INSTR', + 'amount' => '1.00', + 'transaction_id' => 'TEST-001-TX', + 'remittance_information_unstructured' => 'this is a test payment', + 'created_at' => '2000-01-01T00:00:00.000Z', + 'sender_agent' => + [ + 'bic' => 'SPSRSKBAXXX', + ], + 'message_schema' => 'pacs.008.001.02', + 'sender' => + [ + 'name' => 'Sandy Sender', + 'address' => + [ + 'country' => 'GB', + 'lines' => 'Staveley Road +London', + ], + ], + 'instructing_agent' => + [ + 'bic' => 'SPSRSKBAXXX', + ], + 'purpose' => 'SALA', + 'message_id' => 'TEST-001-MSG', + ], + 'reference' => 'this is a test payment', + 'swift_service_level' => 'service-level-same-day-value', + 'merchant_details' => 'PAYBYPHONE RE ST ALBAN HATFIELD GBR', + 'amount' => '0', + 'failure_reasons' => + [ + 0 => 'contact-support', + 1 => 'partner-error', + 2 => 'card-rules-breached', + ], + 'ledger_from_id' => '8763b5df-a61c-4f77-9724-41ca9cde3654', + 'transaction_id' => 'bb8b2428-f94c-41df-8e82-a895ab4d6ac8', + 'amount_ledger_from' => '0', + 'card_entry_method' => '01', + 'reason' => 'random sequence of characters', + 'created_at' => '2000-01-01T00:00:00.000Z', + 'partner_product' => 'ExampleBank-EUR-1', + 'conversion_date' => '2018-05-26', + 'beneficiary_id' => 'bb8b2428-f94c-41df-8e82-a895ab4d6ac8', + 'transaction_printout' => + [ + 'foo' => 'bar', + ], + 'daily_unique_refence' => 'MDSL2EKYF', + 'asset_type' => 'eur', + 'asset_class' => 'currency', + 'swift_charge_bearer' => 'charge-bearer-shared', + 'transaction_currency' => 'GBP', + 'transaction_meta' => + [ + 'foo' => 'bar', + ], + 'rejection_reasons' => + [ + 0 => 'beneficiary-account-closed', + 1 => 'beneficiary-sort-code-and-account-number-unknown', + 2 => 'account-number-invalid', + ], + 'invoices' => + [ + 0 => + [ + 'created_at' => '2000-01-01T00:00:00.000Z', + 'document_id' => 'c91b339e-57d7-41ea-a805-8966ce8fe4ed', + 'description' => 'description', + ], + 1 => + [ + 'created_at' => '2000-01-01T00:00:00.000Z', + 'document_id' => 'bb8b2428-f94c-41df-8e82-a895ab4d6ac8', + 'description' => 'description', + ], + 2 => + [ + 'created_at' => '2000-01-01T00:00:00.000Z', + 'document_id' => '753fa673-66b4-4c94-9ddb-f9f4b5c1e9a3', + 'description' => 'description', + ], + ], + 'merchant_id' => 'a1234567', + 'point_of_sale_info' => '0001110000500826AL9', + 'amount_local_currency' => '1.50', + 'card_transaction_type' => 'Purchase', + 'beneficiary_account_id' => '6630b391-c5ce-46c1-9d23-a82a9e27f82d', + ]; + + $detailedTransaction = new DetailedTransaction($response); + + $entity->setDetailedTransaction($detailedTransaction); + self::assertInstanceOf(DetailedTransaction::class, $entity->getDetailedTransaction()); } } diff --git a/tests/Query/Me/InformationTest.php b/tests/Query/Me/InformationTest.php index bafa54c..b81440b 100644 --- a/tests/Query/Me/InformationTest.php +++ b/tests/Query/Me/InformationTest.php @@ -18,6 +18,7 @@ public function getCommandInputs(): array 'no input throws error' => [ false, [], + [], ], ]; } diff --git a/tests/Query/Me/PHPVersionTest.php b/tests/Query/Me/PHPVersionTest.php new file mode 100644 index 0000000..7dbbb60 --- /dev/null +++ b/tests/Query/Me/PHPVersionTest.php @@ -0,0 +1,25 @@ +command = PHPVersion::class; + } + + public function getCommandInputs(): array + { + return [ + 'no input throws error' => [ + false, + [], + [], + ], + ]; + } +} diff --git a/tests/Query/Version/InformationTest.php b/tests/Query/Version/GetVersionTest.php similarity index 95% rename from tests/Query/Version/InformationTest.php rename to tests/Query/Version/GetVersionTest.php index d26bdf1..a96bd28 100644 --- a/tests/Query/Version/InformationTest.php +++ b/tests/Query/Version/GetVersionTest.php @@ -18,6 +18,7 @@ public function getCommandInputs(): array 'no input throws error' => [ false, [], + [], ], ]; } diff --git a/tests/RailsbankTest.php b/tests/RailsbankTest.php new file mode 100644 index 0000000..2cd695b --- /dev/null +++ b/tests/RailsbankTest.php @@ -0,0 +1,52 @@ +handle(new PHPVersion()); + + self::assertNotNull($command); + self::assertIsString($command); + } +} diff --git a/tests/configtest/emptyarrayconfig.php b/tests/configtest/emptyarrayconfig.php new file mode 100644 index 0000000..0b67a5f --- /dev/null +++ b/tests/configtest/emptyarrayconfig.php @@ -0,0 +1,3 @@ + [ + 'play' => [ + 'base_url' => '', + 'role' => '', + 'api_key' => '', + ], + ], +]; diff --git a/tests/configtest/validconfig.php b/tests/configtest/validconfig.php new file mode 100644 index 0000000..37bcfa8 --- /dev/null +++ b/tests/configtest/validconfig.php @@ -0,0 +1,20 @@ + 'play', + 'play' => [ + 'base_url' => 'test', + 'role' => 'test', + 'api_key' => 'test', + ], + 'play_live' => [ + 'base_url' => 'test', + 'role' => 'test', + 'api_key' => 'test', + ], + 'live_account' => [ + 'base_url' => 'test', + 'role' => 'test', + 'api_key' => 'test', + ], +];