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() |
|
|
|
|
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() |
|
|
|
|
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() |
|
|
|
|
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() |
|
|
|
|
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
|
|
|
|
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.