Passed
Push — master ( 5c444f...454f16 )
by Fabien
03:16
created

CurriculumVitaeTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
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
    public function setUp() {
24
        $this->lang = 'en';
25
    }
26
27
    public function testNoLanguage() {
28
        $this->interface = 'getDropDownLanguages';
29
30
        $this->arrayToCompare = [$this->lang => $this->lang];
31
32
        $this->assertCVInterface('/../Resources/data/core.xml');
33
    }
34
35
    public function testSpecialCharacters() {
36
        $this->interface = 'getLookingFor';
37
38
        $this->arrayToCompare = [
39
            'experience'   => 'Curriculum Vitae With Special Characters',
40
            'presentation' => 'AZERTY keyboard'
41
            .' Line 1 ²é"(-è_çà)='
42
            .' Line 1 with shift 1234567890°+'
43
            .' Line 1 with Alt Gr ~#{[|`\^@]}'
44
            .' Line 2 azertyuiop^$'
45
            .' Line 2 with shift AZERTYUIOP¨£'
46
            .' Line 2 with Alt Gr €¤'
47
            .' Line 3 qsdfghjklmù*'
48
            .' Line 3 with shift QSDFGHJKLM%µ'
49
            .' Line 3 with Alt Gr '
50
            .' Line 4 wxcvbn,;:!'
51
            .' Line 4 with shift WXCVBN?./§'
52
            .' Line 4 with Alt Gr '
53
            .' Escape Characters < > &'
54
            .' End'
55
        ];
56
        $this->assertCVInterface('/../Resources/data/specialCharacters.xml');
57
    }
58
59
    public function testSimpleHumanFileName() {
60
        $this->curriculumVitae = new CurriculumVitae(__DIR__.'/../Resources/data/core.xml');
61
        $this->assertSame('core', $this->curriculumVitae->getHumanFileName());
62
    }
63
64
    public function testHumanFileNameWithExperience() {
65
        $this->curriculumVitae = new CurriculumVitae(__DIR__.'/../../Resources/data/example.xml');
66
        $this->assertSame('First Name Last Name - Curriculum Vitae Title',
67
            $this->curriculumVitae->getHumanFileName()
68
        );
69
70
        $this->curriculumVitae = new CurriculumVitae(__DIR__.'/../Resources/data/backbone.xml');
71
        $this->assertSame('First Name Last Name - The job',
72
            $this->curriculumVitae->getHumanFileName()
73
        );
74
    }
75
76
    public function testHumanFileNameWithJob() {
77
        $this->curriculumVitae = new CurriculumVitae(__DIR__.'/../Resources/data/backbone.xml');
78
        $this->assertSame('First Name Last Name - The job', $this->curriculumVitae->getHumanFileName());
79
    }
80
81
    public function testHumanFileNameWithOnLyName(){
82
        $this->curriculumVitae = new CurriculumVitae(__DIR__.'/../Resources/data/justIdentityMySelf.xml');
83
        $this->assertSame('First Name Last Name', $this->curriculumVitae->getHumanFileName());
84
    }
85
86
    public function testNullReturnWithNoDeclarationInCurriculumVitaeTag() {
87
        $this->curriculumVitae = new CurriculumVitae(__DIR__.'/../Resources/data/core.xml');
88
        $this->assertNull($this->curriculumVitae->getIdentity());
89
    }
90
91
    private function assertCVInterface($pathToFile = '/../../Resources/data/example.xml') {
92
        $this->curriculumVitae = new CurriculumVitae(__DIR__.$pathToFile, $this->lang);
93
        $this->assertEquals($this->arrayToCompare, $this->curriculumVitae->{$this->interface}());
94
    }
95
}
96