Passed
Pull Request — master (#4)
by Chema
02:47
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
    public function testInvoke(): void
15
    {
16
        $foundMoreNews = new IsBuyHigherThanSell();
17
18
        $company = $this->createCompanyWithNews([
19
            '0m' => [
20
                'strongBuy' => '1',
21
                'buy' => '2',
22
                'sell' => '3',
23
                'strongSell' => '4',
24
            ],
25
            '-1m' => [
26
                'strongBuy' => '1',
27
                'buy' => '2',
28
                'sell' => '3',
29
                'strongSell' => '4',
30
            ],
31
        ]);
32
        // ((1 + 2) * 2) > ((3 + 4) * 2)
33
        self::assertFalse($foundMoreNews($company));
34
    }
35
36
    private function createCompanyWithNews(array $trend): Company
37
    {
38
        return new Company(
39
            Symbol::fromString('SYMBOL'),
40
            [
41
                IsBuyHigherThanSell::TREND => $trend,
42
            ]
43
        );
44
    }
45
}
46