1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace VideoPublisher\Tests\Dummy; |
4
|
|
|
|
5
|
|
|
use VideoPublisher\Connection\ConnectionInterface; |
6
|
|
|
use VideoPublisher\Connection\Curl\CurlResponse; |
7
|
|
|
use VideoPublisher\Connection\ResponseInterface; |
8
|
|
|
use VideoPublisher\Payload\Payload; |
9
|
|
|
|
10
|
|
|
class DummyConnection implements ConnectionInterface |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @param Payload $payload |
15
|
|
|
* @return ResponseInterface |
16
|
|
|
*/ |
17
|
|
|
public function sendPayload(Payload $payload) |
18
|
|
|
{ |
19
|
|
|
switch ($payload->getUrl()) { |
20
|
|
|
case 'http://my.videopublisher.io/api/published': |
21
|
|
|
return $this->generateListStreamsResponse(); |
22
|
|
|
case 'http://my.videopublisher.io/api/publish/00000000-0000-0000-0000-00000000': |
23
|
|
|
return $this->generateGetStreamResponse(); |
24
|
|
|
case 'http://my.videopublisher.io/exception/api/published': |
25
|
|
|
return new CurlResponse(400, null, null); |
26
|
|
|
case 'http://my.videopublisher.io/exception/api/publish/00000000-0000-0000-0000-00000000': |
27
|
|
|
return new CurlResponse(400, null, null); |
28
|
|
|
} |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @return CurlResponse |
33
|
|
|
*/ |
34
|
|
|
private function generateListStreamsResponse() |
35
|
|
|
{ |
36
|
|
|
$streams = []; |
37
|
|
|
$streams[] = [ |
38
|
|
|
'streamName' => 'test', |
39
|
|
|
'uuid' => '00000000-0000-0000-0000-00000000', |
40
|
|
|
'status' => 'mock', |
41
|
|
|
'enabled' => true |
42
|
|
|
]; |
43
|
|
|
$streams[] = [ |
44
|
|
|
'streamName' => 'test', |
45
|
|
|
'uuid' => '00000000-0000-0000-0000-00000000', |
46
|
|
|
'status' => 'mock', |
47
|
|
|
'enabled' => true |
48
|
|
|
]; |
49
|
|
|
$streams[] = [ |
50
|
|
|
'streamName' => 'test', |
51
|
|
|
'uuid' => '00000000-0000-0000-0000-00000000', |
52
|
|
|
'status' => 'mock', |
53
|
|
|
'enabled' => true |
54
|
|
|
]; |
55
|
|
|
|
56
|
|
|
return new CurlResponse(200, null, json_encode($streams)); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return CurlResponse |
61
|
|
|
*/ |
62
|
|
|
private function generateGetStreamResponse() |
63
|
|
|
{ |
64
|
|
|
$stream = [ |
65
|
|
|
'streamName' => 'test', |
66
|
|
|
'uuid' => '00000000-0000-0000-0000-00000000', |
67
|
|
|
'status' => 'mock', |
68
|
|
|
'enabled' => true, |
69
|
|
|
'viewable' => true, |
70
|
|
|
'view' => [ |
71
|
|
|
'playout_url' => 'http://playout.com/video.mp4', |
72
|
|
|
'video_player' => 'http://playout.com/player/video.mp4' |
73
|
|
|
] |
74
|
|
|
]; |
75
|
|
|
return new CurlResponse(200, null, json_encode($stream)); |
76
|
|
|
} |
77
|
|
|
} |