diff --git a/README.md b/README.md
index 07541b2..12c7424 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,7 @@ Features:
* general statuses (In the requests/responses may to meet `canceled` or `cancelled` variants. They will be converted to general status like as `cancelled`.)
TODO:
+* translate to English comments and system (error) messages
* validation
* implement method `card`
* implement method `recurrent`
diff --git a/src/Exception/ExceptionFactory.php b/src/Exception/ExceptionFactory.php
index 019a18c..f2e64e8 100644
--- a/src/Exception/ExceptionFactory.php
+++ b/src/Exception/ExceptionFactory.php
@@ -39,7 +39,7 @@ class ExceptionFactory
* @param $message
* @param \Psr\Http\Message\RequestInterface $request
* @param \Psr\Http\Message\ResponseInterface $response
- * @return \ErrorException
+ * @return ErrorException
*/
public static function createFromMessage($message, RequestInterface $request, ResponseInterface $response)
{
diff --git a/src/Exception/UnitellerException.php b/src/Exception/UnitellerException.php
index 23749f0..1d9a9e1 100644
--- a/src/Exception/UnitellerException.php
+++ b/src/Exception/UnitellerException.php
@@ -8,8 +8,30 @@
namespace Tmconsulting\Uniteller\Exception;
use Http\Client\Exception\HttpException;
+use Psr\Http\Message\RequestInterface;
+use Psr\Http\Message\ResponseInterface;
class UnitellerException extends HttpException
{
+ /**
+ * @param \Psr\Http\Message\RequestInterface $request
+ * @param \Psr\Http\Message\ResponseInterface $response
+ * @param \Exception|null $previous
+ * @return static
+ */
+ public static function create(
+ RequestInterface $request,
+ ResponseInterface $response,
+ \Exception $previous = null
+ ) {
+ $message = sprintf(
+ '[url] %s [http method] %s [status code] %s [reason phrase] %s',
+ $request->getRequestTarget(),
+ $request->getMethod(),
+ $response->getStatusCode(),
+ $response->getReasonPhrase()
+ );
+ return new static($message, $request, $response, $previous);
+ }
}
\ No newline at end of file
diff --git a/src/Http/Format.php b/src/Http/Format.php
index 595934f..bde431e 100644
--- a/src/Http/Format.php
+++ b/src/Http/Format.php
@@ -8,6 +8,7 @@
namespace Tmconsulting\Uniteller\Http;
use BadMethodCallException;
+use Tmconsulting\Uniteller\Exception\FormatNotSupportedException;
use Tmconsulting\Uniteller\Exception\RequestNotSupportedException;
use Tmconsulting\Uniteller\Request\RequestInterface;
use Tmconsulting\Uniteller;
@@ -42,6 +43,7 @@ final class Format
* @param $format
* @param $requestName
* @return int
+ * @throws \Tmconsulting\Uniteller\Exception\FormatNotSupportedException
* @throws \Tmconsulting\Uniteller\Exception\RequestNotSupportedException
*/
public static function resolve($format, $requestName)
diff --git a/src/Http/HttpManager.php b/src/Http/HttpManager.php
index 8e3c5ca..31ee540 100644
--- a/src/Http/HttpManager.php
+++ b/src/Http/HttpManager.php
@@ -7,8 +7,8 @@
namespace Tmconsulting\Uniteller\Http;
-use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Request;
+use Http\Client\Exception\RequestException;
use Http\Client\HttpClient;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
diff --git a/src/Order/Order.php b/src/Order/Order.php
index 9bc3104..0bfe83a 100644
--- a/src/Order/Order.php
+++ b/src/Order/Order.php
@@ -504,9 +504,8 @@ public function setEOrderData($eOrderData)
}
foreach (explode(', ', $eOrderData) as $item) {
- foreach (explode('=', $item) as list($key, $value)) {
- $this->eOrderData[$key] = $value;
- }
+ list($key, $value) = explode('=', $item);
+ $this->eOrderData[$key] = $value;
}
return $this;
diff --git a/tests/Cancel/CancelBuilderTest.php b/tests/Cancel/CancelBuilderTest.php
new file mode 100644
index 0000000..e70b9fb
--- /dev/null
+++ b/tests/Cancel/CancelBuilderTest.php
@@ -0,0 +1,36 @@
+setBillNumber(1);
+ $builder->setCurrency('RUB');
+ $builder->setRvrReason(RVRReason::SHOP);
+ $builder->setSelectFields([]);
+ $builder->setSubtotalP(10);
+
+ $expected = [
+ 'Billnumber' => 1,
+ 'Subtotal_P' => 10,
+ 'Currency' => 'RUB',
+ 'RVRReason' => RVRReason::SHOP,
+ 'S_FIELDS' => []
+ ];
+
+ $this->assertEquals($expected, $builder->toArray());
+ }
+}
\ No newline at end of file
diff --git a/tests/Cancel/CancelRequestTest.php b/tests/Cancel/CancelRequestTest.php
new file mode 100644
index 0000000..021c671
--- /dev/null
+++ b/tests/Cancel/CancelRequestTest.php
@@ -0,0 +1,71 @@
+createMock(HttpManagerInterface::class);
+ $manager
+ ->expects($this->once())
+ ->method('request')
+ ->willReturn($this->getStubContents('cancel'));
+
+ $request = new CancelRequest();
+ /** @var \Tmconsulting\Uniteller\Order\Order $order */
+ foreach ($request->execute($manager) as $order) {
+ $this->assertInstanceOf(Order::class, $order);
+ $this->assertEquals('Value of address', $order->getAddress());
+ $this->assertEquals('Value of approvalcode', $order->getApprovalCode());
+ $this->assertEquals('Value of bankname', $order->getBankName());
+ $this->assertEquals('Value of billnumber', $order->getBillNumber());
+ $this->assertEquals('Value of bookingcom_id', $order->getBookingcomId());
+ $this->assertEquals('Value of bookingcom_pincode', $order->getBookingcomPincode());
+ $this->assertEquals('Value of card_idp', $order->getCardIdp());
+ $this->assertEquals('Value of cardholder', $order->getCardHolder());
+ $this->assertEquals('Value of cardnumber', $order->getCardNumber());
+ $this->assertEquals('Value of cardtype', $order->getCardType());
+ $this->assertEquals('Value of comment', $order->getComment());
+ $this->assertEquals('Value of currency', $order->getCurrency());
+ $this->assertEquals(true, $order->isCvc2());
+ $this->assertInstanceOf(\DateTime::class, $order->getDate());
+ $this->assertEquals('Value of email', $order->getEmail());
+ $this->assertEquals('Value of emoneytype', $order->getEMoneyType());
+ $this->assertEquals(['foo' => 'bar', 'baz' => 'bue'], $order->getEOrderData());
+ $this->assertEquals('Value of error_code', $order->getErrorCode());
+ $this->assertEquals('Value of error_comment', $order->getErrorComment());
+ $this->assertEquals('Value of firstname', $order->getFirstName());
+ $this->assertEquals('Value of gds_payment_purpose_id', $order->getGdsPaymentPurposeId());
+ $this->assertEquals('Value of idata', $order->getIData());
+ $this->assertEquals('Value of ipaddress', $order->getIp());
+ $this->assertEquals('Value of lastname', $order->getLastName());
+ $this->assertEquals('Value of loan_id', $order->getLoanId());
+ $this->assertEquals('Value of message', $order->getMessage());
+ $this->assertEquals('Value of middlename', $order->getMiddleName());
+ $this->assertEquals(true, $order->isNeedConfirm());
+ $this->assertEquals('Value of ordernumber', $order->getOrderNumber());
+ $this->assertEquals('Value of parent_order_number', $order->getParentOrderNumber());
+ $this->assertEquals('Value of paymenttype', $order->getPaymentType());
+ $this->assertEquals('Value of phone', $order->getPhone());
+ $this->assertEquals('Value of pt_code', $order->getPtCode());
+ $this->assertEquals('Value of recommendation', $order->getRecommendation());
+ $this->assertEquals('Value of response_code', $order->getResponseCode());
+ $this->assertEquals(Status::PAID, $order->getStatus());
+ $this->assertEquals('Value of total', $order->getTotal());
+ $this->assertInstanceOf(\DateTime::class, $order->getPacketDate());
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/Cancel/RVRReasonTest.php b/tests/Cancel/RVRReasonTest.php
new file mode 100644
index 0000000..596d66e
--- /dev/null
+++ b/tests/Cancel/RVRReasonTest.php
@@ -0,0 +1,22 @@
+assertEquals(RVRReason::SHOP, 1);
+ $this->assertEquals(RVRReason::CARDHOLDER, 2);
+ $this->assertEquals(RVRReason::FRAUD, 3);
+ }
+}
\ No newline at end of file
diff --git a/tests/ClientTest.php b/tests/ClientTest.php
index a432d2b..054d027 100644
--- a/tests/ClientTest.php
+++ b/tests/ClientTest.php
@@ -7,17 +7,20 @@
namespace Tmconsulting\Uniteller\Tests;
-
+use Tmconsulting\Uniteller\ArraybleInterface;
+use Tmconsulting\Uniteller\Cancel\CancelRequest;
+use Tmconsulting\Uniteller\Client;
+use Tmconsulting\Uniteller\Exception\NotImplementedException;
+use Tmconsulting\Uniteller\Http\HttpManagerInterface;
use Tmconsulting\Uniteller\Payment\PaymentInterface;
+use Tmconsulting\Uniteller\Request\RequestInterface;
use Tmconsulting\Uniteller\Signature\SignatureInterface;
-use Tmconsulting\Uniteller\Client;
class ClientTest extends TestCase
{
- public function testEmptyConstructor()
+ public function testShouldBeConstructedWithoutArguments()
{
- $reflect = new \ReflectionClass(Client::class);
- $this->assertEmpty($reflect->getConstructor()->getParameters());
+ new Client();
}
public function testOptionsAccessorsAndMutators()
@@ -66,4 +69,188 @@ public function testSetOptionsUseArrayNotation()
$this->assertSame($true, $uniteller->getOptions());
}
+
+ public function testGivenArgumentShouldBeImplementHttpManagerInterface()
+ {
+ $part1 = 'Argument 1 passed to ' . Client::class . '::setHttpManager()';
+ $part2 = HttpManagerInterface::class;
+
+ $client = new Client();
+ try {
+ $client->setHttpManager(new \stdClass());
+ } catch (\Exception $e) { // PHP 5.6
+ // Argument 1 passed to Tmconsulting\Uniteller\Client::setHttpManager()
+ // must be an instance of Tmconsulting\Uniteller\Http\HttpManagerInterface,
+ // instance of stdClass given
+ // 4096 - is equivalet to the error above.
+ $this->assertEquals(4096, $e->getCode());
+ $this->assertStringStartsWith($part1, $e->getMessage());
+ $this->assertContains($part2, $e->getMessage());
+ } catch (\Throwable $e) { // PHP 7
+ $this->assertStringStartsWith($part1, $e->getMessage());
+ $this->assertContains($part2, $e->getMessage());
+ }
+
+ $client->setHttpManager($this->createMock(HttpManagerInterface::class));
+ $this->assertInstanceOf(HttpManagerInterface::class, $client->getHttpManager());
+ }
+
+ /**
+ * @return array
+ */
+ public function provideMethodsWhenHaveAnFirstArgumentIsRequestInterface()
+ {
+ return [
+ ['registerCancelRequest'],
+ ['registerResultsRequest'],
+ ];
+ }
+
+ /**
+ * @dataProvider provideMethodsWhenHaveAnFirstArgumentIsRequestInterface
+ * @param $methodName
+ */
+ public function testGivenArgumentShouldBeTypeHintedAsRequestInterface($methodName)
+ {
+ $reflect = new \ReflectionClass(Client::class);
+ $first = $reflect->getMethod($methodName)->getParameters()[0]->getClass()->getName();
+
+ $this->assertEquals(RequestInterface::class, $first);
+ }
+
+ public function testCanRequestMethodsMayReturnCorrectResult()
+ {
+ $client = new Client();
+ $client->registerCancelRequest($this->createMock(RequestInterface::class));
+ $client->registerResultsRequest($this->createMock(RequestInterface::class));
+
+ $this->assertInstanceOf(RequestInterface::class, $client->getCancelRequest());
+ $this->assertInstanceOf(RequestInterface::class, $client->getResultsRequest());
+ }
+
+ public function testShouldBePaymentMethodBuildCorrectArray()
+ {
+ $payment = $this->createMock(PaymentInterface::class);
+ $payment
+ ->expects($this->once())
+ ->method('execute')
+ ->willReturnCallback(function ($array) {
+ $this->assertArrayHasKey('Shop_IDP', $array);
+ $this->assertArrayHasKey('Password', $array);
+ $this->assertArrayHasKey('Signature', $array);
+ });
+
+ $client = new Client();
+ $client->registerPayment($payment);
+
+ $client->payment([]);
+ }
+
+ public function testCanCancelMethodGiveControlToTheRequestClass()
+ {
+ $request = $this->createMock(RequestInterface::class);
+ $request
+ ->expects($this->at(1))
+ ->method('execute')
+ ->willReturnCallback(function ($manager, $array) {
+ $this->assertInstanceOf(HttpManagerInterface::class, $manager);
+ $this->assertTrue(is_array($array));
+ });
+
+ $client = new Client();
+ $client->registerCancelRequest($request);
+ $client->registerResultsRequest($request);
+
+ $client->cancel([]);
+ $client->results([]);
+
+ $this->assertInstanceOf(HttpManagerInterface::class, $client->getHttpManager());
+ }
+
+ public function testCanUseCustomHttpManager()
+ {
+ $cancel = $this->createMock(CancelRequest::class);
+ $cancel
+ ->expects($this->once())
+ ->method('execute');
+
+ $client = new Client();
+ $client->setHttpManager(new HttpManagerStub());
+ $client->registerCancelRequest($cancel);
+
+ $client->cancel([]);
+
+ $this->assertInstanceOf(HttpManagerStub::class, $client->getHttpManager());
+ }
+
+ /**
+ * @return array
+ */
+ public function provideUnsupportedRequestMethods()
+ {
+ return [
+ ['reccurent'],
+ ['confirm'],
+ ['card'],
+ ];
+ }
+
+ /**
+ * @dataProvider provideUnsupportedRequestMethods
+ * @param $methodName
+ */
+ public function testShouldBeUnsupportedMethodsThrowException($methodName)
+ {
+ $this->expectException(NotImplementedException::class);
+ $this->expectExceptionMessageRegExp('/In current moment, feature \[.*\] not implemented./');
+ $client = new Client();
+ $client->{$methodName}([]);
+ }
+
+ public function provideActionsWhichShouldBeAcceptArrayble()
+ {
+ return [
+ ['payment'],
+ ['cancel'],
+ ['results'],
+ ];
+ }
+
+ /**
+ * @dataProvider provideActionsWhichShouldBeAcceptArrayble
+ * @param $methodName
+ */
+ public function testShouldBeActionsAcceptClassesWhichImplementArraybleInterface($methodName)
+ {
+ $request = $this->createMock(RequestInterface::class);
+ $request->method('execute');
+
+ $client = new Client();
+ $client->registerResultsRequest($request);
+ $client->registerCancelRequest($request);
+ $client->registerPayment($this->createMock(PaymentInterface::class));
+
+ $arrayble = $this->createMock(ArraybleInterface::class);
+ $arrayble
+ ->method('toArray')
+ ->willReturn([]);
+
+ $client->{$methodName}($arrayble);
+ }
+
+}
+
+class HttpManagerStub implements HttpManagerInterface {
+
+ /**
+ * @param $uri
+ * @param string $method
+ * @param null $data
+ * @param array $headers
+ * @return string
+ */
+ public function request($uri, $method = 'POST', $data = null, array $headers = [])
+ {
+ // TODO: Implement request() method.
+ }
}
\ No newline at end of file
diff --git a/tests/Error/ResponseCodeTest.php b/tests/Error/ResponseCodeTest.php
new file mode 100644
index 0000000..a066a25
--- /dev/null
+++ b/tests/Error/ResponseCodeTest.php
@@ -0,0 +1,43 @@
+{$method}(ResponseCode::message($code));
+ }
+}
\ No newline at end of file
diff --git a/tests/Exception/ExceptionFactoryTest.php b/tests/Exception/ExceptionFactoryTest.php
new file mode 100644
index 0000000..4ebc106
--- /dev/null
+++ b/tests/Exception/ExceptionFactoryTest.php
@@ -0,0 +1,59 @@
+expectException($e);
+
+ throw ExceptionFactory::createFromMessage(
+ $message,
+ $this->createMock(RequestInterface::class),
+ $this->createMock(ResponseInterface::class)
+ );
+ }
+}
\ No newline at end of file
diff --git a/tests/Http/FormatTest.php b/tests/Http/FormatTest.php
new file mode 100644
index 0000000..17b30e7
--- /dev/null
+++ b/tests/Http/FormatTest.php
@@ -0,0 +1,49 @@
+expectException(RequestNotSupportedException::class);
+ $this->expectExceptionMessage('Request [unknown] not supported here.');
+
+ Format::resolveXml('unknown');
+ }
+
+ public function testCanNotResolveUnsupportedFormat()
+ {
+ $this->expectException(FormatNotSupportedException::class);
+ $this->expectExceptionMessage('Format [xml] not supported for request [recurrent].');
+
+ Format::resolveXml(RequestInterface::REQUEST_RECURRENT);
+ }
+
+ public function testCanCallBadMagicStaticMethod()
+ {
+ $this->expectException(BadMethodCallException::class);
+ $this->expectExceptionMessage('Method [resolvingJson] not found.');
+
+ Format::resolvingJson('unknown');
+ }
+
+ public function testCanResolveSupportedFormat()
+ {
+ $value = Format::resolveXml(RequestInterface::REQUEST_CONFIRM);
+ $this->assertEquals(3, $value);
+ }
+}
\ No newline at end of file
diff --git a/tests/Http/HttpManagerTest.php b/tests/Http/HttpManagerTest.php
new file mode 100644
index 0000000..b956b85
--- /dev/null
+++ b/tests/Http/HttpManagerTest.php
@@ -0,0 +1,104 @@
+http([
+ new Response(200, [], $this->getStubContents('cancel')),
+ ]);
+
+ $this->assertEquals(
+ $this->getStubContents('cancel'),
+ $manager->request(RequestInterface::REQUEST_CANCEL)
+ );
+ }
+
+ public function testBehaviorIfServerReturnError()
+ {
+ $this->expectException(UnitellerException::class);
+
+ $manager = $this->http([
+ new RequestException(
+ 'Error Communicating with Server',
+ new Request('GET', 'test'),
+ new Response(500)
+ )
+ ]);
+
+ $manager->request(RequestInterface::REQUEST_CANCEL);
+ }
+
+ public function testCreatingExceptionsFromPayloadErrorText()
+ {
+ $this->expectException(AuthConfirmIsNotAllowedException::class);
+
+ $manager = $this->http([
+ new Response(200, [], 'ERROR: Authorization confirm is not allowed')
+ ]);
+
+ $manager->request(RequestInterface::REQUEST_CANCEL);
+ }
+
+ public function testCreatingExceptionsFromXmlResponse()
+ {
+ $this->expectException(AuthenticationException::class);
+
+ $manager = $this->http([
+ new Response(200, [], $this->getStubContents('error'))
+ ]);
+
+ $manager->request(RequestInterface::REQUEST_CANCEL);
+ }
+
+ public function testThrownBasicExceptionIfStatusNotIncludedInTheRange()
+ {
+ $this->expectException(UnitellerException::class);
+
+ $manager = $this->http([new Response(302, [])]);
+
+ $manager->request(RequestInterface::REQUEST_CANCEL);
+ }
+
+ /**
+ * @param $queue
+ * @return \Tmconsulting\Uniteller\Http\HttpManager
+ */
+ protected function http($queue)
+ {
+ $mock = new MockHandler($queue);
+
+ $httpClient = new GuzzleAdapter(new GuzzleClient([
+ 'handler' => HandlerStack::create($mock)
+ ]));
+
+ return new HttpManager($httpClient, [
+ 'base_uri' => '',
+ 'shop_id' => '',
+ 'login' => '',
+ 'password' => '',
+ ]);
+ }
+}
\ No newline at end of file
diff --git a/tests/Order/StatusTest.php b/tests/Order/StatusTest.php
new file mode 100644
index 0000000..e9b5a82
--- /dev/null
+++ b/tests/Order/StatusTest.php
@@ -0,0 +1,42 @@
+assertEquals($expected, Status::resolve($name));
+ }
+}
\ No newline at end of file
diff --git a/tests/Payment/PaymentTest.php b/tests/Payment/PaymentTest.php
new file mode 100644
index 0000000..2b7bbcc
--- /dev/null
+++ b/tests/Payment/PaymentTest.php
@@ -0,0 +1,25 @@
+execute(['q' => 'banana'], ['base_uri' => 'https://google.com']);
+
+ $this->assertInstanceOf(UriInterface::class, $results);
+ $this->assertEquals('https://google.com/pay?q=banana', $results->getUri());
+ }
+}
\ No newline at end of file
diff --git a/tests/Results/ResultsRequestTest.php b/tests/Results/ResultsRequestTest.php
new file mode 100644
index 0000000..06f3611
--- /dev/null
+++ b/tests/Results/ResultsRequestTest.php
@@ -0,0 +1,71 @@
+createMock(HttpManagerInterface::class);
+ $manager
+ ->expects($this->once())
+ ->method('request')
+ ->willReturn($this->getStubContents('cancel'));
+
+ $request = new ResultsRequest();
+ /** @var \Tmconsulting\Uniteller\Order\Order $order */
+ foreach ($request->execute($manager) as $order) {
+ $this->assertInstanceOf(Order::class, $order);
+ $this->assertEquals('Value of address', $order->getAddress());
+ $this->assertEquals('Value of approvalcode', $order->getApprovalCode());
+ $this->assertEquals('Value of bankname', $order->getBankName());
+ $this->assertEquals('Value of billnumber', $order->getBillNumber());
+ $this->assertEquals('Value of bookingcom_id', $order->getBookingcomId());
+ $this->assertEquals('Value of bookingcom_pincode', $order->getBookingcomPincode());
+ $this->assertEquals('Value of card_idp', $order->getCardIdp());
+ $this->assertEquals('Value of cardholder', $order->getCardHolder());
+ $this->assertEquals('Value of cardnumber', $order->getCardNumber());
+ $this->assertEquals('Value of cardtype', $order->getCardType());
+ $this->assertEquals('Value of comment', $order->getComment());
+ $this->assertEquals('Value of currency', $order->getCurrency());
+ $this->assertEquals(true, $order->isCvc2());
+ $this->assertInstanceOf(\DateTime::class, $order->getDate());
+ $this->assertEquals('Value of email', $order->getEmail());
+ $this->assertEquals('Value of emoneytype', $order->getEMoneyType());
+ $this->assertEquals(['foo' => 'bar', 'baz' => 'bue'], $order->getEOrderData());
+ $this->assertEquals('Value of error_code', $order->getErrorCode());
+ $this->assertEquals('Value of error_comment', $order->getErrorComment());
+ $this->assertEquals('Value of firstname', $order->getFirstName());
+ $this->assertEquals('Value of gds_payment_purpose_id', $order->getGdsPaymentPurposeId());
+ $this->assertEquals('Value of idata', $order->getIData());
+ $this->assertEquals('Value of ipaddress', $order->getIp());
+ $this->assertEquals('Value of lastname', $order->getLastName());
+ $this->assertEquals('Value of loan_id', $order->getLoanId());
+ $this->assertEquals('Value of message', $order->getMessage());
+ $this->assertEquals('Value of middlename', $order->getMiddleName());
+ $this->assertEquals(true, $order->isNeedConfirm());
+ $this->assertEquals('Value of ordernumber', $order->getOrderNumber());
+ $this->assertEquals('Value of parent_order_number', $order->getParentOrderNumber());
+ $this->assertEquals('Value of paymenttype', $order->getPaymentType());
+ $this->assertEquals('Value of phone', $order->getPhone());
+ $this->assertEquals('Value of pt_code', $order->getPtCode());
+ $this->assertEquals('Value of recommendation', $order->getRecommendation());
+ $this->assertEquals('Value of response_code', $order->getResponseCode());
+ $this->assertEquals(Status::PAID, $order->getStatus());
+ $this->assertEquals('Value of total', $order->getTotal());
+ $this->assertInstanceOf(\DateTime::class, $order->getPacketDate());
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/SignatureTest.php b/tests/Signature/SignatureTest.php
similarity index 90%
rename from tests/SignatureTest.php
rename to tests/Signature/SignatureTest.php
index 9a39895..c1a8ba7 100644
--- a/tests/SignatureTest.php
+++ b/tests/Signature/SignatureTest.php
@@ -5,9 +5,10 @@
* GitHub: Roquie
*/
-namespace Tmconsulting\Uniteller\Tests;
+namespace Tmconsulting\Uniteller\Tests\Signature;
use Tmconsulting\Uniteller\Signature\Signature;
+use Tmconsulting\Uniteller\Tests\TestCase;
class SignatureTest extends TestCase
{
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 043bb61..f0b63ee 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -6,5 +6,12 @@
class TestCase extends PHPUnit_Framework_TestCase
{
-
+ /**
+ * @param $filename
+ * @return bool|string
+ */
+ protected function getStubContents($filename)
+ {
+ return file_get_contents(__DIR__ . "/stub/$filename.xml");
+ }
}
\ No newline at end of file
diff --git a/tests/stub/cancel.xml b/tests/stub/cancel.xml
new file mode 100644
index 0000000..e0925ed
--- /dev/null
+++ b/tests/stub/cancel.xml
@@ -0,0 +1,46 @@
+
+
+
+
+ Value of ordernumber
+ Value of response_code
+ Value of recommendation
+ Value of message
+ Value of comment
+ 10.03.2017 15:42:42
+ Value of total
+ Value of currency
+ Value of cardtype
+ Value of emoneytype
+ Value of cardnumber
+ foo=bar, baz=bue
+ Value of lastname
+ Value of firstname
+ Value of middlename
+ Value of bookingcom_id
+ Value of bookingcom_pincode
+ Value of gds_payment_purpose_id
+ Value of idata
+ 1
+ Value of loan_id
+ Value of card_idp
+ Value of parent_order_number
+ Value of address
+ Value of email
+ paid
+ Value of pt_code
+ Value of approvalcode
+ Value of cvc2
+ Value of cardholder
+ Value of ipaddress
+ Value of billnumber
+ Value of bankname
+ Value of status
+ Value of error_code
+ Value of error_comment
+ 10.03.2017 15:42:42
+ Value of paymenttype
+ Value of phone
+
+
+
\ No newline at end of file
diff --git a/tests/stub/error.xml b/tests/stub/error.xml
new file mode 100644
index 0000000..179bbf1
--- /dev/null
+++ b/tests/stub/error.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/tests/stub/results.xml b/tests/stub/results.xml
new file mode 100644
index 0000000..e0925ed
--- /dev/null
+++ b/tests/stub/results.xml
@@ -0,0 +1,46 @@
+
+
+
+
+ Value of ordernumber
+ Value of response_code
+ Value of recommendation
+ Value of message
+ Value of comment
+ 10.03.2017 15:42:42
+ Value of total
+ Value of currency
+ Value of cardtype
+ Value of emoneytype
+ Value of cardnumber
+ foo=bar, baz=bue
+ Value of lastname
+ Value of firstname
+ Value of middlename
+ Value of bookingcom_id
+ Value of bookingcom_pincode
+ Value of gds_payment_purpose_id
+ Value of idata
+ 1
+ Value of loan_id
+ Value of card_idp
+ Value of parent_order_number
+ Value of address
+ Value of email
+ paid
+ Value of pt_code
+ Value of approvalcode
+ Value of cvc2
+ Value of cardholder
+ Value of ipaddress
+ Value of billnumber
+ Value of bankname
+ Value of status
+ Value of error_code
+ Value of error_comment
+ 10.03.2017 15:42:42
+ Value of paymenttype
+ Value of phone
+
+
+
\ No newline at end of file