1
|
|
|
<?php |
2
|
|
|
namespace Wonnova\SDK\Test\Model; |
3
|
|
|
|
4
|
|
|
use PHPUnit_Framework_TestCase as TestCase; |
5
|
|
|
use Wonnova\SDK\Model\Update; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class UpdateTest |
9
|
|
|
* @author Wonnova |
10
|
|
|
* @link http://www.wonnova.com |
11
|
|
|
*/ |
12
|
|
|
class UpdateTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var Update |
16
|
|
|
*/ |
17
|
|
|
private $update; |
18
|
|
|
|
19
|
|
|
public function setUp() |
20
|
|
|
{ |
21
|
|
|
$this->update = new Update(); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function testText() |
25
|
|
|
{ |
26
|
|
|
$expected = 'You just won 10 points'; |
27
|
|
|
$this->assertNull($this->update->getText()); |
28
|
|
|
$this->assertSame($this->update, $this->update->setText($expected)); |
29
|
|
|
$this->assertEquals($expected, $this->update->getText()); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
View Code Duplication |
public function testDate() |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
$expected = new \DateTime('1990-05-08 00:00:00'); |
35
|
|
|
$this->assertNull($this->update->getDate()); |
36
|
|
|
$this->assertSame($this->update, $this->update->setDate($expected)); |
37
|
|
|
$this->assertSame($expected, $this->update->getDate()); |
38
|
|
|
|
39
|
|
|
$this->update->setDate(['date' => '1990-05-08 00:00:00']); |
40
|
|
|
$this->assertInstanceOf('DateTime', $this->update->getDate()); |
41
|
|
|
|
42
|
|
|
$this->update->setDate(['date' => '1990-05-08 00:00:00', 'timezone' => 'Europe/Berlin']); |
43
|
|
|
$this->assertInstanceOf('DateTime', $this->update->getDate()); |
44
|
|
|
|
45
|
|
|
$this->update->setDate('1990-05-08 00:00:00'); |
46
|
|
|
$this->assertInstanceOf('DateTime', $this->update->getDate()); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testType() |
50
|
|
|
{ |
51
|
|
|
$expected = Update::TYPE_INTERACTION; |
52
|
|
|
$this->assertNull($this->update->getType()); |
53
|
|
|
$this->assertSame($this->update, $this->update->setType($expected)); |
54
|
|
|
$this->assertEquals($expected, $this->update->getType()); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
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.