@@ -13,11 +13,18 @@ function setUp() {
1313 $ this ->mailer = new SparkPostHTTPMailer ();
1414 }
1515
16+ function test_mailSend_calls_sparkpost_send () {
17+ $ stub = Mockery::mock ($ this ->mailer );
18+ $ stub ->shouldReceive ('sparkpost_send ' )->andReturn ('woowoo ' );
19+
20+ $ this ->assertTrue (NSA ::invokeMethod ($ stub , 'mailSend ' , null , null ) == 'woowoo ' );
21+ }
22+
1623 function test_mailer_is_a_mailer_instance () {
1724 $ this ->assertTrue ( $ this ->mailer instanceof \PHPMailer );
1825 }
1926
20- function test_sender_with_name () {
27+ function test_get_sender_with_name () {
2128 $ this ->mailer ->setFrom ( 'me@hello.com ' , 'me ' );
2229 $ sender = array (
2330 'name ' => 'me ' ,
@@ -27,7 +34,7 @@ function test_sender_with_name() {
2734 $ this ->assertTrue (NSA ::invokeMethod ($ this ->mailer , 'get_sender ' ) == $ sender );
2835 }
2936
30- function test_sender_without_name () {
37+ function test_get_sender_without_name () {
3138 $ this ->mailer ->setFrom ( 'me@hello.com ' , '' );
3239 $ sender = array (
3340 'email ' => 'me@hello.com '
@@ -159,4 +166,14 @@ function test_get_recipients() {
159166 $ recipients = NSA ::invokeMethod ($ this ->mailer , 'get_recipients ' );
160167 $ this ->assertTrue ($ recipients == $ expected );
161168 }
169+
170+ function test_get_attachments () {
171+ $ temp = tempnam ('/tmp ' , 'php-wordpress-sparkpost ' );
172+ file_put_contents ($ temp , 'TEST ' );
173+ $ this ->mailer ->addAttachment ($ temp );
174+ $ attachments = NSA ::invokeMethod ($ this ->mailer , 'get_attachments ' );
175+ $ this ->assertTrue ($ attachments [0 ]['type ' ] === 'application/octet-stream ' );
176+ $ this ->assertTrue ($ attachments [0 ]['name ' ] === basename ($ temp ));
177+ $ this ->assertTrue ($ attachments [0 ]['data ' ] === base64_encode ('TEST ' ));
178+ }
162179}
0 commit comments