Passed
Push — master ( 35eebd...7b8a1a )
by Roman
16:45
created

testSuccessfullyValidateAnswers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 14
ccs 0
cts 10
cp 0
crap 2
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Tests\Game\Features\Answers;
6
7
use App\Game\Features\Answers\AnswersValidator;
8
use App\Game\Features\Answers\WrongAnswerException;
9
use App\Game\Infrastructure\Encoder\Base64Encoder;
10
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
/**
13
 * @coversDefaultClass \App\Game\Features\Answers\AnswersValidator
14
 */
15
final class AnswersValidatorTest extends TestCase
16
{
17
    /**
18
     * @covers ::validate
19
     */
20
    public function testSuccessfullyValidateAnswers(): void
21
    {
22
        $encoder = new Base64Encoder();
23
        $answers = [
24
            ['index' => 0, 'letter' => $encoder->encode('t'), 'value' => 't'],
25
            ['index' => 1, 'letter' => $encoder->encode('e'), 'value' => 'e'],
26
            ['index' => 2, 'letter' => $encoder->encode('s'), 'value' => 's'],
27
            ['index' => 3, 'letter' => $encoder->encode('t'), 'value' => 't'],
28
        ];
29
30
        $answersValidator = new AnswersValidator($encoder);
31
        $answersValidator->validate($answers);
32
33
        self::assertTrue(true);
34
    }
35
36
    /**
37
     * @covers ::validate
38
     */
39
    public function testRaiseExceptionWhenAnswersIsWrong(): void
40
    {
41
        $this->expectException(WrongAnswerException::class);
42
43
        $encoder = new Base64Encoder();
44
        $answers = [
45
            ['index' => 0, 'letter' => $encoder->encode('t'), 'value' => 't'],
46
            ['index' => 1, 'letter' => $encoder->encode('e'), 'value' => 'e'],
47
            ['index' => 2, 'letter' => $encoder->encode('s'), 'value' => 'k'],
48
            ['index' => 3, 'letter' => $encoder->encode('t'), 'value' => 'e'],
49
        ];
50
51
        $answersValidator = new AnswersValidator($encoder);
52
        $answersValidator->validate($answers);
53
    }
54
}
55