BufferedOutputTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 20
c 1
b 0
f 0
dl 0
loc 46
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testFetch() 0 6 1
A testFetchWithoutCleaning() 0 10 1
A testFetchWithMultipleWrites() 0 7 1
A testFetchCleansBufferByDefault() 0 7 1
A testToString() 0 6 1
1
<?php
2
3
namespace PhpSchool\TerminalTest\IO;
4
5
use PhpSchool\Terminal\IO\BufferedOutput;
6
use PHPUnit\Framework\TestCase;
7
8
/**
9
 * @author Aydin Hassan <[email protected]>
10
 */
11
class BufferedOutputTest extends TestCase
12
{
13
    public function testFetch() : void
14
    {
15
        $output = new BufferedOutput;
16
        $output->write('one');
17
18
        static::assertEquals('one', $output->fetch());
19
    }
20
21
    public function testFetchWithMultipleWrites() : void
22
    {
23
        $output = new BufferedOutput;
24
        $output->write('one');
25
        $output->write('two');
26
27
        static::assertEquals('onetwo', $output->fetch());
28
    }
29
30
    public function testFetchCleansBufferByDefault() : void
31
    {
32
        $output = new BufferedOutput;
33
        $output->write('one');
34
35
        static::assertEquals('one', $output->fetch());
36
        static::assertEquals('', $output->fetch());
37
    }
38
39
    public function testFetchWithoutCleaning() : void
40
    {
41
        $output = new BufferedOutput;
42
        $output->write('one');
43
44
        static::assertEquals('one', $output->fetch(false));
45
46
        $output->write('two');
47
48
        static::assertEquals('onetwo', $output->fetch(false));
49
    }
50
51
    public function testToString() : void
52
    {
53
        $output = new BufferedOutput;
54
        $output->write('one');
55
56
        static::assertEquals('one', (string) $output);
57
    }
58
}
59