Completed
Push — master ( 098137...75ec1f )
by Daniel
02:13
created

JobWithBrazilianLocationsBuilderTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 84
Duplicated Lines 32.14 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 7
c 3
b 0
f 1
lcom 1
cbo 3
dl 27
loc 84
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testFromApiThrowsCareerjetExceptionWhenLocationIsNotPresent() 0 7 1
A testLocationIsBrasil() 0 9 1
A testLocationIsAcre() 9 9 1
A testLocationIsAlagoas() 9 9 1
A testLocationIsAmapa() 0 16 1
A testLocationIsAmazonas() 9 9 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 Jobles\Tests\Careerjet\Builder;
4
5
use Jobles\Careerjet\Builder\JobWithBrazilianLocationsBuilder;
6
use Jobles\Core\Job\Job;
7
8
class JobWithBrazilianLocationsBuilderTest extends \PHPUnit_Framework_TestCase
9
{
10
    /**
11
     * @var \stdClass
12
     */
13
    private $apiJob;
14
15
    /**
16
     * @var Job
17
     */
18
    private $job;
19
20
    public function setUp()
21
    {
22
        $this->apiJob = new \stdClass;
23
        $this->job = new Job;
24
        $this->job->setCountry('Brazil');
25
    }
26
27
    public function testFromApiThrowsCareerjetExceptionWhenLocationIsNotPresent()
28
    {
29
        $this->expectException(\Jobles\Careerjet\Exception\CareerjetException::class);
30
        $this->expectExceptionMessage('Invalid API job');
31
32
        JobWithBrazilianLocationsBuilder::fromApi(new \stdClass, new Job);
33
    }
34
35
    public function testLocationIsBrasil()
36
    {
37
        $this->apiJob->locations = 'Brasil';
38
        $this->job = JobWithBrazilianLocationsBuilder::fromApi($this->apiJob, $this->job);
39
40
        $this->assertNull($this->job->getState());
41
        $this->assertNull($this->job->getCity());
42
        $this->assertEquals('Brazil', $this->job->getCountry());
43
    }
44
45 View Code Duplication
    public function testLocationIsAcre()
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...
46
    {
47
        $this->apiJob->locations = 'Acre';
48
        $this->job = JobWithBrazilianLocationsBuilder::fromApi($this->apiJob, $this->job);
49
50
        $this->assertEquals('AC', $this->job->getState());
51
        $this->assertNull($this->job->getCity());
52
        $this->assertEquals('Brazil', $this->job->getCountry());
53
    }
54
55 View Code Duplication
    public function testLocationIsAlagoas()
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...
56
    {
57
        $this->apiJob->locations = 'Alagoas';
58
        $this->job = JobWithBrazilianLocationsBuilder::fromApi($this->apiJob, $this->job);
59
60
        $this->assertEquals('AL', $this->job->getState());
61
        $this->assertNull($this->job->getCity());
62
        $this->assertEquals('Brazil', $this->job->getCountry());
63
    }
64
65
    public function testLocationIsAmapa()
66
    {
67
        $this->apiJob->locations = 'Amapá';
68
        $this->job = JobWithBrazilianLocationsBuilder::fromApi($this->apiJob, $this->job);
69
70
        $this->assertEquals('AP', $this->job->getState());
71
        $this->assertNull($this->job->getCity());
72
        $this->assertEquals('Brazil', $this->job->getCountry());
73
74
        $this->apiJob->locations = 'Amapa';
75
        $this->job = JobWithBrazilianLocationsBuilder::fromApi($this->apiJob, $this->job);
76
77
        $this->assertEquals('AP', $this->job->getState());
78
        $this->assertNull($this->job->getCity());
79
        $this->assertEquals('Brazil', $this->job->getCountry());
80
    }
81
82 View Code Duplication
    public function testLocationIsAmazonas()
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...
83
    {
84
        $this->apiJob->locations = 'Amazonas';
85
        $this->job = JobWithBrazilianLocationsBuilder::fromApi($this->apiJob, $this->job);
86
87
        $this->assertEquals('AM', $this->job->getState());
88
        $this->assertNull($this->job->getCity());
89
        $this->assertEquals('Brazil', $this->job->getCountry());
90
    }
91
}
92