Completed
Pull Request — master (#365)
by Gordon
07:15
created

testUpdateNotificationRecipients()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 23
rs 9.0856
cc 3
eloc 16
nc 4
nop 0
1
<?php
2
3
class BlogPostNotificationsTest extends SapphireTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    /**
6
     * @var string
7
     */
8
    public static $fixture_file = 'blog.yml';
9
10
    public function testUpdateNotificationRecipients()
11
    {
12
        if (!class_exists('CommentNotifier')) {
13
            $this->markTestSkipped('Comments Notification module is not installed');
0 ignored issues
show
Bug introduced by
The method markTestSkipped() does not seem to exist on object<BlogPostNotificationsTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
14
        }
15
16
        $blogPost = $this->objFromFixture('BlogPost', 'PostC');
17
        $comment = new Comment();
18
        $comment->Comment = 'This is a comment';
19
        $comment->write();
20
        $recipients = $blogPost->notificationRecipients(
21
            $comment
22
        )->toArray();
23
24
        $segments = array();
25
        foreach ($recipients as $recipient) {
26
            array_push($segments, $recipient->URLSegment);
27
        }
28
29
        sort($segments);
30
        $this->assertEquals(array('blog-contributor', 'blog-editor',
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogPostNotificationsTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
                                    'blog-writer', ), $segments);
32
    }
33
34
    public function testUpdateNotificationSubject()
35
    {
36
        if (!class_exists('CommentNotifier')) {
37
            $this->markTestSkipped('Comments Notification module is not installed');
0 ignored issues
show
Bug introduced by
The method markTestSkipped() does not seem to exist on object<BlogPostNotificationsTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
        }
39
        $blogPost = $this->objFromFixture('BlogPost', 'PostC');
40
        $comment = new Comment();
41
        $comment->Comment = 'This is a comment';
42
        $comment->write();
43
        $recipients = $blogPost->notificationRecipients(
44
            $comment
45
        )->toArray();
46
        $subject = $blogPost->notificationSubject($comment, $recipients[0]);
47
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<BlogPostNotificationsTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
            'A new comment has been posted on Third Post',
49
            $subject
50
        );
51
    }
52
}
53