Completed
Push — master ( a37b73...8ce218 )
by Chris
02:15
created

ParserTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testParse() 0 7 1
A testParseFromUriWithoutSetLoader() 0 5 1
A testParserFromUri() 0 13 1
1
<?php
2
3
/*
4
 * This file is part of the PhpM3u8 package.
5
 *
6
 * (c) Chrisyue <http://chrisyue.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Chrisyue\PhpM3u8\Tests;
13
14
use Chrisyue\PhpM3u8\Parser;
15
use PHPUnit\Framework\TestCase;
16
17
class ParserTest extends TestCase
18
{
19
    public function testParse()
20
    {
21
        $parser = new Parser();
22
        $m3u8 = $parser->parse(DummyM3u8Factory::createM3u8Content());
23
24
        $this->assertEquals($m3u8, DummyM3u8Factory::createM3u8());
25
    }
26
27
    /**
28
     * @expectedException \BadMethodCallException
29
     */
30
    public function testParseFromUriWithoutSetLoader()
31
    {
32
        $parser = new Parser();
33
        $parser->parseFromUri('http://example.com/');
34
    }
35
36
    public function testParserFromUri()
37
    {
38
        $uri = 'http://example.com/';
39
40
        $loader = $this->prophesize('Chrisyue\PhpM3u8\Loader\LoaderInterface');
41
        $loader->load($uri)->shouldBeCalledTimes(1)->willReturn(DummyM3u8Factory::createM3u8Content());
42
43
        $parser = new Parser();
44
        $parser->setLoader($loader->reveal());
45
        $m3u8 = $parser->parseFromUri($uri);
46
47
        $this->assertEquals($m3u8, DummyM3u8Factory::createM3u8());
48
    }
49
}
50