-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClientUsageTest.php
103 lines (76 loc) · 2.63 KB
/
ClientUsageTest.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
<?php
namespace Tests\Integration;
use InvalidArgumentException;
use Tests\TestCase;
use Tests\Fixtures\MockableClient;
use Oneofftech\KlinkStreaming\Client;
use Oneofftech\KlinkStreaming\Video;
use Oneofftech\KlinkStreaming\Upload;
class ClientUsageTest extends TestCase
{
protected function setUp(): void
{
if (empty(getenv('VIDEO_STREAMING_SERVICE_URL'))) {
$this->markTestSkipped(
'The VIDEO_STREAMING_SERVICE_URL is not configured.'
);
}
}
public function test_add_video()
{
$url = getenv('VIDEO_STREAMING_SERVICE_URL');
$app_token = 'token';
$app_url = 'url';
$videos = new Client($url, $app_token, $app_url);
$video_path = __DIR__ .'/../data/video.mp4';
$upload = $videos->add($video_path);
$this->assertNotNull($upload);
$this->assertInstanceOf(Upload::class, $upload);
$this->assertNotNull($upload->videoId());
return $upload->videoId();
}
/**
* @depends test_add_video
*/
public function test_get_added_video($video_id)
{
$url = getenv('VIDEO_STREAMING_SERVICE_URL');
$app_token = 'token';
$app_url = 'url';
$videos = new Client($url, $app_token, $app_url);
$video = $videos->get($video_id);
$this->assertNotNull($video);
$this->assertInstanceOf(Video::class, $video);
$this->assertNotEmpty($video->video_id);
$this->assertNotEmpty($video->created_at);
$this->assertNotEmpty($video->updated_at);
$this->assertNotEmpty($video->status);
$this->assertNotEmpty($video->url);
return $video_id;
}
/**
* @depends test_get_added_video
*/
public function test_delete_added_video($video_id)
{
$url = getenv('VIDEO_STREAMING_SERVICE_URL');
$app_token = 'token';
$app_url = 'url';
$videos = new Client($url, $app_token, $app_url);
$video = $videos->delete($video_id);
$this->assertNotNull($video);
$this->assertInstanceOf(Video::class, $video);
$this->assertNotEmpty($video->video_id);
$this->assertNotEmpty($video->status);
$this->assertEquals('deleted', $video->status);
}
public function test_get_non_existing_video()
{
$url = getenv('VIDEO_STREAMING_SERVICE_URL');
$app_token = 'token';
$app_url = 'url';
$videos = new Client($url, $app_token, $app_url);
$this->expectException(InvalidArgumentException::class);
$video = $videos->get('20170813');
}
}