diff options
author | nornholdj <nornholdj@gmail.com> | 2014-10-31 15:10:06 -0400 |
---|---|---|
committer | nornholdj <nornholdj@gmail.com> | 2014-10-31 15:10:06 -0400 |
commit | 68a7e8ec33f205a71107d924e0d244f5edac97a6 (patch) | |
tree | 7e47e9d41a8a3304e32eb0da6219c523f3e9c126 /test/unit/SparkPostTest.php | |
parent | de407ac8bf029e85278eaeb683e6f86c6a11c097 (diff) | |
download | php-sparkpost-68a7e8ec33f205a71107d924e0d244f5edac97a6.zip php-sparkpost-68a7e8ec33f205a71107d924e0d244f5edac97a6.tar.gz php-sparkpost-68a7e8ec33f205a71107d924e0d244f5edac97a6.tar.bz2 |
MA-946 #time 3h 30m Revamped Transmission object to be stateless,
updated tests and examples.
Diffstat (limited to 'test/unit/SparkPostTest.php')
-rw-r--r-- | test/unit/SparkPostTest.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/test/unit/SparkPostTest.php b/test/unit/SparkPostTest.php new file mode 100644 index 0000000..218cb6e --- /dev/null +++ b/test/unit/SparkPostTest.php @@ -0,0 +1,60 @@ +<?php +namespace SparkPost\Test; + +use MessageSystems\SparkPost; + +class SparkPostTest extends \PHPUnit_Framework_TestCase { + + /** + * @desc Ensures that the configuration class is not instantiable. + */ + public function testConstructorCannotBeCalled() { + $class = new \ReflectionClass('\MessageSystems\SparkPost'); + $this->assertFalse($class->isInstantiable()); + } + + /** + * @desc Tests that an exception is thrown when a library tries to recieve the config and it has not yet been set. + * Since its a singleton this test must come before any setConfig tests. + * @expectedException Exception + * @expectedExceptionMessage No configuration has been provided + */ + public function testGetConfigEmptyException() { + SparkPost::getConfig(); + } + + /** + * @desc Tests that the api key is set when setting the config + * @expectedException Exception + * @expectedExceptionMessage You must provide an API key + */ + public function testSetConfigAPIKeyNotSetException() { + SparkPost::setConfig(['something'=>'other than an API Key']); + } + + /** + * @desc Tests that the api key is set when setting the config and that its not empty + * @expectedException Exception + * @expectedExceptionMessage You must provide an API key + */ + public function testSetConfigAPIKeyEmptyException() { + SparkPost::setConfig(['key'=>'']); + } + + /** + * @desc Tests overridable values are set while invalid values are ignored + */ + public function testSetConfigMultipleValuesAndGetConfig() { + SparkPost::setConfig(['key'=>'lala', 'version'=>'v8', 'port'=>1024, 'someOtherValue'=>'fakeValue']); + + $testConfig = SparkPost::getConfig(); + $this->assertEquals('lala', $testConfig['key']); + $this->assertEquals('v8', $testConfig['version']); + $this->assertEquals(1024, $testConfig['port']); + $this->assertNotContains('someOtherValue', array_keys($testConfig)); + $this->assertEquals('https', $testConfig['protocol']); + $this->assertEquals('app.cloudplaceholder.com', $testConfig['host']); + $this->assertEquals(true, $testConfig['strictSSL']); + } +} +?>
\ No newline at end of file |