Test Failed
Push — master ( c6b6d3...528954 )
by Dan Michael O.
03:21
created

ItemsSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 46
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 12 1
A it_returns_an_item_object_given_a_barcode() 0 18 1
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)
0 ignored issues
show
Unused Code introduced by
The parameter $url is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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