Completed
Push — master ( b22ff2...115023 )
by Daniel
02:18
created

JobWithBrazilianLocationsBuilderTest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 111
Duplicated Lines 53.15 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 9
c 4
b 0
f 1
lcom 1
cbo 3
dl 59
loc 111
rs 10

9 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 testLocationIsAmazonas() 9 9 1
A testLocationIsAmapa() 16 16 1
A testLocationIsBahia() 0 9 1
A testLocationIsCeara() 16 16 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 View Code Duplication
    public function testLocationIsAmapa()
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...
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
    public function testLocationIsBahia()
93
    {
94
        $this->apiJob->locations = 'Bahia';
95
        $this->job = JobWithBrazilianLocationsBuilder::fromApi($this->apiJob, $this->job);
96
97
        $this->assertEquals('BA', $this->job->getState());
98
        $this->assertNull($this->job->getCity());
99
        $this->assertEquals('Brazil', $this->job->getCountry());
100
    }
101
102 View Code Duplication
    public function testLocationIsCeara()
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...
103
    {
104
        $this->apiJob->locations = 'Ceará';
105
        $this->job = JobWithBrazilianLocationsBuilder::fromApi($this->apiJob, $this->job);
106
107
        $this->assertEquals('CE', $this->job->getState());
108
        $this->assertNull($this->job->getCity());
109
        $this->assertEquals('Brazil', $this->job->getCountry());
110
111
        $this->apiJob->locations = 'Ceara';
112
        $this->job = JobWithBrazilianLocationsBuilder::fromApi($this->apiJob, $this->job);
113
114
        $this->assertEquals('CE', $this->job->getState());
115
        $this->assertNull($this->job->getCity());
116
        $this->assertEquals('Brazil', $this->job->getCountry());
117
    }
118
}
119