Completed
Pull Request — master (#5)
by Jan
06:16 queued 02:12
created

RequestFactoryTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace SlevomatCsobGateway;
4
5
use SlevomatCsobGateway\Api\HttpMethod;
6
use SlevomatCsobGateway\Call\ClosePaymentRequest;
7
use SlevomatCsobGateway\Call\CustomerInfoRequest;
8
use SlevomatCsobGateway\Call\EchoRequest;
9
use SlevomatCsobGateway\Call\InitPaymentRequest;
10
use SlevomatCsobGateway\Call\PaymentStatusRequest;
11
use SlevomatCsobGateway\Call\PayMethod;
12
use SlevomatCsobGateway\Call\PayOperation;
13
use SlevomatCsobGateway\Call\PostEchoRequest;
14
use SlevomatCsobGateway\Call\ProcessPaymentRequest;
15
use SlevomatCsobGateway\Call\ReceivePaymentRequest;
16
use SlevomatCsobGateway\Call\RecurrentPaymentRequest;
17
use SlevomatCsobGateway\Call\RefundPaymentRequest;
18
use SlevomatCsobGateway\Call\ReversePaymentRequest;
19
20
class RequestFactoryTest extends \PHPUnit_Framework_TestCase
21
{
22
23
	/**
24
	 * @var RequestFactory
25
	 */
26
	private $requestFactory;
27
28
	protected function setUp()
29
	{
30
		$this->requestFactory = new RequestFactory('012345');
31
	}
32
33
	public function testCreateInitPayment()
34
	{
35
		$cart = new Cart(
36
			new Currency(Currency::CZK)
37
		);
38
		$cart->addItem('Nákup na vasobchodcz', 1, 1789600, 'Lenovo ThinkPad Edge E540');
39
		$cart->addItem('Poštovné', 1, 0, 'Doprava PPL');
40
41
		$request = $this->requestFactory->createInitPayment(
42
			'5547',
43
			new PayOperation(PayOperation::PAYMENT),
44
			new PayMethod(PayMethod::CARD),
45
			true,
46
			'https://vasobchod.cz/gateway-return',
47
			new HttpMethod(HttpMethod::POST),
48
			$cart,
49
			'Nákup na vasobchod.cz (Lenovo ThinkPad Edge E540, Doprava PPL)',
50
			'some-base64-encoded-merchant-data',
51
			'123',
52
			new Language(Language::CZ)
53
		);
54
55
		$this->assertInstanceOf(InitPaymentRequest::class, $request);
56
	}
57
58
	public function testCreateProcessPayment()
59
	{
60
		$request = $this->requestFactory->createProcessPayment('123456789');
61
62
		$this->assertInstanceOf(ProcessPaymentRequest::class, $request);
63
	}
64
65
	public function testCreatePaymentStatus()
66
	{
67
		$request = $this->requestFactory->createPaymentStatus('123456789');
68
69
		$this->assertInstanceOf(PaymentStatusRequest::class, $request);
70
	}
71
72
	public function testCreateReversePayment()
73
	{
74
		$request = $this->requestFactory->createReversePayment('123456789');
75
76
		$this->assertInstanceOf(ReversePaymentRequest::class, $request);
77
	}
78
79
	public function testCreateClosePayment()
80
	{
81
		$request = $this->requestFactory->createClosePayment('123456789');
82
83
		$this->assertInstanceOf(ClosePaymentRequest::class, $request);
84
	}
85
86
	public function testCreateRefundPayment()
87
	{
88
		$request = $this->requestFactory->createRefundPayment('123456789');
89
90
		$this->assertInstanceOf(RefundPaymentRequest::class, $request);
91
	}
92
93
	public function testCreateRecurrentPayment()
94
	{
95
		$request = $this->requestFactory->createRecurrentPayment(
96
			'ef08b6e9f22345c',
97
			'5547123'
98
		);
99
100
		$this->assertInstanceOf(RecurrentPaymentRequest::class, $request);
101
	}
102
103
	public function testCreateEchoRequest()
104
	{
105
		$request = $this->requestFactory->createEchoRequest();
106
107
		$this->assertInstanceOf(EchoRequest::class, $request);
108
	}
109
110
	public function testCreatePostEchoRequest()
111
	{
112
		$request = $this->requestFactory->createPostEchoRequest();
113
114
		$this->assertInstanceOf(PostEchoRequest::class, $request);
115
	}
116
117
	public function testCreateCustomerInfo()
118
	{
119
		$request = $this->requestFactory->createCustomerInfo('[email protected]');
120
121
		$this->assertInstanceOf(CustomerInfoRequest::class, $request);
122
	}
123
124
	public function testCreateReceivePayment()
125
	{
126
		$request = $this->requestFactory->createReceivePaymentRequest();
127
128
		$this->assertInstanceOf(ReceivePaymentRequest::class, $request);
129
	}
130
131
}
132