Passed
Branch feature/tests (366918)
by Michał
05:45
created

AbstractParserTest::setParser()   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 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Dziki\MonologSentryBundle\Tests\Unit\UserAgent;
6
7
use Dziki\MonologSentryBundle\UserAgent\Parser;
8
use Dziki\MonologSentryBundle\UserAgent\UserAgent;
9
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...
10
11
abstract class AbstractParserTest extends TestCase
12
{
13
    /** @var Parser */
14
    private $parser;
15
16
    public function validUserAgentsDataProvider(): array
17
    {
18
        return [
19
            [
20
                'Mozilla/5.0 (X11; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0',
21
                UserAgent::create('Firefox', '62.0', 'Linux'),
22
            ],
23
        ];
24
    }
25
26
    protected function setParser(Parser $parser): void
27
    {
28
        $this->parser = $parser;
29
    }
30
31
    /**
32
     * @test
33
     * @dataProvider validUserAgentsDataProvider
34
     *
35
     * @param string $userAgent
36
     * @param UserAgent $expectedUserAgent
37
     */
38
    public function parseValidUserAgent(string $userAgent, UserAgent $expectedUserAgent): void
39
    {
40
        $resultedUserAgent = $this->parser->parse($userAgent);
41
42
        $this->assertEquals($expectedUserAgent, $resultedUserAgent);
43
    }
44
}