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

BibsSpec::it_provides_lookup_by_isbn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
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\Client as AlmaClient;
9
use Scriptotek\Marc\Record;
10
use Scriptotek\Sru\Client as SruClient;
11
use Scriptotek\Sru\Record as SruRecord;
12
use spec\Scriptotek\Alma\SpecHelper;
13
14
class BibsSpec extends ObjectBehavior
15
{
16
    public function let(AlmaClient $client, SruClient $sru)
17
    {
18
        $this->beConstructedWith($client);
19
        $client->sru = $sru;
20
    }
21
22 View Code Duplication
    public function it_provides_a_lazy_interface_to_bib_objects(AlmaClient $client)
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...
23
    {
24
        SpecHelper::expectNoRequests($client);
25
26
        $mms_id = '123'; // str_random();
27
        $bib = $this->get($mms_id);
28
29
        $bib->shouldHaveType(Bib::class);
30
        $bib->mms_id->shouldBe($mms_id);
31
    }
32
33 View Code Duplication
    public function it_provides_a_lazy_array_interface_to_bib_objects(AlmaClient $client)
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...
34
    {
35
        SpecHelper::expectNoRequests($client);
36
37
        $mms_id = '123'; // str_random();
38
        $bib = $this[$mms_id];
39
40
        $bib->shouldHaveType(Bib::class);
41
        $bib->mms_id->shouldBe($mms_id);
42
    }
43
44
    public function it_provides_lookup_by_isbn(AlmaClient $client, SruClient $sru)
45
    {
46
        SpecHelper::expectNoRequests($client);
47
        $client->assertHasSruClient()->shouldBeCalled()->willReturn(true);
48
49
        $sru->all('alma.isbn="123"', 1)
50
            ->shouldBeCalled()
51
            ->willReturn([SruRecord::make(1,
52
                '<record><controlfield tag="001">990114012304702201</controlfield></record>'
53
                )]);
54
55
        $bib = $this->fromIsbn('123');
56
        $bib->shouldHaveType(Bib::class);
57
58
        // This operation should be lazy
59
        $bib->mms_id->shouldBe('990114012304702201');
60
61
        // This operation should also be lazy
62
        $bib->record->shouldBeAnInstanceOf(Record::class);
63
    }
64
65
    public function it_returns_null_given_unknown_isbn(AlmaClient $client, SruClient $sru)
66
    {
67
        SpecHelper::expectNoRequests($client);
68
        $client->assertHasSruClient()->shouldBeCalled()->willReturn(true);
69
70
        $sru->all('alma.isbn="123"', 1)
71
            ->shouldBeCalled()
72
            ->willReturn([]);
73
74
        $bib = $this->fromIsbn('123');
75
        $bib->shouldBe(null);
76
    }
77
78
    public function it_supports_lookup_by_holding_id(AlmaClient $client)
79
    {
80
        $client->getJSON('/bibs', Argument::containing('12345'))
81
            ->shouldBeCalled()
82
            ->willReturn(SpecHelper::getDummyData('bibs_holdings.json'));
83
84
        $bib = $this->fromHoldingsId('12345');
85
        $bib->shouldHaveType(Bib::class);
86
        $bib->mms_id->shouldBe('990006312214702204');
87
    }
88
89
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
90
    public function it_returns_a_bib_object_given_a_barcode(AlmaClient $client)
91
    {
92
    }
93
    */
94
}
95