1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the FabienCrassat\CurriculumVitaeBundle Symfony bundle. |
5
|
|
|
* |
6
|
|
|
* (c) Fabien Crassat <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace FabienCrassat\CurriculumVitaeBundle\Tests\Entity; |
13
|
|
|
|
14
|
|
|
use FabienCrassat\CurriculumVitaeBundle\Entity\CurriculumVitae; |
15
|
|
|
|
16
|
|
|
class CurriculumVitaeTest extends \PHPUnit\Framework\TestCase |
17
|
|
|
{ |
18
|
|
|
private $curriculumVitae; |
19
|
|
|
private $lang; |
20
|
|
|
private $interface; |
21
|
|
|
private $arrayToCompare; |
22
|
|
|
|
23
|
|
|
const XML_CORE = '/../Resources/data/core.xml'; |
24
|
|
|
|
25
|
|
|
public function setUp() { |
26
|
|
|
$this->lang = 'en'; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function testNoLanguage() { |
30
|
|
|
$this->interface = 'getDropDownLanguages'; |
31
|
|
|
|
32
|
|
|
$this->arrayToCompare = [$this->lang => $this->lang]; |
33
|
|
|
|
34
|
|
|
$this->assertCVInterface(self::XML_CORE); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testSpecialCharacters() { |
38
|
|
|
$this->interface = 'getLookingFor'; |
39
|
|
|
|
40
|
|
|
$this->arrayToCompare = [ |
41
|
|
|
'experience' => 'Curriculum Vitae With Special Characters', |
42
|
|
|
'presentation' => 'AZERTY keyboard' |
43
|
|
|
.' Line 1 ²é"(-è_çà)=' |
44
|
|
|
.' Line 1 with shift 1234567890°+' |
45
|
|
|
.' Line 1 with Alt Gr ~#{[|`\^@]}' |
46
|
|
|
.' Line 2 azertyuiop^$' |
47
|
|
|
.' Line 2 with shift AZERTYUIOP¨£' |
48
|
|
|
.' Line 2 with Alt Gr €¤' |
49
|
|
|
.' Line 3 qsdfghjklmù*' |
50
|
|
|
.' Line 3 with shift QSDFGHJKLM%µ' |
51
|
|
|
.' Line 3 with Alt Gr ' |
52
|
|
|
.' Line 4 wxcvbn,;:!' |
53
|
|
|
.' Line 4 with shift WXCVBN?./§' |
54
|
|
|
.' Line 4 with Alt Gr ' |
55
|
|
|
.' Escape Characters < > &' |
56
|
|
|
.' End' |
57
|
|
|
]; |
58
|
|
|
$this->assertCVInterface('/../Resources/data/specialCharacters.xml'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function testSimpleHumanFileName() { |
62
|
|
|
$this->curriculumVitae = new CurriculumVitae(__DIR__.self::XML_CORE); |
63
|
|
|
$this->assertSame('core', $this->curriculumVitae->getHumanFileName()); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function testHumanFileNameWithExperience() { |
67
|
|
|
$this->curriculumVitae = new CurriculumVitae(__DIR__.'/../../Resources/data/example.xml'); |
68
|
|
|
$this->assertSame('First Name Last Name - Curriculum Vitae Title', |
69
|
|
|
$this->curriculumVitae->getHumanFileName() |
70
|
|
|
); |
71
|
|
|
|
72
|
|
|
$this->curriculumVitae = new CurriculumVitae(__DIR__.'/../Resources/data/backbone.xml'); |
73
|
|
|
$this->assertSame('First Name Last Name - The job', |
74
|
|
|
$this->curriculumVitae->getHumanFileName() |
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function testHumanFileNameWithJob() { |
79
|
|
|
$this->curriculumVitae = new CurriculumVitae(__DIR__.'/../Resources/data/backbone.xml'); |
80
|
|
|
$this->assertSame('First Name Last Name - The job', $this->curriculumVitae->getHumanFileName()); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function testHumanFileNameWithOnLyName(){ |
84
|
|
|
$this->curriculumVitae = new CurriculumVitae(__DIR__.'/../Resources/data/justIdentityMySelf.xml'); |
85
|
|
|
$this->assertSame('First Name Last Name', $this->curriculumVitae->getHumanFileName()); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function testNullReturnWithNoDeclarationInCurriculumVitaeTag() { |
89
|
|
|
$this->curriculumVitae = new CurriculumVitae(__DIR__.self::XML_CORE); |
90
|
|
|
$this->assertNull($this->curriculumVitae->getIdentity()); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
private function assertCVInterface($pathToFile = '/../../Resources/data/example.xml') { |
94
|
|
|
$this->curriculumVitae = new CurriculumVitae(__DIR__.$pathToFile, $this->lang); |
95
|
|
|
$this->assertEquals($this->arrayToCompare, $this->curriculumVitae->{$this->interface}()); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|