Completed
Push — master ( 29ee36...16ede1 )
by Tom
03:58
created

EnableCommandTest::testEnableNonexistentCache()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 10
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
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 EnableCommandTest 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 testEnableNonexistentCache()
17
    {
18
        $input = array(
19
            'command' => 'cache:enable',
20
            'type'    => self::NONEXISTENT_CACHE_TYPE,
21
        );
22
        $expectedOutput = $this->getExpectedOutput();
23
24
        $this->assertDisplayContains($input, $expectedOutput);
25
    }
26
27
    /**
28
     * @return string
29
     */
30
    private function getExpectedOutput()
31
    {
32
        $buffer =
33
            sprintf(
34
                EnableCommand::INVALID_TYPES_MESSAGE,
35
                self::NONEXISTENT_CACHE_TYPE
36
            ) . PHP_EOL . EnableCommand::ABORT_MESSAGE . PHP_EOL;
37
38
        // Strip tags because of console formatting (<info> etc)
39
        return strip_tags($buffer);
40
    }
41
}
42