|
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) |
|
|
|
|
|
|
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
|
|
|
/* |
|
|
|
|
|
|
81
|
|
|
public function it_returns_a_bib_object_given_a_barcode(AlmaClient $almaClient) |
|
82
|
|
|
{ |
|
83
|
|
|
} |
|
84
|
|
|
*/ |
|
85
|
|
|
} |
|
86
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.