LibrariesSpec::let()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace spec\Scriptotek\Alma\Conf;
4
5
use PhpSpec\ObjectBehavior;
6
use Scriptotek\Alma\Client as AlmaClient;
7
use Scriptotek\Alma\Conf\Libraries;
8
use Scriptotek\Alma\Conf\Library;
9
use spec\Scriptotek\Alma\SpecHelper;
10
11
class LibrariesSpec extends ObjectBehavior
12
{
13
    public function let(AlmaClient $client)
14
    {
15
        $this->beConstructedWith($client);
16
    }
17
18
    public function it_is_muh()
19
    {
20
        $this->shouldBeAnInstanceOf(Libraries::class);
21
        $this->shouldImplement(\Countable::class);
22
        $this->shouldImplement(\Iterator::class);
23
    }
24
25
    public function it_provides_a_lazy_interface_to_libary_objects(AlmaClient $client)
26
    {
27
        SpecHelper::expectNoRequests($client);
28
29
        $libraryCode = 'THAT_LIBRARY';
30
        $library = $this->get($libraryCode);
31
32
        $library->shouldBeAnInstanceOf(Library::class);
33
        $library->code->shouldBe($libraryCode);
34
    }
35
36
    public function it_provides_libraries(AlmaClient $client)
37
    {
38
        $client->getJSON('/conf/libraries')
39
            ->shouldBeCalled()
40
            ->willReturn(SpecHelper::getDummyData('libraries_response.json'));
41
42
        $this->shouldHaveCount(27);
43
        $this->all()->shouldBeArray();
44
        $this->all()[0]->shouldBeAnInstanceOf(Library::class);
45
    }
46
}
47