Completed
Push — master ( 29ee36...92bd35 )
by Tom
03:51
created

DisableCommandTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 1
dl 31
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testDisableNonexistentCache() 11 11 1
A getExpectedOutput() 11 11 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @todo    writing unit tests for toggling caches is complicated because environments differ
4
 *          touching caches changes state and will result in different test result second time
5
 *          solutions: disabling/enabling, faking&mocking or having one defined test environment
6
 */
7
8
namespace N98\Magento\Command\Cache;
9
10
use N98\Magento\Command\TestCase;
11
12 View Code Duplication
class DisableCommandTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class 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...
13
{
14
    const NONEXISTENT_CACHE_TYPE = 'FAKE_CACHE_TYPE';
15
16
    public function testDisableNonexistentCache()
17
    {
18
        $expectedOutput = $this->getExpectedOutput();
19
20
        $input = array(
21
            'command' => 'cache:disable',
22
            'type'    => self::NONEXISTENT_CACHE_TYPE,
23
        );
24
25
        $this->assertDisplayContains($input, $expectedOutput);
26
    }
27
28
    /**
29
     * @return string
30
     */
31
    private function getExpectedOutput()
32
    {
33
        $buffer =
34
            sprintf(
35
                DisableCommand::INVALID_TYPES_MESSAGE,
36
                self::NONEXISTENT_CACHE_TYPE
37
            ) . PHP_EOL . DisableCommand::ABORT_MESSAGE . PHP_EOL;
38
39
        // Strip tags because of console formatting (<info> etc)
40
        return strip_tags($buffer);
41
    }
42
}
43