Completed
Push — master ( 47778c...ba169d )
by Dan Michael O.
10:36
created

LoansSpec::it_can_be_empty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 15
loc 15
rs 9.7666
c 0
b 0
f 0
1
<?php
2
3
namespace spec\Scriptotek\Alma\Users;
4
5
use Scriptotek\Alma\Client as AlmaClient;
6
use Psr\Http\Message\UriInterface;
7
use Scriptotek\Alma\Users\Loan;
8
use Scriptotek\Alma\Users\Loans;
9
use PhpSpec\ObjectBehavior;
10
use Scriptotek\Alma\Users\User;
11
use spec\Scriptotek\Alma\SpecHelper;
12
13
class LoansSpec extends ObjectBehavior
14
{
15
    public function let(AlmaClient $client, User $user)
16
    {
17
        $user->id = '123435';
18
        $this->beConstructedWith($client, $user);
19
    }
20
21
    public function it_is_initializable()
22
    {
23
        $this->shouldHaveType(Loans::class);
24
    }
25
26 View Code Duplication
    public function it_yields_loans(AlmaClient $client, UriInterface $url)
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...
27
    {
28
        $client->buildUrl('/users/123435/loans', ['offset' => 0, 'limit' => 10])
29
            ->shouldBeCalled()
30
            ->willReturn($url);
31
32
        $client->getJSON($url)
33
            ->shouldBeCalled()
34
            ->willReturn(SpecHelper::getDummyData('loans_response.json'));
35
36
37
        $this->rewind();
38
        $this->valid()->shouldBe(true);
39
        $this->current()->shouldBeAnInstanceOf(Loan::class);
40
41
        $this->shouldHaveCount(2);
42
    }
43
44 View Code Duplication
    public function it_can_be_empty(AlmaClient $client, UriInterface $url)
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...
45
    {
46
        $client->buildUrl('/users/123435/loans', ['offset' => 0, 'limit' => 10])
47
            ->shouldBeCalled()
48
            ->willReturn($url);
49
50
        $client->getJSON($url)
51
            ->shouldBeCalled()
52
            ->willReturn(SpecHelper::getDummyData('zero_loans_response.json'));
53
54
        $this->rewind();
55
        $this->valid()->shouldBe(false);
56
57
        $this->shouldHaveCount(0);
58
    }
59
}
60