1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Scriptotek\Alma\Bibs; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
use Prophecy\Argument; |
7
|
|
|
use Psr\Http\Message\UriInterface; |
8
|
|
|
use Scriptotek\Alma\Bibs\Bib; |
9
|
|
|
use Scriptotek\Alma\Bibs\Holding; |
10
|
|
|
use Scriptotek\Alma\Bibs\Item; |
11
|
|
|
use Scriptotek\Alma\Bibs\Items; |
12
|
|
|
use Scriptotek\Alma\Client as AlmaClient; |
13
|
|
|
use Scriptotek\Sru\Client as SruClient; |
14
|
|
|
use spec\Scriptotek\Alma\SpecHelper; |
15
|
|
|
|
16
|
|
|
class ItemsSpec extends ObjectBehavior |
17
|
|
|
{ |
18
|
|
|
public function let(AlmaClient $client, SruClient $sru, Bib $bib, Holding $holding) |
19
|
|
|
{ |
20
|
|
|
$this->beConstructedWith($client, $bib, $holding); |
21
|
|
|
$client->sru = $sru; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function it_is_initializable(AlmaClient $client) |
25
|
|
|
{ |
26
|
|
|
$this->beConstructedWith($client); |
27
|
|
|
$this->shouldHaveType(Items::class); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function it_returns_a_lazy_loaded_item_object_given_a_barcode(AlmaClient $client, UriInterface $url) |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
$client->getRedirectLocation('/items', Argument::containing('303011kj0')) |
33
|
|
|
->shouldBeCalled() |
34
|
|
|
->willReturn('https://api-eu.hosted.exlibrisgroup.com/almaws/v1/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204'); |
35
|
|
|
|
36
|
|
|
$client->buildUrl('/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204', []) |
37
|
|
|
->shouldNotBeCalled(); |
38
|
|
|
|
39
|
|
|
$item = $this->fromBarcode('303011kj0'); |
40
|
|
|
$item->shouldHaveType(Item::class); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function it_returns_an_item_object_given_a_barcode(AlmaClient $client, UriInterface $url) |
44
|
|
|
{ |
45
|
|
|
$client->getRedirectLocation('/items', Argument::containing('303011kj0')) |
46
|
|
|
->shouldBeCalled() |
47
|
|
|
->willReturn('https://api-eu.hosted.exlibrisgroup.com/almaws/v1/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204'); |
48
|
|
|
|
49
|
|
|
$client->buildUrl('/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204', []) |
50
|
|
|
->shouldBeCalled() |
51
|
|
|
->willReturn($url); |
52
|
|
|
|
53
|
|
|
$client->getJSON($url) |
54
|
|
|
->shouldBeCalled() |
55
|
|
|
->willReturn(SpecHelper::getDummyData('item_response.json')); |
56
|
|
|
|
57
|
|
|
$item = $this->fromBarcode('303011kj0'); |
58
|
|
|
$item->shouldHaveType(Item::class); |
59
|
|
|
$item->pid->shouldBe('23163771190002204'); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.