1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Scriptotek\Alma\Analytics; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
use Scriptotek\Alma\Analytics\Report; |
7
|
|
|
use Scriptotek\Alma\Analytics\Row; |
8
|
|
|
use Scriptotek\Alma\Client; |
9
|
|
|
use spec\Scriptotek\Alma\SpecHelper; |
10
|
|
|
|
11
|
|
|
class ReportSpec extends ObjectBehavior |
12
|
|
|
{ |
13
|
|
|
public function let(Client $almaClient) |
14
|
|
|
{ |
15
|
|
|
$path = 'xyz'; |
16
|
|
|
$this->beConstructedWith($almaClient, $path); |
17
|
|
|
$almaClient->getXML('/analytics/reports', ['path' => $path, 'limit' => 1000, 'token' => null, 'filter' => null]) |
18
|
|
|
->willReturn(SpecHelper::getDummyData('analytics_response.xml')); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function it_is_initializable() |
22
|
|
|
{ |
23
|
|
|
$this->shouldHaveType(Report::class); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function it_has_rows() |
27
|
|
|
{ |
28
|
|
|
$this->rows->shouldImplement(\Generator::class); |
|
|
|
|
29
|
|
|
$this->rows->current()->shouldBeAnInstanceOf(Row::class); |
|
|
|
|
30
|
|
|
$this->getRows()->shouldHaveCount(14); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function it_supports_setting_headers(Client $almaClient) |
34
|
|
|
{ |
35
|
|
|
$this->beConstructedWith($almaClient, 'xyz', ['a', 'b']); |
36
|
|
|
|
37
|
|
|
$this->headers->shouldBe(['a', 'b']); |
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function it_supports_setting_filter(Client $almaClient) |
41
|
|
|
{ |
42
|
|
|
$this->beConstructedWith($almaClient, 'xyz', ['a', 'b'], 'la la la'); |
43
|
|
|
|
44
|
|
|
$this->filter->shouldBe('la la la'); |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function it_supports_resumption(Client $almaClient) |
48
|
|
|
{ |
49
|
|
|
$path = 'xyz'; |
50
|
|
|
|
51
|
|
|
$almaClient->getXML('/analytics/reports', ['path' => $path, 'limit' => 1000, 'token' => null, 'filter' => null]) |
52
|
|
|
->shouldBeCalledTimes(1) |
53
|
|
|
->willReturn(SpecHelper::getDummyData('analytics_response_part1.xml')); |
54
|
|
|
|
55
|
|
|
$almaClient->getXML('/analytics/reports', ['path' => null, 'limit' => 1000, 'token' => '9672D715A8E2EAAA6F30DD22FC52BE4CCAE35E29D921E0AC8BE8C6734C9E1571B4E48EEFCA4046EFF8CD7D1662C2D0A7677D3AD05EDC3CA7F06182E34E9D7A2F', 'filter' => null]) |
56
|
|
|
->shouldBeCalledTimes(3) |
57
|
|
|
->willReturn( |
58
|
|
|
|
59
|
|
|
# If Analytics has a bad day, we might get a "still loading" response |
60
|
|
|
# See: https://bitbucket.org/uwlib/uwlib-alma-analytic-tools/wiki/Understanding_Analytic_GET_Requests#!analytic-still-loading |
61
|
|
|
SpecHelper::getDummyData('analytics_still_loading_response.xml'), |
62
|
|
|
|
63
|
|
|
SpecHelper::getDummyData('analytics_response_part2.xml'), |
64
|
|
|
SpecHelper::getDummyData('analytics_response_part3.xml') |
65
|
|
|
); |
66
|
|
|
|
67
|
|
|
$this->getRows()->shouldHaveCount(150 + 150 + 88); |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.