Completed
Push — master ( cc06f5...b0a397 )
by Korotkov
02:50 queued 01:19
created

InterpreterTest::getInterpreter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author  : Jagepard <[email protected]>
7
 * @license https://mit-license.org/ MIT
8
 */
9
10
namespace Behavioral\Interpreter\Tests;
11
12
use Behavioral\Interpreter\Album;
13
use Behavioral\Interpreter\Interpreter;
14
use Behavioral\Interpreter\InterpreterInterface;
15
use PHPUnit\Framework\TestCase as PHPUnit_Framework_TestCase;
16
17
class InterpreterTest extends PHPUnit_Framework_TestCase
18
{
19
    /**
20
     * @var InterpreterInterface
21
     */
22
    protected $interpreter;
23
24
    protected function setUp(): void
25
    {
26
        $this->interpreter = new Interpreter();
27
        $this->interpreter->addItem(new Album('Korn', 'Untouchables'));
28
        $this->interpreter->addItem(new Album('Deftones', 'Adrenaline'));
29
    }
30
31
    public function testAlbum(): void
32
    {
33
        ob_start();
34
        $this->interpreter->interpret('album 2');
35
        $album = ob_get_clean();
36
        $this->assertEquals($album, sprintf("%s \n",  'Deftones'));
37
38
        ob_start();
39
        $this->interpreter->interpret('2 album');
40
        $album = ob_get_clean();
41
        $this->assertEquals($album, sprintf("%s \n",  'Deftones'));
42
    }
43
44
    public function testAuthor(): void
45
    {
46
        ob_start();
47
        $this->interpreter->interpret('author 2');
48
        $album = ob_get_clean();
49
        $this->assertEquals($album, sprintf("%s\n",  'Adrenaline'));
50
51
        ob_start();
52
        $this->interpreter->interpret('2 author');
53
        $album = ob_get_clean();
54
        $this->assertEquals($album, sprintf("%s\n",  'Adrenaline'));
55
    }
56
}
57