|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* Copyright 2016 Jan Eichhorn <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
6
|
|
|
* you may not use this file except in compliance with the License. |
|
7
|
|
|
* You may obtain a copy of the License at |
|
8
|
|
|
* |
|
9
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
10
|
|
|
* |
|
11
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
12
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
13
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14
|
|
|
* See the License for the specific language governing permissions and |
|
15
|
|
|
* limitations under the License. |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
namespace ApaiIO\Test\Configuration; |
|
19
|
|
|
|
|
20
|
|
|
use ApaiIO\Configuration\GenericConfiguration; |
|
21
|
|
|
use ApaiIO\Request\GuzzleRequest; |
|
22
|
|
|
use ApaiIO\ResponseTransformer\XmlToDomDocument; |
|
23
|
|
|
|
|
24
|
|
|
class GenericConfigurationTest extends \PHPUnit_Framework_TestCase |
|
25
|
|
|
{ |
|
26
|
|
|
public function testGettersAndSetters() |
|
27
|
|
|
{ |
|
28
|
|
|
$object = new GenericConfiguration(); |
|
29
|
|
|
|
|
30
|
|
|
$object->setAccessKey('ABC'); |
|
31
|
|
|
$object->setSecretKey('DEF'); |
|
32
|
|
|
$object->setAssociateTag('GHI'); |
|
33
|
|
|
$object->setResponseTransformer($a = new XmlToDomDocument()); |
|
34
|
|
|
$object->setRequest($b = new GuzzleRequest($this->prophesize('\GuzzleHttp\ClientInterface')->reveal())); |
|
35
|
|
|
|
|
36
|
|
|
$this->assertSame('ABC', $object->getAccessKey()); |
|
37
|
|
|
$this->assertSame('DEF', $object->getSecretKey()); |
|
38
|
|
|
$this->assertSame('GHI', $object->getAssociateTag()); |
|
39
|
|
|
$this->assertSame($a, $object->getResponseTransformer()); |
|
40
|
|
|
$this->assertSame($b, $object->getRequest()); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @expectedException InvalidArgumentException |
|
45
|
|
|
*/ |
|
46
|
|
|
public function testCountryException() |
|
47
|
|
|
{ |
|
48
|
|
|
$object = new GenericConfiguration(); |
|
49
|
|
|
$object->setCountry('no country'); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function testCountrySetter() |
|
53
|
|
|
{ |
|
54
|
|
|
$object = new GenericConfiguration(); |
|
55
|
|
|
$object->setCountry('DE'); |
|
56
|
|
|
|
|
57
|
|
|
$this->assertEquals('de', $object->getCountry()); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|