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

testLocationIsCeara()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 16
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 16
loc 16
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
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