Skip to content

Commit 63022bf

Browse files
committed
removed unhittable code and removed a unit test for it. Updated code coverage filters in phpunit.xml to ignore test files because a utility function wasn't being used
1 parent ada533a commit 63022bf

File tree

4 files changed

+3
-18
lines changed

4 files changed

+3
-18
lines changed

lib/SparkPost/APIResource.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(SparkPost $sparkpost) {
4848
* @param string $mapKey a dot syntax path determining which value to set
4949
* @param mixed $value value for the given path
5050
*/
51-
protected function setMappedValue (&$model, $mapKey, $value) {
51+
protected function setMappedValue(&$model, $mapKey, $value) {
5252
//get mapping
5353
if( empty(static::$parameterMappings) ) {
5454
// if parameterMappings is empty we can assume that no wrapper is defined
@@ -180,10 +180,6 @@ private function buildBody($options) {
180180
private function callResource( $action, $resourcePath=null, $options=[] ) {
181181
$action = strtoupper($action); // normalize
182182

183-
if( !in_array($action, ['POST', 'PUT', 'GET', 'DELETE'])) {
184-
throw new \Exception('Invalid resource action');
185-
}
186-
187183
$url = $this->buildUrl($resourcePath, $options);
188184
$body = $this->buildBody($options);
189185

lib/SparkPost/SparkPost.php

+1-8
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,13 @@ public function setupUnwrapped ($endpoint) {
6161

6262
/**
6363
* @desc Merges passed in headers with default headers for http requests
64-
* @return Array - headers to be set on http requests
6564
*/
66-
public function getHttpHeaders(Array $headers = null) {
65+
public function getHttpHeaders() {
6766
$defaultOptions = [
6867
'Authorization' => $this->config['key'],
6968
'Content-Type' => 'application/json',
7069
];
7170

72-
// Merge passed in headers with defaults
73-
if (!is_null($headers)) {
74-
foreach ($headers as $header => $value) {
75-
$defaultOptions[$header] = $value;
76-
}
77-
}
7871
return $defaultOptions;
7972
}
8073

phpunit.xml

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<filter>
3333
<blacklist>
3434
<directory>./vendor</directory>
35+
<directory>./test</directory>
3536
</blacklist>
3637
</filter>
3738
</phpunit>

test/unit/SparkPostTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ public function testGetHeaders() {
6666
$this->assertEquals('application/json', $results['Content-Type']);
6767
}
6868

69-
public function testGetHeadersOverride() {
70-
$results = $this->resource->getHttpHeaders(['Content-Type'=>'application/xml']);
71-
$this->assertEquals('application/xml', $results['Content-Type']);
72-
}
73-
7469
public function testSetUnwrapped() {
7570
$results = $this->resource->setupUnwrapped('ASweetEndpoint');
7671
$this->assertEquals($this->resource->ASweetEndpoint, $results);

0 commit comments

Comments
 (0)