-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathOrdersTest.php
117 lines (91 loc) · 3.18 KB
/
OrdersTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
use Voucherify\Test\Helpers\CurlMock;
use Voucherify\VoucherifyClient;
use Voucherify\ClientException;
class OrdersTest extends PHPUnit_Framework_TestCase
{
protected static $headers;
protected static $apiId;
protected static $apiKey;
protected static $client;
public static function setUpBeforeClass()
{
self::$apiId = "c70a6f00-cf91-4756-9df5-47628850002b";
self::$apiKey = "3266b9f8-e246-4f79-bdf0-833929b1380c";
self::$headers = [
"Content-Type: application/json",
"X-App-Id: " . self::$apiId,
"X-App-Token: " . self::$apiKey,
"X-Voucherify-Channel: PHP-SDK"
];
self::$client = new VoucherifyClient(self::$apiId, self::$apiKey);
CurlMock::enable();
}
public static function tearDownAfterClass()
{
CurlMock::disable();
}
public function testCreate()
{
CurlMock::register("https://api.voucherify.io/v1", self::$headers)
->post("/orders/", [
"customer" => [ "name" => "customer name" ],
"amount" => 20050
])
->reply(200, [ "status" => "ok" ]);
$result = self::$client->orders->create((object)[
"customer" => [ "name" => "customer name" ],
"amount" => 20050
]);
$this->assertEquals($result, (object)[ "status" => "ok" ]);
CurlMock::done();
}
public function testGet()
{
CurlMock::register("https://api.voucherify.io/v1", self::$headers)
->get("/orders/test-order-id")
->reply(200, [ "status" => "ok" ]);
$result = self::$client->orders->get("test-order-id");
$this->assertEquals($result, (object)[ "status" => "ok" ]);
CurlMock::done();
}
public function testUpdateByObject()
{
CurlMock::register("https://api.voucherify.io/v1", self::$headers)
->put("/orders/test-order-id", [
"id" => "test-order-id",
"status" => "PAID"
])
->reply(200, [ "status" => "ok" ]);
$result = self::$client->orders->update((object)[
"id" => "test-order-id",
"status" => "PAID"
]);
$this->assertEquals($result, (object)[ "status" => "ok" ]);
CurlMock::done();
}
public function testUpdateByArray()
{
CurlMock::register("https://api.voucherify.io/v1", self::$headers)
->put("/orders/test-order-id", [
"id" => "test-order-id",
"status" => "PAID"
])
->reply(200, [ "status" => "ok" ]);
$result = self::$client->orders->update([
"id" => "test-order-id",
"status" => "PAID"
]);
$this->assertEquals($result, (object)[ "status" => "ok" ]);
CurlMock::done();
}
public function testGetList()
{
CurlMock::register("https://api.voucherify.io/v1", self::$headers)
->get("/orders/")
->reply(200, [ "status" => "ok" ]);
$result = self::$client->orders->getList();
$this->assertEquals($result, (object)[ "status" => "ok" ]);
CurlMock::done();
}
}