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() |
|
|
|
|
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() |
|
|
|
|
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() |
|
|
|
|
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
|
|
|
|
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.