1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
use VideoPublisher\Domain\SimpleStream; |
4
|
|
|
use VideoPublisher\Domain\Stream; |
5
|
|
|
use VideoPublisher\Tests\Dummy\DummyAuthentication; |
6
|
|
|
use VideoPublisher\Tests\Dummy\DummyConnection; |
7
|
|
|
use VideoPublisher\VideoPublisherClient; |
8
|
|
|
|
9
|
|
|
include_once 'src/VideoPublisher/AutoLoader.php'; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class ConnectionTest. |
13
|
|
|
* |
14
|
|
|
* @author Bart Malestein <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class ConnectionTest extends \PHPUnit_Framework_TestCase |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* List stream test |
21
|
|
|
*/ |
22
|
|
|
public function testListStreams() |
23
|
|
|
{ |
24
|
|
|
$client = new VideoPublisherClient(new DummyAuthentication(), 'src', 'http://my.videopublisher.io/', new DummyConnection()); |
25
|
|
|
$simpleStreams = $client->listStreams(); |
26
|
|
|
|
27
|
|
|
$this->assertEquals(3, count($simpleStreams)); |
28
|
|
|
$this->assertContainsOnlyInstancesOf(SimpleStream::class, $simpleStreams); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @expectedException \VideoPublisher\Exception\BadResponseException |
33
|
|
|
*/ |
34
|
|
|
public function testListStreamsException() |
35
|
|
|
{ |
36
|
|
|
$client = new VideoPublisherClient(new DummyAuthentication(), 'src', 'http://my.videopublisher.io/exception', new DummyConnection()); |
37
|
|
|
$client->listStreams(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Get stream test |
42
|
|
|
*/ |
43
|
|
|
public function testGetStream() |
44
|
|
|
{ |
45
|
|
|
$client = new VideoPublisherClient(new DummyAuthentication(), 'src', 'http://my.videopublisher.io/', new DummyConnection()); |
46
|
|
|
$stream = $client->getStream('00000000-0000-0000-0000-00000000'); |
47
|
|
|
|
48
|
|
|
$this->assertEquals('00000000-0000-0000-0000-00000000', $stream->getUuid()); |
49
|
|
|
$this->assertEquals('mock', $stream->getStatus()); |
50
|
|
|
$this->assertEquals('http://playout.com/video.mp4', $stream->getView()->getPlayoutUrl()); |
51
|
|
|
$this->assertEquals('http://playout.com/player/video.mp4', $stream->getView()->getVideoPlayer()); |
52
|
|
|
$this->assertInstanceOf(Stream::class, $stream); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @expectedException \VideoPublisher\Exception\StreamNotFoundException |
57
|
|
|
*/ |
58
|
|
|
public function testGetStreamException() |
59
|
|
|
{ |
60
|
|
|
$client = new VideoPublisherClient(new DummyAuthentication(), 'src', 'http://my.videopublisher.io/exception', new DummyConnection()); |
61
|
|
|
$client->getStream('00000000-0000-0000-0000-00000000'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
} |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.