1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of php-task library. |
5
|
|
|
* |
6
|
|
|
* (c) php-task |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Task\TaskBundle\Functional\Command; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
15
|
|
|
use Task\TaskBundle\Tests\Functional\BaseCommandTestCase; |
16
|
|
|
use Task\TaskBundle\Tests\Functional\TestHandler; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Tests for RunHandlerCommand. |
20
|
|
|
*/ |
21
|
|
|
class RunHandlerCommandTest extends BaseCommandTestCase |
22
|
|
|
{ |
23
|
|
View Code Duplication |
public function testExecute() |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
$this->commandTester->execute( |
26
|
|
|
[ |
27
|
|
|
'command' => $this->command->getName(), |
28
|
|
|
'handlerClass' => TestHandler::class, |
29
|
|
|
], |
30
|
|
|
[ |
31
|
|
|
'verbosity' => OutputInterface::VERBOSITY_VERBOSE, |
32
|
|
|
] |
33
|
|
|
); |
34
|
|
|
|
35
|
|
|
$output = $this->commandTester->getDisplay(); |
36
|
|
|
$this->assertContains('No workload.', $output); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
View Code Duplication |
public function testExecuteWithWorkload() |
|
|
|
|
40
|
|
|
{ |
41
|
|
|
$this->commandTester->execute( |
42
|
|
|
[ |
43
|
|
|
'command' => $this->command->getName(), |
44
|
|
|
'handlerClass' => TestHandler::class, |
45
|
|
|
'workload' => 'Test workload 1', |
46
|
|
|
], |
47
|
|
|
[ |
48
|
|
|
'verbosity' => OutputInterface::VERBOSITY_VERBOSE, |
49
|
|
|
] |
50
|
|
|
); |
51
|
|
|
|
52
|
|
|
$output = $this->commandTester->getDisplay(); |
53
|
|
|
$this->assertContains(strrev('Test workload 1'), $output); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
View Code Duplication |
public function testExecuteWithWorkloadNoVerbosity() |
|
|
|
|
57
|
|
|
{ |
58
|
|
|
$this->commandTester->execute( |
59
|
|
|
[ |
60
|
|
|
'command' => $this->command->getName(), |
61
|
|
|
'handlerClass' => TestHandler::class, |
62
|
|
|
'workload' => 'Test workload 1', |
63
|
|
|
] |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
$output = $this->commandTester->getDisplay(); |
67
|
|
|
$this->assertEquals('', $output); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
|
|
*/ |
73
|
|
|
protected function getCommand() |
74
|
|
|
{ |
75
|
|
|
return self::$kernel->getContainer()->get('task.command.run_handler'); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
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.