Completed
Push — master ( 9466a4...206d9f )
by Pablo
04:08
created

CommandBusTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Bruli\EventBusBundleTests\Behaviour;
4
5
use Bruli\EventBusBundleTests\Infrastructure\Application;
6
use Bruli\EventBusBundleTests\Behaviour\SingleCommand;
7
use Bruli\EventBusBundleTests\Behaviour\SingleCommandHandler;
8
use Mockery\Mock;
9
use PHPUnit\Framework\TestCase;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
class CommandBusTest extends TestCase
14
{
15
    /**
16
     * @var Application
17
     */
18
    private $app;
19
    /**
20
     * @var InputInterface
21
     */
22
    private $input;
23
    /**
24
     * @var OutputInterface
25
     */
26
    private $outputInterface;
27
28
    protected function setUp()
29
    {
30
        $this->app =  new Application();
31
        $this->input = \Mockery::mock(InputInterface::class);
32
        $this->outputInterface = \Mockery::mock(OutputInterface::class);
33
    }
34
35
    /**
36
     * @test
37
     */
38
    public function itShouldHandleSingleHandler()
39
    {
40
        $this->app->setCommand(new SingleCommand());
41
42
        $this->app->doRun($this->input, $this->outputInterface);
43
44
        $filename = __DIR__ . '/' . SingleCommandHandler::FILE_TEST;
45
        $this->assertTrue(file_exists($filename));
46
47
        unlink($filename);
48
    }
49
50
    /**
51
     * @test
52
     */
53
    public function itShouldHandleWithPreMiddleWare()
54
    {
55
        $this->app->setCommand(new WithPreMiddleWareCommand());
56
57
        $this->app->doRun($this->input, $this->outputInterface);
58
59
        $handlerFilename = __DIR__ . '/' . WithPreMiddleWareHandler::FILE_TEST;
60
        $preHandlerFilename = __DIR__.'/'. PreMiddleWareHandler::FILE_TEST;
61
        $this->assertTrue(file_exists($handlerFilename));
62
        $this->assertTrue(file_exists($preHandlerFilename));
63
64
        unlink($handlerFilename);
65
        unlink($preHandlerFilename);
66
    }
67
}
68