Skip to content

Commit

Permalink
Improving RulesEndpointProvider exception when tried to use SDK with …
Browse files Browse the repository at this point in the history
…unmapped store or environment
  • Loading branch information
Daniel Costa committed Aug 28, 2015
1 parent 1716e94 commit 8e37c11
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/Common/RulesEndpointProvider.php
Expand Up @@ -52,7 +52,9 @@ public function __invoke(array $args = [])
}
}

throw new UnresolvedEndpointException();
throw new UnresolvedEndpointException(
'Could not resolve a valid endpoint to ' . $args['store'] . '-' . $args['environment']
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Version.php
Expand Up @@ -11,7 +11,7 @@
class Version
{

const VERSION_NUMBER = '1.8.8';
const VERSION_NUMBER = '1.8.9';

const API = '2.6';

Expand Down
22 changes: 18 additions & 4 deletions tests/Common/RulesEndpointProviderTest.php
Expand Up @@ -25,19 +25,33 @@ public function endpointProvider()
return [
[
['store' => 'mobly-br', 'environment' => 'staging'],
['endpoint' => 'https://sellercenter-api-staging.mobly.com.br', 'signatureVersion' => 'v1']
]
['endpoint' => 'https://sellercenter-api-staging.mobly.com.br', 'signatureVersion' => 'v1'],
true
],
[
['store' => 'unmapped-store', 'environment' => 'production'],
['endpoint' => null, 'signatureVersion' => null],
false
],
];
}

/**
* @dataProvider endpointProvider
*/
public function testResolvesEndpoints($input, $output)
public function testResolvesEndpoints($input, $output, $valid)
{
// Use the default endpoints file
$p = RulesEndpointProvider::fromDefaults();
$this->assertEquals($output, call_user_func($p, $input));
if ($valid) {
$this->assertEquals($output, call_user_func($p, $input));
} else {
$this->setExpectedException(
'SellerCenter\SDK\Common\Exception\UnresolvedEndpointException',
'Could not resolve a valid endpoint to ' . $input['store'] . '-' . $input['environment']
);
call_user_func($p, $input);
}
}

/**
Expand Down

0 comments on commit 8e37c11

Please sign in to comment.