1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace allejo\DaPulse\Tests; |
4
|
|
|
|
5
|
|
|
use allejo\DaPulse\Exceptions\InvalidObjectException; |
6
|
|
|
use allejo\DaPulse\Pulse; |
7
|
|
|
use allejo\DaPulse\PulseNote; |
8
|
|
|
|
9
|
|
|
class PulseNoteTestCase extends PulseUnitTestCase |
10
|
|
|
{ |
11
|
|
|
static $title = "Violently Making Toast"; |
|
|
|
|
12
|
|
|
static $content = "By adding the word 'violently' in front a phrase, it makes the phrase more amusing"; |
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var Pulse |
16
|
|
|
*/ |
17
|
|
|
private $pulse; |
18
|
|
|
|
19
|
|
|
public function setUp () |
20
|
|
|
{ |
21
|
|
|
parent::setUp(); |
22
|
|
|
|
23
|
|
|
$this->pulse = new Pulse(27345095, true); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testCreateNoteWithUpdateButWithoutUser () |
27
|
|
|
{ |
28
|
|
|
$this->setExpectedException(\InvalidArgumentException::class); |
29
|
|
|
|
30
|
|
|
$this->pulse->addNote(self::$title, self::$content, true, NULL, true); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testCreateNote () |
34
|
|
|
{ |
35
|
|
|
$note = $this->pulse->addNote(self::$title, self::$content, true); |
36
|
|
|
|
37
|
|
|
$this->assertEquals('owners', $note->getPermissions()); |
38
|
|
|
$this->assertEquals(self::$title, $note->getTitle()); |
39
|
|
|
$this->assertEquals(self::$content, $note->getContent()); |
40
|
|
|
$this->assertEquals('rich_text', $note->getType()); |
41
|
|
|
$this->assertInstanceOf(\DateTime::class, $note->getCreatedAt()); |
42
|
|
|
$this->assertInstanceOf(\DateTime::class, $note->getUpdatedAt()); |
43
|
|
|
|
44
|
|
|
return $note; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @depends testCreateNote |
49
|
|
|
* @param PulseNote $note |
50
|
|
|
* @return PulseNote |
51
|
|
|
*/ |
52
|
|
|
public function testEditNote ($note) |
53
|
|
|
{ |
54
|
|
|
$newTitle = "My new title"; |
55
|
|
|
|
56
|
|
|
$note->editTitle($newTitle); |
57
|
|
|
$this->assertEquals($newTitle, $note->getTitle()); |
58
|
|
|
|
59
|
|
|
$newContent = "The world that the children made, here!"; |
60
|
|
|
|
61
|
|
|
$note->editContent($newContent); |
62
|
|
|
$this->assertEquals($newContent, $note->getContent()); |
63
|
|
|
|
64
|
|
|
return $note; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @depends testEditNote |
69
|
|
|
* @param PulseNote $note |
70
|
|
|
*/ |
71
|
|
|
public function testDeletingNote ($note) |
72
|
|
|
{ |
73
|
|
|
$this->setExpectedException(InvalidObjectException::class); |
74
|
|
|
|
75
|
|
|
$note->deleteNote(); |
76
|
|
|
$note->deleteNote(); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.