Completed
Push — master ( 80cb06...2b2e5b )
by Damian
06:53
created

BlogPostNotificationsTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 50
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testUpdateNotificationRecipients() 0 23 3
A testUpdateNotificationSubject() 0 18 2
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