Completed
Pull Request — develop (#27)
by Chris
12:16
created

TextStreamTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test() 0 10 1
A dataProvider() 0 7 1
1
<?php
2
3
namespace Chrisyue\PhpM3u8\Tests\Stream;
4
5
use PHPUnit\Framework\TestCase;
6
use Chrisyue\PhpM3u8\Stream\TextStream;
7
8
class TextStreamTest extends TestCase
9
{
10
    /**
11
     * @dataProvider dataProvider
12
     */
13
    public function test($text, $firstValid, $firstInfo, $secondValid, $secondInfo)
14
    {
15
        $stream = new TextStream($text);
16
        $this->assertSame($firstValid, $stream->valid());
17
        $this->assertSame($firstInfo, $stream->read());
18
19
        $stream->next();
20
        $this->assertSame($secondValid, $stream->valid());
21
        $this->assertSame($secondInfo, $stream->read());
22
    }
23
24
    public function dataProvider()
25
    {
26
        return [
27
            ["#TAG1\n#TAG2", true, ['tag' => '#TAG1', 'value' => ''], true, ['tag' => '#TAG2', 'value' => '']],
28
            ["#TAG1", true, ['tag' => '#TAG1', 'value' => ''], false, null],
29
        ];
30
    }
31
}
32