DomainTest::testStreamObject()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 19
rs 9.4285
cc 1
eloc 14
nc 1
nop 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 13 and the first side effect is on line 6.

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.

Loading history...
2
3
use VideoPublisher\Domain\SimpleStream;
4
use VideoPublisher\Domain\Stream;
5
6
include_once 'src/VideoPublisher/AutoLoader.php';
7
8
/**
9
 * Class DomainTest.
10
 *
11
 * @author Bart Malestein <[email protected]>
12
 */
13
class DomainTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
14
{
15
16
    public function testSimpleStreamObject()
17
    {
18
        $simpleStream = new SimpleStream([
0 ignored issues
show
Documentation introduced by
array('streamName' => 't...ck', 'enabled' => true) is of type array<string,string|bool...","enabled":"boolean"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
19
            'streamName' => 'test',
20
            'uuid' => '00000000-0000-0000-0000-00000000',
21
            'status' => 'mock',
22
            'enabled' => true
23
        ]);
24
25
        $this->assertEquals(true, $simpleStream->getEnabled());
26
        $this->assertEquals('test', $simpleStream->getName());
27
    }
28
29
    public function testStreamObject()
30
    {
31
        $stream = new Stream([
32
            'streamName' => 'test',
33
            'uuid' => '00000000-0000-0000-0000-00000000',
34
            'status' => 'mock',
35
            'enabled' => true,
36
            'viewable' => true,
37
            'view' => [
38
                'playout_url' => 'http://playout.com/video.mp4',
39
                'video_player' => 'http://playout.com/player/video.mp4'
40
            ]
41
        ]);
42
43
        $this->assertEquals('mock', $stream->getStatus());
44
        $this->assertEquals('test', $stream->getName());
45
        $this->assertEquals('http://playout.com/video.mp4', $stream->getView()->getPlayoutUrl());
46
        $this->assertEquals('http://playout.com/player/video.mp4', $stream->getView()->getVideoPlayer());
47
    }
48
}