1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Scriptotek\Alma\Bibs; |
4
|
|
|
|
5
|
|
|
use Scriptotek\Alma\Bibs\Bib; |
6
|
|
|
use Scriptotek\Alma\Bibs\File; |
7
|
|
|
use Scriptotek\Alma\Bibs\Representations; |
8
|
|
|
use Scriptotek\Alma\Bibs\Representation; |
9
|
|
|
use Scriptotek\Alma\Client as AlmaClient; |
10
|
|
|
use PhpSpec\ObjectBehavior; |
11
|
|
|
use Prophecy\Argument; |
12
|
|
|
use spec\Scriptotek\Alma\SpecHelper; |
13
|
|
|
|
14
|
|
|
class RepresentationSpec extends ObjectBehavior |
15
|
|
|
{ |
16
|
|
|
public function let(AlmaClient $client, Bib $bib) |
17
|
|
|
{ |
18
|
|
|
$bib->mms_id = 'abc'; |
19
|
|
|
$representation_id = '123'; |
20
|
|
|
$this->beConstructedWith($client, $bib, $representation_id); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
protected function expectRequest($client) |
24
|
|
|
{ |
25
|
|
|
$client->getJSON('/bibs/abc/representations/123') |
26
|
|
|
->shouldBeCalled() |
27
|
|
|
->willReturn(SpecHelper::getDummyData('representation_response.json')); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function it_is_initializable() |
31
|
|
|
{ |
32
|
|
|
$this->shouldHaveType(Representation::class); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function it_fetches_data_when_needed(AlmaClient $client) |
36
|
|
|
{ |
37
|
|
|
$this->expectRequest($client); |
38
|
|
|
|
39
|
|
|
$this->label->shouldBe('High resolution TIFF images'); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
View Code Duplication |
public function it_has_files(AlmaClient $client) |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
$client->getJSON('/bibs/abc/representations/123/files') |
45
|
|
|
->shouldBeCalled() |
46
|
|
|
->willReturn(SpecHelper::getDummyData('files_response.json')); |
47
|
|
|
|
48
|
|
|
$files = $this->files; |
|
|
|
|
49
|
|
|
$files->shouldHaveCount(96); |
50
|
|
|
|
51
|
|
|
$files->rewind(); |
52
|
|
|
$files->valid()->shouldBe(true); |
53
|
|
|
$files->current()->shouldHaveType(File::class); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
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.