|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (c) 2013-2014 eBay Enterprise, Inc. |
|
4
|
|
|
* |
|
5
|
|
|
* NOTICE OF LICENSE |
|
6
|
|
|
* |
|
7
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
8
|
|
|
* that is bundled with this package in the file LICENSE.md. |
|
9
|
|
|
* It is also available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* @copyright Copyright (c) 2013-2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/) |
|
13
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace eBayEnterprise\RetailOrderManagement\Payload; |
|
17
|
|
|
|
|
18
|
|
|
class ConfigLocatorTest extends \PHPUnit_Framework_TestCase |
|
19
|
|
|
{ |
|
20
|
|
|
const TEST_PAYLOAD_TYPE = '\eBayEnterprise\RetailOrderManagement\Payload\Test'; |
|
21
|
|
|
/** @var array */ |
|
22
|
|
|
protected $testPayloadConfig; |
|
23
|
|
|
/** @var array */ |
|
24
|
|
|
protected $config; |
|
25
|
|
|
/** @var ConfigLocator */ |
|
26
|
|
|
protected $locator; |
|
27
|
|
|
|
|
28
|
|
|
public function setUp() |
|
29
|
|
|
{ |
|
30
|
|
|
$this->testPayloadConfig = [ |
|
31
|
|
|
'validators' => [['validator' => 'SomeValidator', 'params' => []]], |
|
32
|
|
|
'validatorIterator' => 'ValidatorIterator', |
|
33
|
|
|
'schemaValidator' => 'SchemaValidator', |
|
34
|
|
|
'childPayloads' => ['payloadMap' => 'PayloadMap', 'types' => []], |
|
35
|
|
|
]; |
|
36
|
|
|
$this->config = [self::TEST_PAYLOAD_TYPE => $this->testPayloadConfig]; |
|
37
|
|
|
$this->locator = new ConfigLocator($this->config); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function testHasPayoadConfig() |
|
41
|
|
|
{ |
|
42
|
|
|
$this->assertTrue($this->locator->hasPayloadConfig(self::TEST_PAYLOAD_TYPE)); |
|
43
|
|
|
$this->assertFalse($this->locator->hasPayloadConfig('NotAPayloadTestType')); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testGetPayloadConfig() |
|
47
|
|
|
{ |
|
48
|
|
|
$this->assertSame( |
|
49
|
|
|
$this->locator->getPayloadConfig(self::TEST_PAYLOAD_TYPE), |
|
50
|
|
|
$this->testPayloadConfig |
|
51
|
|
|
); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function testUnsupportedPayloadExceptionForUnknownType() |
|
55
|
|
|
{ |
|
56
|
|
|
$this->setExpectedException('\eBayEnterprise\RetailOrderManagement\Payload\Exception\UnsupportedPayload'); |
|
57
|
|
|
$this->locator->getPayloadConfig('NotAPayloadTestType'); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|