1
|
|
|
<?php |
2
|
|
|
include '../vendor/autoload.php'; |
3
|
|
|
|
4
|
|
|
use Guzzle\Http; |
5
|
|
|
|
6
|
|
|
class TracksTest extends PHPUnit_Framework_TestCase |
7
|
|
|
{ |
8
|
|
|
protected $bundle = null; |
9
|
|
|
protected $media = 'http://media.clarify.io/audio/samples/harvard-sentences-1.wav'; |
10
|
|
|
|
11
|
|
|
public function setUp() |
12
|
|
|
{ |
13
|
|
|
global $apikey; |
14
|
|
|
|
15
|
|
|
$this->bundle = new \Clarify\Bundle($apikey); |
16
|
|
|
|
17
|
|
|
parent::setUp(); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @expectedException \Clarify\Exceptions\InvalidEnumTypeException |
22
|
|
|
*/ |
23
|
|
|
public function testCreateWithChannelException() |
24
|
|
|
{ |
25
|
|
|
$params = array(); |
26
|
|
|
$params['media_url'] = ''; |
27
|
|
|
$params['label'] = ''; |
28
|
|
|
$params['source'] = ''; |
29
|
|
|
$params['audio_channel'] = 'neither channel'; |
30
|
|
|
$this->bundle->tracks->create($params); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testCreate() |
34
|
|
|
{ |
35
|
|
|
$name = 'name - testCreate' . rand(0, 500); |
36
|
|
|
$this->bundle->create($name, $this->media); |
37
|
|
|
|
38
|
|
|
$this->assertEquals(201, $this->bundle->getStatusCode()); |
39
|
|
|
$location = $this->bundle->location; |
40
|
|
|
|
41
|
|
|
$params = array('media_url' => 'http://google.com', 'id' => $location); |
42
|
|
|
$this->bundle->tracks->create($params); |
43
|
|
|
|
44
|
|
|
$this->assertTrue($this->bundle->delete($location)); |
45
|
|
|
$this->assertEquals(204, $this->bundle->getStatusCode()); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testLoad() |
49
|
|
|
{ |
50
|
|
|
$name = 'name - testCreate' . rand(0, 500); |
51
|
|
|
$this->bundle->create($name, $this->media); |
52
|
|
|
|
53
|
|
|
$this->assertEquals(201, $this->bundle->getStatusCode()); |
54
|
|
|
$location = $this->bundle->location; |
55
|
|
|
|
56
|
|
|
$params = array('media_url' => 'http://google.com', 'id' => $location); |
57
|
|
|
$this->bundle->tracks->create($params); |
58
|
|
|
|
59
|
|
|
$resource = $this->bundle->tracks->load($location); |
60
|
|
|
$this->assertEquals(2, count($resource['tracks'])); |
61
|
|
|
$this->assertEquals('http://google.com', $resource['tracks'][1]['media_url']); |
62
|
|
|
|
63
|
|
|
$this->assertTrue($this->bundle->delete($location)); |
64
|
|
|
$this->assertEquals(204, $this->bundle->getStatusCode()); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function testDelete() |
68
|
|
|
{ |
69
|
|
|
$name = 'name - testCreate' . rand(0, 500); |
70
|
|
|
$this->bundle->create($name, $this->media); |
71
|
|
|
|
72
|
|
|
$this->assertEquals(201, $this->bundle->getStatusCode()); |
73
|
|
|
$location = $this->bundle->location; |
74
|
|
|
|
75
|
|
|
$params = array('media_url' => 'http://google.com', 'id' => $location); |
76
|
|
|
$this->bundle->tracks->create($params); |
77
|
|
|
|
78
|
|
|
$resource = $this->bundle->tracks->load($location); |
79
|
|
|
$this->assertEquals(2, count($resource['tracks'])); |
80
|
|
|
$this->bundle->tracks->delete($location); |
81
|
|
|
|
82
|
|
|
$resource = $this->bundle->tracks->load($location); |
83
|
|
|
$this->assertEquals(0, count($resource['tracks'])); |
84
|
|
|
|
85
|
|
|
$this->assertTrue($this->bundle->delete($location)); |
86
|
|
|
$this->assertEquals(204, $this->bundle->getStatusCode()); |
87
|
|
|
} |
88
|
|
|
} |