ItemsSpec   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 5 1
A it_is_initializable() 0 5 1
A it_returns_a_lazy_loaded_item_object_given_a_barcode() 0 9 1
A it_returns_an_item_object_given_a_barcode() 0 14 1
1
<?php
2
3
namespace spec\Scriptotek\Alma\Bibs;
4
5
use PhpSpec\ObjectBehavior;
6
use Prophecy\Argument;
7
use Scriptotek\Alma\Bibs\Bib;
8
use Scriptotek\Alma\Bibs\Holding;
9
use Scriptotek\Alma\Bibs\Item;
10
use Scriptotek\Alma\Bibs\Items;
11
use Scriptotek\Alma\Client as AlmaClient;
12
use Scriptotek\Sru\Client as SruClient;
13
use spec\Scriptotek\Alma\SpecHelper;
14
15
class ItemsSpec extends ObjectBehavior
16
{
17
    public function let(AlmaClient $client, SruClient $sru, Bib $bib, Holding $holding)
18
    {
19
        $this->beConstructedWith($client, $bib, $holding);
20
        $client->sru = $sru;
21
    }
22
23
    public function it_is_initializable(AlmaClient $client)
24
    {
25
        $this->beConstructedWith($client);
26
        $this->shouldHaveType(Items::class);
27
    }
28
29
    public function it_returns_a_lazy_loaded_item_object_given_a_barcode(AlmaClient $client)
30
    {
31
        $client->getRedirectLocation('/items', Argument::containing('303011kj0'))
32
            ->shouldBeCalled()
33
            ->willReturn('https://api-eu.hosted.exlibrisgroup.com/almaws/v1/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204');
34
35
        $item = $this->fromBarcode('303011kj0');
36
        $item->shouldHaveType(Item::class);
37
    }
38
39
    public function it_returns_an_item_object_given_a_barcode(AlmaClient $client)
40
    {
41
        $client->getRedirectLocation('/items', Argument::containing('303011kj0'))
42
            ->shouldBeCalled()
43
            ->willReturn('https://api-eu.hosted.exlibrisgroup.com/almaws/v1/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204');
44
45
        $client->getJSON('/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204')
46
            ->shouldBeCalled()
47
            ->willReturn(SpecHelper::getDummyData('item_response.json'));
48
49
        $item = $this->fromBarcode('303011kj0');
50
        $item->shouldHaveType(Item::class);
51
        $item->pid->shouldBe('23163771190002204');
52
    }
53
}
54