-
Notifications
You must be signed in to change notification settings - Fork 5
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 #9 from zanderwar/tests/coverage
Test coverage improvements
- Loading branch information
Showing
2 changed files
with
112 additions
and
15 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,6 +3,7 @@ | |
namespace Vulcan\SendGrid\Tests; | ||
|
||
use SilverStripe\Dev\FunctionalTest; | ||
use SilverStripe\ORM\ArrayList; | ||
use SilverStripe\ORM\FieldType\DBDatetime; | ||
use SilverStripe\ORM\FieldType\DBHTMLText; | ||
use SilverStripe\View\ArrayData; | ||
|
@@ -157,4 +158,93 @@ public function testCustomArgs() | |
$this->assertTrue(true); | ||
} | ||
} | ||
|
||
/** | ||
* @covers \Vulcan\SendGrid\SendGrid::getErrorMap() | ||
*/ | ||
public function testErrorMap() | ||
{ | ||
$this->assertInstanceOf(ArrayList::class, $this->sendGrid->getErrorMap()); | ||
} | ||
|
||
/** | ||
* @covers \Vulcan\SendGrid\SendGrid::getErrorDefinition() | ||
*/ | ||
public function testErrorDefinition() | ||
{ | ||
$definition = $this->sendGrid->getErrorDefinition(200); | ||
|
||
$this->assertEquals('OK', $definition->Message); | ||
} | ||
|
||
/** | ||
* @covers \Vulcan\SendGrid\SendGrid::isSandbox() | ||
* @covers \Vulcan\SendGrid\SendGrid::setSandboxMode() | ||
*/ | ||
public function testSandboxMode() | ||
{ | ||
$this->sendGrid->setSandboxMode(true); | ||
$this->assertTrue($this->sendGrid->isSandbox()); | ||
} | ||
|
||
/** | ||
* @covers \Vulcan\SendGrid\SendGrid::setTemplateId() | ||
* @covers \Vulcan\SendGrid\SendGrid::getTemplateId() | ||
*/ | ||
public function testTemplateId() | ||
{ | ||
$id = '1234-5678-9123-4567'; | ||
$this->sendGrid->setTemplateId($id); | ||
$this->assertEquals($id, $this->sendGrid->getTemplateId()); | ||
} | ||
|
||
/** | ||
* @covers \Vulcan\SendGrid\SendGrid::getApiKey() | ||
*/ | ||
public function testGetApiKey() | ||
{ | ||
if ($this->hasApiKey) { | ||
$this->assertEquals(getenv('SG_API_KEY'), $this->sendGrid->getApiKey()); | ||
return; | ||
} | ||
|
||
$this->assertEquals('XXXX-XXXX-XXXX-XXXX', $this->sendGrid->getApiKey()); | ||
} | ||
|
||
/** | ||
* @covers \Vulcan\SendGrid\SendGrid::setReplyTo() | ||
* @covers \Vulcan\SendGrid\SendGrid::getReplyTo() | ||
*/ | ||
public function testReplyTo() | ||
{ | ||
$this->sendGrid->setReplyTo('[email protected]'); | ||
$this->assertEquals('[email protected]', $this->sendGrid->getReplyTo()); | ||
} | ||
|
||
/** | ||
* @covers \Vulcan\SendGrid\SendGrid::setFrom() | ||
* @covers \Vulcan\SendGrid\SendGrid::setFromName() | ||
* @covers \Vulcan\SendGrid\SendGrid::getFrom() | ||
* @covers \Vulcan\SendGrid\SendGrid::getFromName() | ||
*/ | ||
public function testFrom() | ||
{ | ||
$this->sendGrid->setFrom('[email protected]'); | ||
$this->sendGrid->setFromName('Jane Doe'); | ||
|
||
$this->assertEquals('[email protected]', $this->sendGrid->getFrom()); | ||
$this->assertEquals('Jane Doe', $this->sendGrid->getFromName()); | ||
} | ||
|
||
/** | ||
* @covers \Vulcan\SendGrid\SendGrid::setSubject() | ||
* @covers \Vulcan\SendGrid\SendGrid::getSubject() | ||
*/ | ||
public function testSubject() | ||
{ | ||
$subject = 'Where have you been John!'; | ||
$this->sendGrid->setSubject($subject); | ||
|
||
$this->assertEquals($subject, $this->sendGrid->getSubject()); | ||
} | ||
} |