Test Setup Failed
Pull Request — master (#215)
by Viruthagiri
12:15
created

CheckNotifications::testRegistrationEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 12
loc 12
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
class CheckNotifications extends WP_UnitTestCase
3
{
4
    public function setUp()
5
    {
6
        parent::setUp();
7
    }
8
9 View Code Duplication
    public function testSendFriendEmail()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
10
    {
11
        add_filter('wp_mail', 'print_mail');
12
        ob_start();
13
        geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'send_friend');
14
        $output = ob_get_clean();
15
        remove_filter('wp_mail', 'print_mail');
16
        $this->assertContains( 'thought you might be interested in', $output );
17
        $this->assertContains( 'Your friend has sent you a message from', $output );
18
        $this->assertContains( '[email protected]', $output );
19
        $this->assertContains( 'ADMIN BCC COPY', $output );
20
    }
21
22 View Code Duplication
    public function testSendEnquiryEmail()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
23
    {
24
        add_filter('wp_mail', 'print_mail');
25
        ob_start();
26
        geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'send_enquiry');
27
        $output = ob_get_clean();
28
        remove_filter('wp_mail', 'print_mail');
29
        $this->assertContains( 'Website Enquiry', $output );
30
        $this->assertContains( 'An enquiry has been sent from', $output );
31
        $this->assertContains( '[email protected]', $output );
32
        $this->assertContains( 'ADMIN BCC COPY', $output );
33
    }
34
35 View Code Duplication
    public function testForgotPassEmail()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
36
    {
37
        add_filter('wp_mail', 'print_mail');
38
        ob_start();
39
        geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'forgot_password');
40
        $output = ob_get_clean();
41
        remove_filter('wp_mail', 'print_mail');
42
        $this->assertContains( 'Your new password', $output );
43
        $this->assertContains( 'You requested a new password for', $output );
44
        $this->assertContains( '[email protected]', $output );
45
    }
46
47 View Code Duplication
    public function testRegistrationEmail()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
48
    {
49
        add_filter('wp_mail', 'print_mail');
50
        ob_start();
51
        geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'registration');
52
        $output = ob_get_clean();
53
        remove_filter('wp_mail', 'print_mail');
54
        $this->assertContains( 'Your Log In Details', $output );
55
        $this->assertContains( 'You can log in  with the following information', $output );
56
        $this->assertContains( '[email protected]', $output );
57
        $this->assertContains( 'ADMIN BCC COPY', $output );
58
    }
59
60 View Code Duplication
    public function testPostSubmitEmail()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
61
    {
62
        add_filter('wp_mail', 'print_mail');
63
        ob_start();
64
        geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'post_submit');
65
        $output = ob_get_clean();
66
        remove_filter('wp_mail', 'print_mail');
67
        $this->assertContains( 'Post Submitted Successfully', $output );
68
        $this->assertContains( 'You submitted the below listing information', $output );
69
        $this->assertContains( '[email protected]', $output );
70
        $this->assertContains( 'ADMIN BCC COPY', $output );
71
        $this->assertContains( 'A new  listing has been published', $output );
72
    }
73
74 View Code Duplication
    public function testListingPublishedEmail()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
75
    {
76
        add_filter('wp_mail', 'print_mail');
77
        ob_start();
78
        geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'listing_published');
79
        $output = ob_get_clean();
80
        remove_filter('wp_mail', 'print_mail');
81
        $this->assertContains( 'Listing Published Successfully', $output );
82
        $this->assertContains( 'Your listing  has been published', $output );
83
        $this->assertContains( '[email protected]', $output );
84
        $this->assertContains( 'ADMIN BCC COPY', $output );
85
    }
86
87
    public function tearDown()
88
    {
89
        parent::tearDown();
90
    }
91
}
92
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...