Passed
Pull Request — master (#1)
by Aydin
02:24
created

BufferedOutputTest::testToString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
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