|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace PTS\Paysera\Tests; |
|
5
|
|
|
|
|
6
|
|
|
use Payum\Core\Reply\HttpPostRedirect; |
|
7
|
|
|
use WebToPayException; |
|
8
|
|
|
use PHPUnit\Framework\TestCase; |
|
9
|
|
|
use PTS\Paysera\Api; |
|
10
|
|
|
|
|
11
|
|
|
class ApiTest extends TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
|
|
14
|
|
|
public function testApiWhenPayingWithoutCorrectDataThrowsException() |
|
15
|
|
|
{ |
|
16
|
|
|
$this->expectException(\WebToPay_Exception_Validation::class); |
|
17
|
|
|
$options = [ |
|
18
|
|
|
'projectid' => 'testProjectId', |
|
19
|
|
|
'sign_password' => 'testSignPassword', |
|
20
|
|
|
'test' => false |
|
21
|
|
|
]; |
|
22
|
|
|
$api = new Api($options); |
|
23
|
|
|
$fields = []; |
|
24
|
|
|
$api->doPayment($fields); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @test |
|
29
|
|
|
**/ |
|
30
|
|
|
public function testApiWhenPayingWithCorrectDataThrowsRedirect() |
|
31
|
|
|
{ |
|
32
|
|
|
$this->expectException(HttpPostRedirect::class); |
|
33
|
|
|
|
|
34
|
|
|
$options = [ |
|
35
|
|
|
'projectid' => 'testProjectId', |
|
36
|
|
|
'sign_password' => 'testSignPassword', |
|
37
|
|
|
'test' => false |
|
38
|
|
|
]; |
|
39
|
|
|
$api = new Api($options); |
|
40
|
|
|
$fields = [ |
|
41
|
|
|
'orderid' => '15', |
|
42
|
|
|
'accepturl' => 'testurl', |
|
43
|
|
|
'cancelurl' => 'testurl', |
|
44
|
|
|
'callbackurl' => 'testurl', |
|
45
|
|
|
]; |
|
46
|
|
|
$api->doPayment($fields); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @test |
|
51
|
|
|
**/ |
|
52
|
|
|
public function testApiWhenNotifyingWithoutCorrectDataThrowsException() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->expectException(WebToPayException::class); |
|
55
|
|
|
|
|
56
|
|
|
$options = [ |
|
57
|
|
|
'projectid' => 'testProjectId', |
|
58
|
|
|
'password' => 'testSignPassword', |
|
59
|
|
|
'test' => false |
|
60
|
|
|
]; |
|
61
|
|
|
$api = new Api($options); |
|
62
|
|
|
$fields = [ |
|
63
|
|
|
'data' => '15', |
|
64
|
|
|
'ss1' => 'testurl', |
|
65
|
|
|
'ss2' => 'testurl' |
|
66
|
|
|
]; |
|
67
|
|
|
$api->doNotify($fields); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
} |