|
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() |
|
|
|
|
|
|
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() |
|
|
|
|
|
|
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() |
|
|
|
|
|
|
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() |
|
|
|
|
|
|
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() |
|
|
|
|
|
|
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() |
|
|
|
|
|
|
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
|
|
|
?> |
|
|
|
|
|
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.