QuestTest   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 75
Duplicated Lines 41.33 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 1
cbo 4
dl 31
loc 75
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testStartDate() 10 10 1
A testCode() 0 7 1
A testGeneratesNotification() 7 7 1
A testName() 7 7 1
A testDescription() 7 7 1
A testProgress() 0 7 1
A testQuestSteps() 0 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
namespace Wonnova\SDK\Test\Model;
3
4
use Doctrine\Common\Collections\ArrayCollection;
5
use PHPUnit_Framework_TestCase as TestCase;
6
use Wonnova\SDK\Model\Quest;
7
use Wonnova\SDK\Model\QuestStep;
8
9
/**
10
 * Class QuestTest
11
 * @author Wonnova
12
 * @link http://www.wonnova.com
13
 */
14
class QuestTest extends TestCase
15
{
16
    /**
17
     * @var Quest
18
     */
19
    private $quest;
20
21
    public function setUp()
22
    {
23
        $this->quest = new Quest();
24
    }
25
26 View Code Duplication
    public function testStartDate()
0 ignored issues
show
Duplication introduced by
This method 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...
27
    {
28
        $expected = new \DateTime();
29
        $this->assertNull($this->quest->getStartDate());
30
        $this->assertSame($this->quest, $this->quest->setStartDate($expected));
31
        $this->assertSame($expected, $this->quest->getStartDate());
32
33
        $this->quest->setStartDate('2010-01-01 00:00:00');
34
        $this->assertInstanceOf('DateTime', $this->quest->getStartDate());
35
    }
36
37
    public function testCode()
38
    {
39
        $expected = 'THE_QUEST';
40
        $this->assertNull($this->quest->getCode());
41
        $this->assertSame($this->quest, $this->quest->setCode($expected));
42
        $this->assertSame($expected, $this->quest->getCode());
43
    }
44
45 View Code Duplication
    public function testGeneratesNotification()
0 ignored issues
show
Duplication introduced by
This method 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...
46
    {
47
        $expected = true;
48
        $this->assertNull($this->quest->getGeneratesNotification());
49
        $this->assertSame($this->quest, $this->quest->setGeneratesNotification($expected));
50
        $this->assertEquals($expected, $this->quest->getGeneratesNotification());
51
    }
52
53 View Code Duplication
    public function testName()
0 ignored issues
show
Duplication introduced by
This method 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...
54
    {
55
        $expected = 'The Quest';
56
        $this->assertNull($this->quest->getName());
57
        $this->assertSame($this->quest, $this->quest->setName($expected));
58
        $this->assertSame($expected, $this->quest->getName());
59
    }
60
61 View Code Duplication
    public function testDescription()
0 ignored issues
show
Duplication introduced by
This method 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...
62
    {
63
        $expected = 'The Quest\'s description';
64
        $this->assertNull($this->quest->getDescription());
65
        $this->assertSame($this->quest, $this->quest->setDescription($expected));
66
        $this->assertSame($expected, $this->quest->getDescription());
67
    }
68
69
    public function testProgress()
70
    {
71
        $expected = 100;
72
        $this->assertNull($this->quest->getProgress());
73
        $this->assertSame($this->quest, $this->quest->setProgress($expected));
74
        $this->assertSame($expected, $this->quest->getProgress());
75
    }
76
77
    public function testQuestSteps()
78
    {
79
        $stepsArray = [new QuestStep(), new QuestStep()];
80
        $expected = new ArrayCollection([new QuestStep(), new QuestStep()]);
81
        $this->assertNull($this->quest->getQuestSteps());
82
        $this->assertSame($this->quest, $this->quest->setQuestSteps($expected));
83
        $this->assertSame($expected, $this->quest->getQuestSteps());
84
85
        $this->quest->setQuestSteps($stepsArray);
86
        $this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $this->quest->getQuestSteps());
87
    }
88
}
89