Passed
Pull Request — master (#2)
by Korotkov
02:32
created

InterpreterTest::testAlbum()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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