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
|
|
|
use PHPUnit\Framework\TestCase; |
24
|
|
|
|
25
|
|
|
class GenericConfigurationTest extends TestCase |
26
|
|
|
{ |
27
|
|
|
public function testGettersAndSetters() |
28
|
|
|
{ |
29
|
|
|
$object = new GenericConfiguration(); |
30
|
|
|
|
31
|
|
|
$object->setAccessKey('ABC'); |
32
|
|
|
$object->setSecretKey('DEF'); |
33
|
|
|
$object->setAssociateTag('GHI'); |
34
|
|
|
$object->setResponseTransformer($a = new XmlToDomDocument()); |
35
|
|
|
$object->setRequest($b = new GuzzleRequest($this->prophesize('\GuzzleHttp\ClientInterface')->reveal())); |
36
|
|
|
|
37
|
|
|
$this->assertSame('ABC', $object->getAccessKey()); |
38
|
|
|
$this->assertSame('DEF', $object->getSecretKey()); |
39
|
|
|
$this->assertSame('GHI', $object->getAssociateTag()); |
40
|
|
|
$this->assertSame($a, $object->getResponseTransformer()); |
41
|
|
|
$this->assertSame($b, $object->getRequest()); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @expectedException InvalidArgumentException |
46
|
|
|
*/ |
47
|
|
|
public function testCountryException() |
48
|
|
|
{ |
49
|
|
|
$object = new GenericConfiguration(); |
50
|
|
|
$object->setCountry('no country'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testCountrySetter() |
54
|
|
|
{ |
55
|
|
|
$object = new GenericConfiguration(); |
56
|
|
|
$object->setCountry('DE'); |
57
|
|
|
|
58
|
|
|
$this->assertEquals('de', $object->getCountry()); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|