|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace spec\Scriptotek\Alma\Bibs; |
|
4
|
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
|
6
|
|
|
use Scriptotek\Alma\Bibs\Bib; |
|
7
|
|
|
use Scriptotek\Alma\Bibs\Holding; |
|
8
|
|
|
use Scriptotek\Alma\Bibs\Item; |
|
9
|
|
|
use Scriptotek\Alma\Client as AlmaClient; |
|
10
|
|
|
use Scriptotek\Marc\Record; |
|
11
|
|
|
use spec\Scriptotek\Alma\SpecHelper; |
|
12
|
|
|
|
|
13
|
|
|
class HoldingSpec extends ObjectBehavior |
|
14
|
|
|
{ |
|
15
|
|
|
public function let(AlmaClient $client, Bib $bib) |
|
16
|
|
|
{ |
|
17
|
|
|
$bib->mms_id = 'abc'; |
|
18
|
|
|
$holdings_id = '123'; |
|
19
|
|
|
$this->beConstructedWith($client, $bib, $holdings_id); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
protected function expectRequest($client) |
|
23
|
|
|
{ |
|
24
|
|
|
$client->getXML('/bibs/abc/holdings/123') |
|
25
|
|
|
->shouldBeCalled() |
|
26
|
|
|
->willReturn(SpecHelper::getDummyData('holding_response.xml')); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function it_is_initializable() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->shouldHaveType(Holding::class); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function it_fetches_record_data_when_needed(AlmaClient $client) |
|
35
|
|
|
{ |
|
36
|
|
|
$this->expectRequest($client); |
|
37
|
|
|
|
|
38
|
|
|
$this->created_by->shouldBe('import'); |
|
|
|
|
|
|
39
|
|
|
$this->created_date->shouldBe('2015-11-05Z'); |
|
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
$this->record->shouldHaveType(Record::class); |
|
|
|
|
|
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
View Code Duplication |
public function it_has_items(AlmaClient $client) |
|
|
|
|
|
|
45
|
|
|
{ |
|
46
|
|
|
$client->getJSON('/bibs/abc/holdings/123/items') |
|
47
|
|
|
->shouldBeCalled() |
|
48
|
|
|
->willReturn(SpecHelper::getDummyData('items_response.json')); |
|
49
|
|
|
|
|
50
|
|
|
$items = $this->items; |
|
|
|
|
|
|
51
|
|
|
$items->shouldHaveCount(9); |
|
52
|
|
|
|
|
53
|
|
|
$items->rewind(); |
|
54
|
|
|
$items->valid()->shouldBe(true); |
|
55
|
|
|
$items->current()->shouldHaveType(Item::class); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
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@propertyannotation 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.