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\Bibs\Bibs; |
9
|
|
|
use Scriptotek\Alma\Bibs\Holding; |
10
|
|
|
use Scriptotek\Alma\Bibs\Holdings; |
11
|
|
|
use Scriptotek\Alma\Client as AlmaClient; |
12
|
|
|
use Scriptotek\Marc\Record; |
13
|
|
|
use spec\Scriptotek\Alma\SpecHelper; |
14
|
|
|
|
15
|
|
|
class BibSpec extends ObjectBehavior |
16
|
|
|
{ |
17
|
|
View Code Duplication |
public function let(AlmaClient $almaClient) |
|
|
|
|
18
|
|
|
{ |
19
|
|
|
$mms_id = '999104760474702204'; |
20
|
|
|
$this->beConstructedWith($almaClient, $mms_id); |
21
|
|
|
|
22
|
|
|
$almaClient->getXML(Argument::containingString('999104760474702204'), Argument::any()) |
23
|
|
|
->willReturn(SpecHelper::getDummyData('bib_response_iz.xml')); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function it_is_initializable() |
27
|
|
|
{ |
28
|
|
|
$this->shouldHaveType(Bib::class); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function it_provides_bib_record_data(AlmaClient $almaClient) |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
$this->created_date->shouldBe('2015-11-05Z'); |
|
|
|
|
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function it_links_to_network_zone(AlmaClient $almaClient, AlmaClient $nz, Bibs $bibs, Bib $nz_bib) |
37
|
|
|
{ |
38
|
|
|
$almaClient->nz = $nz; |
|
|
|
|
39
|
|
|
$nz->bibs = $bibs; |
40
|
|
|
$bibs->get('999104760474702201') |
41
|
|
|
->shouldBeCalled() |
42
|
|
|
->willReturn($nz_bib); |
43
|
|
|
|
44
|
|
|
$this->getNzRecord()->shouldHaveType(Bib::class); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function it_has_holdings(AlmaClient $almaClient, AlmaClient $nz, Bibs $bibs) |
|
|
|
|
48
|
|
|
{ |
49
|
|
|
$this->holdings->shouldHaveType(Holdings::class); |
|
|
|
|
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function it_allows_looking_up_a_single_holding(AlmaClient $almaClient, AlmaClient $nz, Bibs $bibs) |
|
|
|
|
53
|
|
|
{ |
54
|
|
|
$this->getHolding('123')->shouldHaveType(Holding::class); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function it_has_a_MARC_record(AlmaClient $almaClient) |
|
|
|
|
58
|
|
|
{ |
59
|
|
|
$this->record->shouldHaveType(Record::class); |
|
|
|
|
60
|
|
|
$this->record->getField('245')->getSubfield('a')->getData()->shouldBe('Lonely hearts of the cosmos :'); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function it_can_be_edited(AlmaClient $almaClient) |
64
|
|
|
{ |
65
|
|
|
$this->record->getField('245')->getSubfield('a')->setData('New title'); |
|
|
|
|
66
|
|
|
|
67
|
|
|
$almaClient->putXML('/bibs/999104760474702204', Argument::containingString('New title')) |
68
|
|
|
->shouldBeCalled(); |
69
|
|
|
$this->save(); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
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.