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