Passed
Push — master ( db667c...ff227b )
by Daniel
11:28 queued 12s
created

ClientTest::testGetEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 10
1
// <?php 
2
3
// declare(strict_types=1);
4
5
// namespace InShore\Bookwhen\Test;
6
7
// use GuzzleHttp\Client as GuzzleClient;
8
// use GuzzleHttp\Handler\MockHandler;
9
// use GuzzleHttp\Psr7\Response;
10
// use GuzzleHttp\HandlerStack;
11
// use InShore\Bookwhen\Client;
12
// use InShore\Bookwhen\Exceptions\ConfigurationException;
13
// use InShore\Bookwhen\Exceptions\RestException;
14
// use InShore\Bookwhen\Exceptions\ValidationException;
15
// use PHPUnit\Framework\TestCase;
16
17
// /**
18
//  * @author Daniel Mullin [email protected]
19
//  * @author Brandon Lubbehusen [email protected]
20
//  * 
21
//  * @uses InShore\Bookwhen\Client
22
//  */
23
// class ClientTest extends TestCase
24
// {
25
    
26
//     protected $client;
27
    
28
//     protected $mockHandler;
29
    
30
//     public function setUp(): void
31
//     {
32
//         $this->mockHandler = new MockHandler();
33
        
34
//         $this->guzzleClient = new GuzzleClient([
35
//             'handler' => $this->mockHandler,
36
//         ]);
37
        
38
//         $this->client = new Client('6v47r0jdz3r2ao3yc8f1vyx2kjry');
39
//     }
40
    
41
//     /**
42
//      * @covers InShore\Bookwhen\Client::__construct
43
//      * @covers InShore\Bookwhen\Client::getAttachments
44
//      * @covers InShore\Bookwhen\Client::request
45
//      * @uses InShore\Bookwhen\Validator
46
//      */
47
//     public function testGetAttachments()
48
//     {
49
//         $this->mockHandler->append(new Response('200', [], file_get_contents(__DIR__ . '/fixtures/attachments_200.json')));
50
//         $this->client->setGuzzleClient($this->guzzleClient);
51
//         $attachments = $this->client->getAttachments();
52
//         $this->assertIsArray($attachments);
53
//         $this->assertEquals('9v06h1cbv0en', $attachments[0]->id);
54
//     }
55
    
56
//     /**
57
//      * @covers InShore\Bookwhen\Client::__construct
58
//      * @covers InShore\Bookwhen\Client::getAttachment
59
//      * @covers InShore\Bookwhen\Client::request
60
//      * @uses InShore\Bookwhen\Validator
61
//      * @uses InShore\Bookwhen\Exceptions\ValidationException
62
//      */
63
//     public function testGetAttachmentWithInValidAttachmentId()
64
//     {
65
//         $this->expectException(ValidationException::class);
66
//         $this->mockHandler->append(new Response('200', [], file_get_contents(__DIR__ . '/fixtures/attachments_200.json')));
67
//         $this->client->setGuzzleClient($this->guzzleClient);
68
//         $attachment = $this->client->getAttachment(null);
69
//     }
70
    
71
//     /**
72
//      * @covers InShore\Bookwhen\Client::__construct
73
//      * @covers InShore\Bookwhen\Client::getAttachment
74
//      * @covers InShore\Bookwhen\Client::request
75
//      * @uses InShore\Bookwhen\Validator
76
//      */
77
//     public function testGetAttachmentWithValidAttachmentId()
78
//     {
79
//         $this->mockHandler->append(new Response('200', [], file_get_contents(__DIR__ . '/fixtures/attachments_200.json')));
80
//         $this->client->setGuzzleClient($this->guzzleClient);
81
//         $attachment = $this->client->getAttachment('9v06h1cbv0en');
82
//         $this->assertEquals('9v06h1cbv0en', $attachment->id);
83
//     }
84
85
//     /**
86
//      * @covers InShore\Bookwhen\Client::__construct
87
//      * @covers InShore\Bookwhen\Client::getClassPasses
88
//      * @covers InShore\Bookwhen\Client::request
89
//      * @uses InShore\Bookwhen\Validator
90
//      * @uses InShore\Bookwhen\Exceptions\ValidationException
91
//      */
92
//     public function testGetClassPasses()
93
//     {
94
//         $this->mockHandler->append(new Response('200', [], file_get_contents(__DIR__ . '/fixtures/classpasses_200.json')));
95
//         $this->client->setGuzzleClient($this->guzzleClient);
96
//         $classPasses = $this->client->getClassPasses();
97
//         $this->assertEquals('cp-vk3x1brhpsbf', $classPasses[0]->id);
98
//     }
99
    
100
//     /**
101
//      * @covers InShore\Bookwhen\Client::__construct
102
//      * @covers InShore\Bookwhen\Client::getClassPass
103
//      * @covers InShore\Bookwhen\Client::request
104
//      * @uses InShore\Bookwhen\Validator
105
//      * @uses InShore\Bookwhen\Exceptions\ValidationException
106
//      */
107
//     public function testGetClassPassWithValidClassPassId()
108
//     {
109
//         $this->mockHandler->append(new Response('200', [], file_get_contents(__DIR__ . '/fixtures/classpass_200.json')));
110
//         $this->client->setGuzzleClient($this->guzzleClient);
111
//         $classPass = $this->client->getClassPass('cp-vk3x1brhpsbf');
112
//         $this->assertEquals('cp-vk3x1brhpsbf', $classPass->id);
113
//     }
114
    
115
//     /**
116
//      * @covers InShore\Bookwhen\Client::__construct
117
//      * @covers InShore\Bookwhen\Client::getEvent
118
//      * @covers InShore\Bookwhen\Client::request
119
//      * @uses InShore\Bookwhen\Validator
120
//      * @uses InShore\Bookwhen\Exceptions\ValidationException
121
//      */
122
//     public function testGetEventWithValidEventId()
123
//     { 
124
//         $this->mockHandler->append(new Response('200', [], file_get_contents(__DIR__ . '/fixtures/event_200.json')));
125
//         $this->client->setGuzzleClient($this->guzzleClient);
126
//         $event = $this->client->getEvent('ev-sf8b-20200813100000');
127
//         $this->assertEquals('ev-sboe-20200320100000', $event->id);
128
//         $this->assertFalse($event->soldOut, 'Not sold Out');
129
//     }
130
131
//     /**
132
//      * @covers InShore\Bookwhen\Client::__construct
133
//      * @covers InShore\Bookwhen\Client::getEvents
134
//      * @covers InShore\Bookwhen\Client::request
135
//      * @uses InShore\Bookwhen\Validator
136
//      */
137
//     public function testGetEvents()
138
//     {
139
//         $this->mockHandler->append(new Response('200', [], file_get_contents(__DIR__ . '/fixtures/events_200.json')));
140
//         $this->client->setGuzzleClient($this->guzzleClient);
141
//         $events = $this->client->getEvents();
142
//         $this->assertIsArray($events);
143
//         $this->assertEquals('ev-sboe-20200320100000', $events[0]->id);
144
//         $this->assertFalse($events[0]->soldOut, 'Not sold Out');
145
//     }
146
147
//     /**
148
//      * @covers InShore\Bookwhen\Client::__construct
149
//      * @covers InShore\Bookwhen\Client::getLocations
150
//      * @covers InShore\Bookwhen\Client::request
151
//      * @uses InShore\Bookwhen\Validator
152
//      * @uses InShore\Bookwhen\Exceptions\ValidationException
153
//      */
154
//     public function testGetLocations()
155
//     {
156
//         $this->mockHandler->append(new Response('200', [], file_get_contents(__DIR__ . '/fixtures/locations_200.json')));
157
//         $this->client->setGuzzleClient($this->guzzleClient);
158
//         $locations = $this->client->getLocations('sjm7pskr31t3');
159
//         $this->assertEquals('sjm7pskr31t3', $locations[0]->id);
160
//     }
161
    
162
//     /**
163
//      * @covers InShore\Bookwhen\Client::__construct
164
//      * @covers InShore\Bookwhen\Client::getLocation
165
//      * @covers InShore\Bookwhen\Client::request
166
//      * @uses InShore\Bookwhen\Validator
167
//      * @uses InShore\Bookwhen\Exceptions\ValidationException
168
//      */
169
//     public function testGetLocationWithValidLocationId()
170
//     {
171
//         $this->mockHandler->append(new Response('200', [], file_get_contents(__DIR__ . '/fixtures/location_200.json')));
172
//         $this->client->setGuzzleClient($this->guzzleClient);
173
//         $location = $this->client->getLocation('sjm7pskr31t3');
174
//         $this->assertEquals('sjm7pskr31t3', $location->id);
175
//     }
176
177
    
178
//     /**
179
//      * @covers InShore\Bookwhen\Client::__construct
180
//      * @covers InShore\Bookwhen\Client::getTicket
181
//      * @covers InShore\Bookwhen\Client::request
182
//      * @uses InShore\Bookwhen\Validator
183
//      */
184
//     public function testGetTicketWithValidTicketId()
185
//     {
186
//         $this->mockHandler->append(new Response('200', [], file_get_contents(__DIR__ . '/fixtures/ticket_200.json')));
187
//         $this->client->setGuzzleClient($this->guzzleClient);
188
//         $ticket = $this->client->getTicket('ti-sboe-20200320100000-tk1m');
189
//         $this->assertEquals('ti-sboe-20200320100000-tk1m', $ticket->id);
190
//     }
191
    
192
//     /**
193
//      * @covers InShore\Bookwhen\Client::__construct
194
//      * @covers InShore\Bookwhen\Client::getTickets
195
//      * @covers InShore\Bookwhen\Client::request
196
//      * @uses InShore\Bookwhen\Validator
197
//      * @uses InShore\Bookwhen\Exceptions\ValidationException
198
//      */
199
//     public function testGetTicketsWithInValidEventId()
200
//     {
201
//         $this->expectException(ValidationException::class);
202
//         $this->mockHandler->append(new Response('200', [], file_get_contents(__DIR__ . '/fixtures/tickets_200.json')));
203
//         $this->client->setGuzzleClient($this->guzzleClient);
204
//         $tickets = $this->client->getTickets('ti-sboe-20200320100000-tk1m');
205
//         $this->assertIsArray($tickets);
206
//     }
207
    
208
//     /**
209
//      * @covers InShore\Bookwhen\Client::__construct
210
//      * @covers InShore\Bookwhen\Client::getTickets
211
//      * @covers InShore\Bookwhen\Client::request
212
//      * @uses InShore\Bookwhen\Validator
213
//      */
214
//     public function testGetTicketsWithValidEventId()
215
//     {
216
//         $this->mockHandler->append(new Response('200', [], file_get_contents(__DIR__ . '/fixtures/tickets_200.json')));
217
//         $this->client->setGuzzleClient($this->guzzleClient);
218
//         $tickets = $this->client->getTickets('ev-sf8b-20200813100000');
219
//         $this->assertIsArray($tickets);
220
//     }
221
    
222
    
223
// }
224
225
// // EOF!
226