blob: f40461d606ff2f6f227af33fa13802d8f74f4ea4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<?php
namespace SparkPost\Test;
use SparkPost\SparkPost;
class SparkPostTest extends \PHPUnit_Framework_TestCase {
/**
* @desc Ensures that the configuration class is not instantiable.
*/
public function testConstructorCannotBeCalled() {
$class = new \ReflectionClass('\SparkPost\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::unsetConfig();
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(array('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(array('key'=>''));
}
/**
* @desc Tests overridable values are set while invalid values are ignored
*/
public function testSetConfigMultipleValuesAndGetConfig() {
SparkPost::setConfig(array('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('api.sparkpost.com', $testConfig['host']);
$this->assertEquals(true, $testConfig['strictSSL']);
}
}
?>
|