Test Setup Failed
Push — master ( 8a6c4e...2f310d )
by Dan Michael O.
07:45
created

JobInstancesSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 34.48 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 10
loc 29
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 5 1
A it_provides_a_lazy_interface_to_jobinstance_objects() 0 9 1
A it_provides_jobintances() 10 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Job;
8
use Scriptotek\Alma\Conf\JobInstance;
9
use spec\Scriptotek\Alma\SpecHelper;
10
11
class JobInstancesSpec extends ObjectBehavior
12
{
13
    public function let(AlmaClient $client, Job $job)
14
    {
15
        $job->job_id = '1108569450000121';
16
        $this->beConstructedWith($client, $job);
17
    }
18
19
    public function it_provides_a_lazy_interface_to_jobinstance_objects(AlmaClient $client)
20
    {
21
        SpecHelper::expectNoRequests($client);
22
23
        $jobId = '1108569450000121';
24
        $instanceId = '1108569450000121';
25
        $jobInstance = $this->get($jobId, $instanceId);
26
        $jobInstance->shouldBeAnInstanceOf(JobInstance::class);
27
    }
28
29 View Code Duplication
    public function it_provides_jobintances(AlmaClient $client)
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...
30
    {
31
        $jobId = '1108569450000121';
32
        $client->getJSON("/conf/jobs/{$jobId}/instances")
33
            ->shouldBeCalled()
34
            ->willReturn(SpecHelper::getDummyData('jobinstances_response.json'));
35
36
        $this->all()->shouldBeArray();
37
        $this->all()[0]->shouldBeAnInstanceOf(JobInstance::class);
38
    }
39
}
40