AbstractTimelineMessageTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 4 4 1
A testConstructor() 6 6 1
A testGetSetStorage() 6 6 1
A testGetSetTimeline() 6 6 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\Cli\CommandBus\Timeline;
21
22
use Baleen\Cli\CommandBus\AbstractMessage;
23
use Baleen\Cli\CommandBus\Timeline\AbstractTimelineCommand;
24
use Baleen\Cli\CommandBus\Util\StorageAwareInterface;
25
use Baleen\Cli\CommandBus\Util\TimelineAwareInterface;
26
use Baleen\Migrations\Storage\StorageInterface;
27
use Baleen\Migrations\Timeline;
28
use BaleenTest\Cli\BaseTestCase;
29
use Mockery as m;
30
31
/**
32
 * Class AbstractTimelineMessageTest
33
 * @author Gabriel Somoza <[email protected]>
34
 */
35 View Code Duplication
class AbstractTimelineMessageTest extends BaseTestCase
36
{
37
    /** @var m\Mock|AbstractTimelineCommand */
38
    protected $instance;
39
40
    /**
41
     * setUp
42
     */
43
    public function setUp()
44
    {
45
        $this->instance = m::mock(AbstractTimelineCommand::class)->makePartial();
46
    }
47
48
    /**
49
     * testConstructor
50
     */
51
    public function testConstructor()
52
    {
53
        $this->assertInstanceOf(AbstractMessage::class, $this->instance);
54
        $this->assertInstanceOf(StorageAwareInterface::class, $this->instance);
55
        $this->assertInstanceOf(TimelineAwareInterface::class, $this->instance);
56
    }
57
58
    /**
59
     * testGetSetStorage
60
     */
61
    public function testGetSetStorage()
62
    {
63
        $storage = m::mock(StorageInterface::class);
64
        $this->instance->setStorage($storage);
65
        $this->assertSame($storage, $this->instance->getStorage());
66
    }
67
68
    /**
69
     * testGetSetTimeline
70
     */
71
    public function testGetSetTimeline()
72
    {
73
        $timeline = m::mock(Timeline::class);
74
        $this->instance->setTimeline($timeline);
75
        $this->assertSame($timeline, $this->instance->getTimeline());
76
    }
77
}
78