Completed
Push — master ( 206d9f...261a93 )
by Pablo
02:52
created

CommandBusTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
rs 9.4285
c 1
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\CommandApplication;
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 CommandApplication
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 CommandApplication();
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 View Code Duplication
    public function itShouldHandleWithPreMiddleWare()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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->assertFalse(file_exists($preHandlerFilename));
62
        $this->assertTrue(file_exists($handlerFilename));
63
64
        unlink($handlerFilename);
65
    }
66
67
    /**
68
     * @test
69
     * @group active
70
     */
71 View Code Duplication
    public function itShouldHandleWithPostMiddleWare()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
72
    {
73
        $this->app->setCommand(new WithPostMiddleWareCommand());
74
75
        $this->app->doRun($this->input, $this->outputInterface);
76
77
        $handlerFilename = __DIR__ . '/' . WithPostMiddleWareHandler::FILE_TEST;
78
        $postHandlerFilename = __DIR__.'/'. PostMiddleWareHandler::FILE_TEST;
79
        $this->assertFalse(file_exists($handlerFilename));
80
        $this->assertTrue(file_exists($postHandlerFilename));
81
82
        unlink($postHandlerFilename);
83
84
    }
85
}
86