Passed
Push — master ( 3ec735...0b5e67 )
by Chema
01:36 queued 14s
created

ComparingTwoGroupsTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testInvoke() 0 24 1
A createCompanyWithNews() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chemaclass\StockTickerTests\Unit\Domain\Notifier\Policy\Condition;
6
7
use Chemaclass\StockTicker\Domain\Notifier\Policy\Condition\ComparingTwoGroups;
0 ignored issues
show
Bug introduced by
The type Chemaclass\StockTicker\D...tion\ComparingTwoGroups 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...
8
use Chemaclass\StockTicker\Domain\ReadModel\Company;
9
use Chemaclass\StockTicker\Domain\ReadModel\Symbol;
10
use PHPUnit\Framework\TestCase;
11
12
final class ComparingTwoGroupsTest extends TestCase
13
{
14
    private const KEY = 'the key where the groups are';
15
16
    public function testInvoke(): void
17
    {
18
        $foundMoreNews = new ComparingTwoGroups(
19
            self::KEY,
20
            ['a', 'b'],
21
            ['c', 'd'],
22
        );
23
24
        $company = $this->createCompanyWithNews([
25
            '0m' => [
26
                'a' => '1',
27
                'b' => '2',
28
                'c' => '3',
29
                'd' => '4',
30
            ],
31
            '-1m' => [
32
                'a' => '1',
33
                'b' => '2',
34
                'c' => '3',
35
                'd' => '4',
36
            ],
37
        ]);
38
        // ((1 + 2) * 2) > ((3 + 4) * 2)
39
        self::assertFalse($foundMoreNews($company));
40
    }
41
42
    private function createCompanyWithNews(array $trend): Company
43
    {
44
        return new Company(
45
            Symbol::fromString('SYMBOL'),
46
            [
47
                self::KEY => $trend,
48
            ]
49
        );
50
    }
51
}
52