Test Setup Failed
Push — master ( d9a06b...c9d9e0 )
by Chema
03:47
created

NotifyCommandTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
dl 0
loc 24
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A test_non_existing_ticker() 0 4 1
A runCommand() 0 5 1
A test_existing_ticker() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chemaclass\StockTickerTests\Feature\Infrastructure\Command;
6
7
use Chemaclass\StockTicker\Infrastructure\Command\NotifyCommand;
8
use Gacela\Framework\Gacela;
9
use PHPUnit\Framework\TestCase;
10
use Symfony\Component\Console\Command\Command;
11
use Symfony\Component\Console\Input\StringInput;
12
use Symfony\Component\Console\Output\OutputInterface;
13
14
final class NotifyCommandTest extends TestCase
15
{
16
    protected function setUp(): void
17
    {
18
        Gacela::bootstrap(__DIR__);
19
    }
20
21
    public function test_existing_ticker(): void
22
    {
23
        $actual = $this->runCommand('GM --channels=fake --maxNews=1 --maxRepetitions=1 --sleepingTime=0');
24
        self::assertSame(Command::SUCCESS, $actual);
25
    }
26
27
    public function test_non_existing_ticker(): void
28
    {
29
        $actual = $this->runCommand('UNKNOWN_TICKER --channels=fake --maxNews=1 --maxRepetitions=1 --sleepingTime=0');
30
        self::assertSame(Command::SUCCESS, $actual);
31
    }
32
33
    private function runCommand(string $inputString): int
34
    {
35
        return (new NotifyCommand())->run(
36
            new StringInput($inputString),
37
            $this->createMock(OutputInterface::class),
38
        );
39
    }
40
}
41