|
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
|
|
|
public function testFromApiThrowsCareerjetExceptionWhenLocationIsNotPresent() |
|
11
|
|
|
{ |
|
12
|
|
|
$this->expectException(\Jobles\Careerjet\Exception\CareerjetException::class); |
|
13
|
|
|
$this->expectExceptionMessage('Invalid API job'); |
|
14
|
|
|
|
|
15
|
|
|
JobWithBrazilianLocationsBuilder::fromApi(new \stdClass, new Job); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
View Code Duplication |
public function testLocationIsBrasil() |
|
|
|
|
|
|
19
|
|
|
{ |
|
20
|
|
|
$apiJob = new \stdClass; |
|
21
|
|
|
$apiJob->locations = 'Brasil'; |
|
22
|
|
|
|
|
23
|
|
|
$job = new Job; |
|
24
|
|
|
$job->setCountry('Brazil'); |
|
25
|
|
|
$job = JobWithBrazilianLocationsBuilder::fromApi($apiJob, $job); |
|
26
|
|
|
|
|
27
|
|
|
$this->assertNull($job->getState()); |
|
28
|
|
|
$this->assertNull($job->getCity()); |
|
29
|
|
|
$this->assertEquals('Brazil', $job->getCountry()); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
View Code Duplication |
public function testLocationIsAcre() |
|
|
|
|
|
|
33
|
|
|
{ |
|
34
|
|
|
$apiJob = new \stdClass; |
|
35
|
|
|
$apiJob->locations = 'Acre'; |
|
36
|
|
|
|
|
37
|
|
|
$job = new Job; |
|
38
|
|
|
$job->setCountry('Brazil'); |
|
39
|
|
|
$job = JobWithBrazilianLocationsBuilder::fromApi($apiJob, $job); |
|
40
|
|
|
|
|
41
|
|
|
$this->assertEquals('AC', $job->getState()); |
|
42
|
|
|
$this->assertNull($job->getCity()); |
|
43
|
|
|
$this->assertEquals('Brazil', $job->getCountry()); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
View Code Duplication |
public function testLocationIsAlagoas() |
|
|
|
|
|
|
47
|
|
|
{ |
|
48
|
|
|
$apiJob = new \stdClass; |
|
49
|
|
|
$apiJob->locations = 'Alagoas'; |
|
50
|
|
|
|
|
51
|
|
|
$job = new Job; |
|
52
|
|
|
$job->setCountry('Brazil'); |
|
53
|
|
|
$job = JobWithBrazilianLocationsBuilder::fromApi($apiJob, $job); |
|
54
|
|
|
|
|
55
|
|
|
$this->assertEquals('AL', $job->getState()); |
|
56
|
|
|
$this->assertNull($job->getCity()); |
|
57
|
|
|
$this->assertEquals('Brazil', $job->getCountry()); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function testLocationIsAmapa() |
|
61
|
|
|
{ |
|
62
|
|
|
$apiJob = new \stdClass; |
|
63
|
|
|
$apiJob->locations = 'Amapá'; |
|
64
|
|
|
|
|
65
|
|
|
$job = new Job; |
|
66
|
|
|
$job->setCountry('Brazil'); |
|
67
|
|
|
$job = JobWithBrazilianLocationsBuilder::fromApi($apiJob, $job); |
|
68
|
|
|
|
|
69
|
|
|
$this->assertEquals('AP', $job->getState()); |
|
70
|
|
|
$this->assertNull($job->getCity()); |
|
71
|
|
|
$this->assertEquals('Brazil', $job->getCountry()); |
|
72
|
|
|
|
|
73
|
|
|
$apiJob->locations = 'Amapa'; |
|
74
|
|
|
$job = JobWithBrazilianLocationsBuilder::fromApi($apiJob, $job); |
|
75
|
|
|
|
|
76
|
|
|
$this->assertEquals('AP', $job->getState()); |
|
77
|
|
|
$this->assertNull($job->getCity()); |
|
78
|
|
|
$this->assertEquals('Brazil', $job->getCountry()); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
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.