-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from OpenBuildings/secure-uri
Use https:// protocol for Postmark API
- Loading branch information
Showing
3 changed files
with
113 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
namespace Openbuildings\Postmark\Test; | ||
|
||
use Openbuildings\Postmark\Api; | ||
use Openbuildings\Postmark\Test\Mock; | ||
use PHPUnit_Framework_TestCase; | ||
|
||
/** | ||
|
@@ -147,4 +146,86 @@ public function test_send() | |
) | ||
); | ||
} | ||
|
||
/** | ||
* @covers Openbuildings\Postmark\Api::is_secure | ||
*/ | ||
public function test_is_secure() | ||
{ | ||
$api = new Api(); | ||
$this->assertTrue($api->is_secure()); | ||
|
||
$api->set_secure(false); | ||
$this->assertFalse($api->is_secure()); | ||
|
||
$api->set_secure(true); | ||
$this->assertTrue($api->is_secure()); | ||
} | ||
|
||
/** | ||
* @covers Openbuildings\Postmark\Api::set_secure | ||
*/ | ||
public function test_set_secure() | ||
{ | ||
$api = new Api(); | ||
$this->assertSame($api, $api->set_secure(false)); | ||
$this->assertFalse($api->is_secure()); | ||
|
||
$api->set_secure(true); | ||
$this->assertTrue($api->is_secure()); | ||
} | ||
|
||
/** | ||
* @covers Openbuildings\Postmark\Api::get_send_uri | ||
*/ | ||
public function test_get_send_uri() | ||
{ | ||
$api = new Api(); | ||
$this->assertEquals(Api::SEND_URI_SECURE, $api->get_send_uri()); | ||
|
||
$api->set_secure(false); | ||
$this->assertEquals(Api::SEND_URI, $api->get_send_uri()); | ||
|
||
$api->set_secure(true); | ||
$this->assertEquals(Api::SEND_URI_SECURE, $api->get_send_uri()); | ||
} | ||
|
||
/** | ||
* @covers Openbuildings\Postmark\Api::send | ||
*/ | ||
public function test_send_wrong_json() | ||
{ | ||
$api_mock = $this->getMock( | ||
'Openbuildings\Postmark\Api', | ||
array( | ||
'get_send_uri' | ||
), | ||
array( | ||
'POSTMARK_API_TEST' | ||
) | ||
); | ||
|
||
$path_to_wrong_json = 'file://'.realpath(__DIR__.'/../test_data/wrong-json.json'); | ||
|
||
$api_mock | ||
->expects($this->once()) | ||
->method('get_send_uri') | ||
->will($this->returnValue($path_to_wrong_json)); | ||
|
||
$this->setExpectedException( | ||
'Exception', | ||
'Postmark delivery failed: wrong json response' | ||
); | ||
|
||
$response = $api_mock->send( | ||
array( | ||
'From' => 'Mark Smith <[email protected]>', | ||
'To' => '[email protected],[email protected],[email protected]', | ||
'Subject' => 'Test', | ||
'HtmlBody' => '<b>Hello</b>', | ||
'TextBody' => 'Hello', | ||
'ReplyTo' => '[email protected]', | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{'["} |