Completed
Push — master ( 051205...7fa98e )
by Dan Michael O.
02:12
created

BibsSpec::it_supports_lookup_by_holding_id()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 2
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace spec\Scriptotek\Alma\Bibs;
4
5
use Danmichaelo\QuiteSimpleXMLElement\QuiteSimpleXMLElement;
6
use PhpSpec\ObjectBehavior;
7
use Prophecy\Argument;
8
use Scriptotek\Alma\Bibs\Bib;
9
use Scriptotek\Alma\Bibs\Bibs;
10
use Scriptotek\Alma\Client as AlmaClient;
11
use Scriptotek\Sru\Client as SruClient;
12
use Scriptotek\Sru\Record as SruRecord;
13
use spec\Scriptotek\Alma\SpecHelper;
14
15
class BibsSpec extends ObjectBehavior
16
{
17
    public function let(AlmaClient $almaClient, SruClient $sru)
18
    {
19
        $this->beConstructedWith($almaClient);
20
        $almaClient->sru = $sru;
21
    }
22
23
    public function it_is_initializable(AlmaClient $almaClient)
24
    {
25
        $this->beConstructedWith($almaClient);
26
        $this->shouldHaveType(Bibs::class);
27
    }
28
29
    public function it_provides_an_interface_to_bib_objects(AlmaClient $almaClient)
30
    {
31
        $this->beConstructedWith($almaClient);
32
33
        $mms_id = '123'; // str_random();
34
        $bib = $this->get($mms_id);
35
36
        $bib->shouldHaveType(Bib::class);
37
        $bib->mms_id->shouldBe($mms_id);
38
    }
39
40
    public function it_returns_a_bib_object_given_an_isbn(AlmaClient $almaClient, SruClient $sru)
41
    {
42
        $this->beConstructedWith($almaClient);
43
        $almaClient->sru = $sru;
44
45
        $sru->first('alma.isbn="123"')
46
            ->shouldBeCalled()
47
            ->willReturn(SruRecord::make(1,
48
                '<record><controlfield tag="001">990114012304702201</controlfield></record>'
49
                ));
50
51
        $bib = $this->fromIsbn('123');
52
        $bib->shouldHaveType(Bib::class);
53
        $bib->mms_id->shouldBe('990114012304702201');
54
    }
55
56
    public function it_returns_null_given_unknown_isbn(AlmaClient $almaClient, SruClient $sru)
57
    {
58
        $this->beConstructedWith($almaClient);
59
        $almaClient->sru = $sru;
60
61
        $sru->first('alma.isbn="123"')
62
            ->shouldBeCalled()
63
            ->willReturn(null);
64
65
        $bib = $this->fromIsbn('123');
66
        $bib->shouldBe(null);
67
    }
68
69
    public function it_supports_lookup_by_holding_id(AlmaClient $almaClient, SruClient $sru)
0 ignored issues
show
Unused Code introduced by
The parameter $sru 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...
70
    {
71
        $almaClient->getXML('/bibs', Argument::containing('12345'), Argument::any())
72
            ->shouldBeCalled()
73
            ->willReturn(SpecHelper::getDummyData('bibs_holdings.xml'));
74
75
        $bib = $this->fromHoldingsId('12345');
76
        $bib->shouldHaveType(Bib::class);
77
        $bib->mms_id->shouldBe('999900137074702204');
78
    }
79
80
    /*
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...
81
    public function it_returns_a_bib_object_given_a_barcode(AlmaClient $almaClient)
82
    {
83
    }
84
    */
85
}
86