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

ItemSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace spec\Scriptotek\Alma\Bibs;
4
5
use PhpSpec\ObjectBehavior;
6
use Psr\Http\Message\UriInterface;
7
use Scriptotek\Alma\Bibs\Bib;
8
use Scriptotek\Alma\Bibs\Holding;
9
use Scriptotek\Alma\Bibs\Item;
10
use Scriptotek\Alma\Client as AlmaClient;
11
use Scriptotek\Alma\Bibs\ScanInResponse;
12
use Scriptotek\Alma\Conf\Library;
13
use Scriptotek\Alma\Users\Loan;
14
use Scriptotek\Alma\Users\User;
15
use spec\Scriptotek\Alma\SpecHelper;
16
17
class ItemSpec extends ObjectBehavior
18
{
19
    public function let(AlmaClient $client, Bib $bib, Holding $holding)
20
    {
21
        $bib->mms_id = '990006312214702204';
22
        $holding->holding_id = '22163771200002204';
23
        $item_id = '23163771190002204';
24
25
        $this->beConstructedWith($client, $bib, $holding, $item_id);
26
    }
27
28
    public function it_is_initializable()
29
    {
30
        $this->shouldHaveType(Item::class);
31
    }
32
33
    function it_can_be_checked_out(AlmaClient $client, User $user, Library $library, UriInterface $url)
34
    {
35
        $client->buildUrl('/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204/loans', ['user_id' => 'Dan Michael'])
36
            ->willReturn($url);
37
38
        $client->postJSON($url, [
39
            'library' => ['value' => 'THAT LIBRARY'], 'circ_desk' => ['value' => 'DEFAULT_CIRC_DESK']])
40
            ->shouldBeCalled()
41
            ->willReturn(SpecHelper::getDummyData('create_loan_response.json'));
42
43
        $user->id = 'Dan Michael';
44
        $library->code = 'THAT LIBRARY';
45
46
        $this->checkOut($user, $library)
47
            ->shouldHaveType(Loan::class);
48
    }
49
50 View Code Duplication
    function it_can_be_on_loan(AlmaClient $client, User $user, Library $library, UriInterface $url)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
    {
52
        $client->buildUrl('/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204/loans', [])
53
            ->willReturn($url);
54
55
        $client->getJSON($url)
56
            ->shouldBeCalled()
57
            ->willReturn(SpecHelper::getDummyData('item_loan_response.json'));
58
59
        $user->id = 'Dan Michael';
60
        $library->code = 'THAT LIBRARY';
61
62
        $this->loan()->shouldHaveType(Loan::class);
63
    }
64
65
    function it_can_be_scanned_in(AlmaClient $client, Library $library, UriInterface $url)
66
    {
67
        $client->buildUrl('/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204', [
68
            'op' => 'scan',
69
            'library' => 'THAT LIBRARY',
70
            'circ_desk' => 'DEFAULT_CIRC_DESK',
71
        ])->willReturn($url);
72
73
        $client->postJSON($url)
74
            ->shouldBeCalled()
75
            ->willReturn(SpecHelper::getDummyData('scanin_transit_response.json'));
76
77
        $library->code = 'THAT LIBRARY';
78
79
        $this->scanIn($library)
80
            ->shouldHaveType(ScanInResponse::class);
81
    }
82
}
83