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; |
19
|
|
|
|
20
|
|
|
use ApaiIO\ApaiIO; |
21
|
|
|
use ApaiIO\Configuration\GenericConfiguration; |
22
|
|
|
use ApaiIO\Operations\Search; |
23
|
|
|
use PHPUnit\Framework\TestCase; |
24
|
|
|
|
25
|
|
|
class ApaiIOTest extends TestCase |
26
|
|
|
{ |
27
|
|
|
public function testApaiIORequestPerfomOperation() |
28
|
|
|
{ |
29
|
|
|
$conf = new GenericConfiguration(); |
30
|
|
|
$operation = new Search(); |
31
|
|
|
|
32
|
|
|
$request = $this->prophesize('\ApaiIO\Request\RequestInterface'); |
33
|
|
|
$request |
34
|
|
|
->perform($operation, $conf) |
35
|
|
|
->shouldBeCalledTimes(1) |
36
|
|
|
->willReturn(); |
37
|
|
|
|
38
|
|
|
$conf->setRequest($request->reveal()); |
39
|
|
|
|
40
|
|
|
$apaiIO = new ApaiIO($conf); |
41
|
|
|
$apaiIO->runOperation($operation); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testApaiIOTransformResponse() |
45
|
|
|
{ |
46
|
|
|
$conf = new GenericConfiguration(); |
47
|
|
|
$operation = new Search(); |
48
|
|
|
|
49
|
|
|
$request = $this->prophesize('\ApaiIO\Request\RequestInterface'); |
50
|
|
|
$request |
51
|
|
|
->perform($operation, $conf) |
52
|
|
|
->shouldBeCalledTimes(1) |
53
|
|
|
->willReturn(['a' => 'b']); |
54
|
|
|
|
55
|
|
|
$conf->setRequest($request->reveal()); |
56
|
|
|
|
57
|
|
|
$responseTransformer = $this->prophesize('\ApaiIO\ResponseTransformer\ResponseTransformerInterface'); |
58
|
|
|
$responseTransformer |
59
|
|
|
->transform(['a' => 'b']) |
60
|
|
|
->shouldBeCalledTimes(1); |
61
|
|
|
|
62
|
|
|
$conf->setResponseTransformer($responseTransformer->reveal()); |
63
|
|
|
|
64
|
|
|
$apaiIO = new ApaiIO($conf); |
65
|
|
|
$apaiIO->runOperation($operation); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|