2
2
3
3
namespace JoindinTest \Inc ;
4
4
5
- use \ TalkModel ;
5
+ use TalkModel ;
6
6
7
- require_once __DIR__ . '/../../src/services/TalkCommentEmailService.php ' ;
7
+ require_once __DIR__ . '/../../src/services/TalkCommentEmailService.php ' ;
8
8
9
9
class TalkCommentEmailServiceTest extends \PHPUnit_Framework_Testcase
10
10
{
11
11
12
+ protected $ config = [
13
+ 'email ' => [
14
+
15
+ 'smtp ' => [
16
+ 'host ' => 'localhost ' ,
17
+ 'port ' => 25 ,
18
+ 'username ' => 'username ' ,
19
+ 'password ' => 'ChangeMeSeymourChangeMe ' ,
20
+ 'security ' => null ,
21
+ ],
22
+ ],
23
+ ];
24
+
12
25
/**
13
26
* Check that we can create the service
14
27
*
15
28
* @test
16
29
*/
17
30
public function createService ()
18
31
{
19
- $ config =
array (
"email " =>
array (
"from " =>
"[email protected] " ));
20
- $ recipients =
array (
"[email protected] " );
21
- $ talk = new TalkModel (array ("talk_title " => "sample talk " ));
22
- $ comment = array ("comments " => array (array ("comment " => "test comment " , "rating " => 3 )));
32
+ $ recipients = [
"[email protected] " ];
33
+ $ talk = new TalkModel (["talk_title " => "sample talk " ]);
34
+ $ comment = ["comments " => [["comment " => "test comment " , "rating " => 3 ]]];
23
35
24
- $ service = new \TalkCommentEmailService ($ config , $ recipients , $ talk , $ comment );
36
+ $ service = new \TalkCommentEmailService ($ this -> config , $ recipients , $ talk , $ comment );
25
37
$ this ->assertInstanceOf ('TalkCommentEmailService ' , $ service );
26
38
}
27
39
@@ -32,13 +44,14 @@ public function createService()
32
44
*/
33
45
public function createServiceWithEmailRedirect ()
34
46
{
35
- $ config =
array (
"email " =>
array (
"from " =>
"[email protected] " ,
"forward_all_to " =>
"[email protected] " ));
36
- $ recipients =
array (
"[email protected] " );
37
- $ talk = new TalkModel (array ("talk_title " => "sample talk " ));
38
- $ comment = array ("comments " => array (array ("comment " => "test comment " , "rating " => 3 )));
47
+ $ config = $ this ->config ;
48
+ $ config[
"email " ][
"forward_all_to " ] =
"[email protected] " ;
49
+ $ recipients = [
"[email protected] " ];
50
+ $ talk = new TalkModel (["talk_title " => "sample talk " ]);
51
+ $ comment = ["comments " => [["comment " => "test comment " , "rating " => 3 ]]];
39
52
40
53
$ service = new \TalkCommentEmailService ($ config , $ recipients , $ talk , $ comment );
41
- $ this ->
assertEquals (
$ service -> getRecipients (), array ( "[email protected] " ));
54
+ $ this ->
assertEquals (
[ "[email protected] " ], $ service -> getRecipients ( ));
42
55
}
43
56
44
57
/**
@@ -48,18 +61,17 @@ public function createServiceWithEmailRedirect()
48
61
*/
49
62
public function templateReplacements ()
50
63
{
51
- $ config =
array (
"email " =>
array (
"from " =>
"[email protected] " ));
52
- $ recipients =
array (
"[email protected] " );
53
- $ talk = new TalkModel (array ("talk_title " => "sample talk " ));
54
- $ comment = array ("comments " => array (array ("comment " => "test comment " , "rating " => 3 )));
64
+ $ recipients = [
"[email protected] " ];
65
+ $ talk = new TalkModel (["talk_title " => "sample talk " ]);
66
+ $ comment = ["comments " => [["comment " => "test comment " , "rating " => 3 ]]];
55
67
56
- $ service = new \TalkCommentEmailService ($ config , $ recipients , $ talk , $ comment );
57
- $ service ->templatePath = __DIR__ . '/../../src/views/emails/ ' ;
68
+ $ service = new \TalkCommentEmailService ($ this -> config , $ recipients , $ talk , $ comment );
69
+ $ service ->templatePath = __DIR__ . '/../../src/views/emails/ ' ;
58
70
59
- $ template = "testTemplate.md " ;
60
- $ replacements = array ( "cat " => "Camel " , "mat " => "magic carpet " ) ;
61
- $ message = $ service ->parseEmail ($ template , $ replacements );
62
- $ expected = "The Camel sat on the magic carpet
71
+ $ template = "testTemplate.md " ;
72
+ $ replacements = [ "cat " => "Camel " , "mat " => "magic carpet " ] ;
73
+ $ message = $ service ->parseEmail ($ template , $ replacements );
74
+ $ expected = "The Camel sat on the magic carpet
63
75
64
76
65
77
----
@@ -77,17 +89,18 @@ public function templateReplacements()
77
89
*/
78
90
public function markdownTransform ()
79
91
{
80
- $ markdown = "A *sunny* day " ;
81
-
82
- $ config =
array (
"email " =>
array (
"from " =>
"[email protected] " ));
83
- $ recipients =
array (
"[email protected] " );
84
- $ talk = new TalkModel (array ("talk_title " => "sample talk " ));
85
- $ comment = array ("comments " => array (array ("comment " => "test comment " , "rating " => 3 )));
92
+ $ markdown = "A *sunny* day " ;
93
+ $ recipients = [
"[email protected] " ];
94
+ $ talk = new TalkModel (["talk_title " => "sample talk " ]);
95
+ $ comment = ["comments " => [["comment " => "test comment " , "rating " => 3 ]]];
86
96
87
- $ service = new \TalkCommentEmailService ($ config , $ recipients , $ talk , $ comment );
97
+ $ service = new \TalkCommentEmailService ($ this -> config , $ recipients , $ talk , $ comment );
88
98
89
99
$ html = $ service ->markdownToHtml ($ markdown );
90
- $ this ->assertEquals ($ html , "<p>A <em>sunny</em> day</p>
91
- " );
100
+ $ this ->assertEquals (
101
+ $ html ,
102
+ "<p>A <em>sunny</em> day</p>
103
+ "
104
+ );
92
105
}
93
106
}
0 commit comments