Passed
Pull Request — master (#4)
by Chema
02:57
created

IsBuyBiggerThanSellTest::testInvoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 13
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 20
rs 9.8333
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\IsBuyHigherThanSell;
0 ignored issues
show
Bug introduced by
The type Chemaclass\StockTicker\D...ion\IsBuyHigherThanSell 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 IsBuyBiggerThanSellTest extends TestCase
13
{
14
    private const TREND = 'the key for trend';
15
16
    public function testInvoke(): void
17
    {
18
        $foundMoreNews = new IsBuyHigherThanSell(self::TREND);
19
20
        $company = $this->createCompanyWithNews([
21
            '0m' => [
22
                'strongBuy' => '1',
23
                'buy' => '2',
24
                'sell' => '3',
25
                'strongSell' => '4',
26
            ],
27
            '-1m' => [
28
                'strongBuy' => '1',
29
                'buy' => '2',
30
                'sell' => '3',
31
                'strongSell' => '4',
32
            ],
33
        ]);
34
        // ((1 + 2) * 2) > ((3 + 4) * 2)
35
        self::assertFalse($foundMoreNews($company));
36
    }
37
38
    private function createCompanyWithNews(array $trend): Company
39
    {
40
        return new Company(
41
            Symbol::fromString('SYMBOL'),
42
            [
43
                self::TREND => $trend,
44
            ]
45
        );
46
    }
47
}
48