QuestTest::testQuestSteps()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
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