Completed
Branch master (cf27fb)
by Vladimir
02:33
created

PulseNoteTestCase   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 70
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testCreateNoteWithUpdateButWithoutUser() 0 6 1
A testCreateNote() 0 13 1
A testEditNote() 0 14 1
A testDeletingNote() 0 7 1
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";
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $title.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
12
    static $content = "By adding the word 'violently' in front a phrase, it makes the phrase more amusing";
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $content.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
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