LevelTest   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 87
Duplicated Lines 19.54 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

10 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testCode() 0 7 1
A testName() 0 7 1
A testScore() 0 7 1
A testGeneratesNotification() 7 7 1
A testCategoryEnabled() 0 7 1
A testImageUrl() 0 7 1
A testDateCreated() 10 10 1
A testBadge() 0 7 1
A testScenario() 0 7 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 PHPUnit_Framework_TestCase as TestCase;
5
use Wonnova\SDK\Model\Badge;
6
use Wonnova\SDK\Model\Level;
7
use Wonnova\SDK\Model\Scenario;
8
9
/**
10
 * Class LevelTest
11
 * @author Wonnova
12
 * @link http://www.wonnova.com
13
 */
14
class LevelTest extends TestCase
15
{
16
    /**
17
     * @var Level
18
     */
19
    private $level;
20
21
    public function setUp()
22
    {
23
        $this->level = new Level();
24
    }
25
26
    public function testCode()
27
    {
28
        $expected = 'THE_LEVEL';
29
        $this->assertNull($this->level->getCode());
30
        $this->assertSame($this->level, $this->level->setCode($expected));
31
        $this->assertEquals($expected, $this->level->getCode());
32
    }
33
34
    public function testName()
35
    {
36
        $expected = 'The Level';
37
        $this->assertNull($this->level->getName());
38
        $this->assertSame($this->level, $this->level->setName($expected));
39
        $this->assertEquals($expected, $this->level->getName());
40
    }
41
42
    public function testScore()
43
    {
44
        $expected = 500;
45
        $this->assertNull($this->level->getScore());
46
        $this->assertSame($this->level, $this->level->setScore($expected));
47
        $this->assertEquals($expected, $this->level->getScore());
48
    }
49
50 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...
51
    {
52
        $expected = true;
53
        $this->assertNull($this->level->getGeneratesNotification());
54
        $this->assertSame($this->level, $this->level->setGeneratesNotification($expected));
55
        $this->assertEquals($expected, $this->level->getGeneratesNotification());
56
    }
57
58
    public function testCategoryEnabled()
59
    {
60
        $expected = false;
61
        $this->assertNull($this->level->isCategoryEnabled());
62
        $this->assertSame($this->level, $this->level->setCategoryEnabled($expected));
63
        $this->assertEquals($expected, $this->level->isCategoryEnabled());
64
    }
65
66
    public function testImageUrl()
67
    {
68
        $expected = 'https://secure.wonnova.com/image';
69
        $this->assertNull($this->level->getImageUrl());
70
        $this->assertSame($this->level, $this->level->setImageUrl($expected));
71
        $this->assertEquals($expected, $this->level->getImageUrl());
72
    }
73
74 View Code Duplication
    public function testDateCreated()
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...
75
    {
76
        $expected = new \DateTime();
77
        $this->assertNull($this->level->getDateCreated());
78
        $this->assertSame($this->level, $this->level->setDateCreated($expected));
79
        $this->assertSame($expected, $this->level->getDateCreated());
80
81
        $this->level->setDateCreated('2010-01-01 00:00:00');
82
        $this->assertInstanceOf('DateTime', $this->level->getDateCreated());
83
    }
84
85
    public function testBadge()
86
    {
87
        $expected = new Badge();
88
        $this->assertNull($this->level->getBadge());
89
        $this->assertSame($this->level, $this->level->setBadge($expected));
90
        $this->assertSame($expected, $this->level->getBadge());
91
    }
92
93
    public function testScenario()
94
    {
95
        $expected = new Scenario();
96
        $this->assertNull($this->level->getScenario());
97
        $this->assertSame($this->level, $this->level->setScenario($expected));
98
        $this->assertSame($expected, $this->level->getScenario());
99
    }
100
}
101