StatusMessageTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 28.81 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 3
dl 17
loc 59
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructor() 0 13 2
A getClassName() 0 4 1
A getExpectations() 17 17 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
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace BaleenTest\Baleen\CommandBus\Config;
21
22
use Baleen\Cli\CommandBus\Config\AbstractConfigMessage;
23
use Baleen\Cli\CommandBus\Config\StatusMessage;
24
use Baleen\Cli\CommandBus\Util\ComparatorAwareInterface;
25
use Baleen\Cli\CommandBus\Util\RepositoryAwareInterface;
26
use Baleen\Cli\CommandBus\Util\StorageAwareInterface;
27
use BaleenTest\Cli\CommandBus\MessageTestCase;
28
use Mockery as m;
29
30
/**
31
 * Class StatusMessageTest
32
 * @author Gabriel Somoza <[email protected]>
33
 */
34
class StatusMessageTest extends MessageTestCase
35
{
36
37
    /**
38
     * Must test the constructor and assert implemented interfaces
39
     */
40
    public function testConstructor()
41
    {
42
        $instance = new StatusMessage();
43
        $list = [
44
            AbstractConfigMessage::class,
45
            RepositoryAwareInterface::class,
46
            StorageAwareInterface::class,
47
            ComparatorAwareInterface::class,
48
        ];
49
        foreach ($list as $expected) {
50
            $this->assertInstanceOf($expected, $instance);
51
        }
52
    }
53
54
    /**
55
     * getClassName must return a string with the FQN of the command class being tested
56
     * @return string
57
     */
58
    protected function getClassName()
59
    {
60
        return StatusMessage::class;
61
    }
62
63
    /**
64
     * Must return an array in the format:
65
     *
66
     *      [
67
     *          'name' => 'functionName', // required
68
     *          'with' => [arguments for with] // optional
69
     *          'return' => return value // optional, defaults to return self
70
     *          'times' => number of times it will be invoked
71
     *      ]
72
     *
73
     * @return array
74
     */
75 View Code Duplication
    protected function getExpectations()
76
    {
77
        return [
78
            [
79
                'name' => 'setName',
80
                'with' => 'config:status',
81
            ],
82
            [
83
                'name' => 'setAliases',
84
                'with' => [['status']],
85
            ],
86
            [
87
                'name' => 'setDescription',
88
                'with' => m::type('string'),
89
            ]
90
        ];
91
    }
92
}
93