Passed
Push — LessIssues ( b0696b...ec8676 )
by Fabien
03:01
created

testGetIdentityWithFrenchLanguage()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 30
rs 8.8571
cc 1
eloc 23
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 CurriculumVitaeGetterTest extends \PHPUnit_Framework_TestCase
17
{
18
    private $curriculumVitae;
19
    private $lang;
20
    private $interface;
21
    private $arrayToCompare;
22
23
    public function __construct() {
24
        $this->lang = 'en';
25
    }
26
27
    public function testGetLookingForAndExperiencesAndHumanFileName() {
28
        $this->curriculumVitae = new CurriculumVitae(__DIR__.'/../Resources/data/backbone.xml', $this->lang);
29
30
        $result = array();
31
        $result = array_merge($result, array('lookingFor' => $this->curriculumVitae->getLookingFor()));
32
        $result = array_merge($result, array('experiences' => $this->curriculumVitae->getExperiences()));
33
        $result = array_merge($result, array('pdfFile' => $this->curriculumVitae->getHumanFileName()));
34
35
        $expected = array(
36
            'lookingFor' => array(
37
                'experience'   => array(
38
                    'date' => 'Date',
39
                    'job' => 'The job',
40
                    'society' => array(
41
                        'name' => 'My Company',
42
                        'address' => 'The address of the company',
43
                        'siteurl' => 'http://www.MyCompany.com')),
44
                'presentation' => 'A presentation'),
45
            'experiences' => array(
46
                'LastJob' => array(
47
                    'date' => 'Date',
48
                    'job' => 'The job',
49
                    'society' => array(
50
                        'name' => 'My Company',
51
                        'address' => 'The address of the company',
52
                        'siteurl' => 'http://www.MyCompany.com'))),
53
            'pdfFile' => 'First Name Last Name - The job'
54
        );
55
        $this->assertEquals($expected, $result);
56
    }
57
58
    public function testGetAnchorsWithNoLang() {
59
        $this->curriculumVitae = new CurriculumVitae(__DIR__.'/../Resources/data/backbone.xml');
60
61
        $anchors = $this->curriculumVitae->getAnchors();
62
        if (is_array($anchors)) {
63
            $this->assertEquals(array('identity' => array(
64
                        'href' => 'identity',
65
                        'title' => 'identity'),
66
                      'followMe' => array(
67
                        'href' => 'followMe',
68
                        'title' => 'followMe'),
69
                      'experiences' => array(
70
                        'href' => 'experiences',
71
                        'title' => 'experiences'),
72
                      'skills' => array(
73
                        'href' => 'skills',
74
                        'title' => 'skills'),
75
                      'educations' => array(
76
                        'href' => 'educations',
77
                        'title' => 'educations'),
78
                      'languageSkills' => array(
79
                        'href' => 'languageSkills',
80
                        'title' => 'languageSkills'),
81
                      'miscellaneous' => array(
82
                        'href' => 'miscellaneous',
83
                        'title' => 'miscellaneous')
84
                ),
85
                $anchors
86
            );
87
        }
88
    }
89
90
    public function testGetIdentityWithEnglishLanguage() {
91
        $this->curriculumVitae = new CurriculumVitae(__DIR__.'/../../Resources/data/example.xml');
92
93
        $identity = $this->curriculumVitae->getIdentity();
94
        // We remove the values because of travisci and scrutinizer (depending of date)
95
        unset($identity['myself']['birthday']);
96
        unset($identity['myself']['age']);
97
        $this->assertEquals(array(
98
            'myself' => array(
99
                'name' => 'First Name Last Name',
100
                'nationality' => 'French Citizenship',
101
                'picture' => 'bundles/fabiencrassatcurriculumvitae/img/example.png'
102
            ),
103
            'address' => array(
104
                'street' => 'Street',
105
                'postalcode' => 'PostalCode',
106
                'city' => 'City',
107
                'country' => 'Country',
108
                'googlemap' => 'http://maps.google.com'
109
            ),
110
            'contact' => array(
111
                'mobile' => 'Telephone',
112
                'email' => 'email_arobase_site_dot_com'
113
            ),
114
            'social' => array(
115
                'drivelicences' => 'French driving licence'
116
            )
117
        ), $identity);
118
    }
119
120
    public function testGetIdentityWithFrenchLanguage() {
121
        $this->curriculumVitae = new CurriculumVitae(__DIR__.'/../../Resources/data/example.xml', 'fr');
122
123
        $identity = $this->curriculumVitae->getIdentity();
124
        // We remove the format birthday because of travisci and scrutinizer
125
        unset($identity['myself']['birthday']);
126
        $this->assertEquals(array(
127
            'myself' => array(
128
                'name' => 'First Name Last Name',
129
                'birthplace' => 'Paris',
130
                'picture' => 'bundles/fabiencrassatcurriculumvitae/img/example.png'
131
            ),
132
            'address' => array(
133
                'street' => 'Street',
134
                'postalcode' => 'PostalCode',
135
                'city' => 'City',
136
                'country' => 'Country',
137
                'googlemap' => 'http://maps.google.com'
138
            ),
139
            'contact' => array(
140
                'mobile' => 'Telephone',
141
                'email' => 'email_arobase_site_dot_com'
142
            ),
143
            'social' => array(
144
                'marital' => 'Célibataire',
145
                'military' => 'Dégagé des obligations militaires',
146
                'drivelicences' => 'Titulaire du permis B'
147
            )
148
        ), $identity);
149
    }
150
151
    public function testGetDropDownLanguages() {
152
        $this->interface      = 'getDropDownLanguages';
153
        $this->arrayToCompare = array(
154
            'en' => 'English',
155
            'fr' => 'Français',
156
            'es' => 'español'
157
        );
158
159
        $this->assertCVInterface();
160
    }
161
162
    public function testGetFollowMe() {
163
        $this->interface      = 'getFollowMe';
164
        $this->arrayToCompare = array(
165
            'linkedin' => array(
166
                'title' => 'Linked In',
167
                'url'   => 'http://www.linkedin.com',
168
                'icon'  => 'bundles/fabiencrassatcurriculumvitae/img/linkedin.png'
169
            ),
170
            'viadeo' => array(
171
                'title' => 'Viadeo',
172
                'url'   => 'http://www.viadeo.com',
173
                'icon'  => 'bundles/fabiencrassatcurriculumvitae/img/viadeo.png'
174
            ),
175
            'monster' => array(
176
                'title' => 'Monster',
177
                'url'   => 'http://beknown.com',
178
                'icon'  => 'bundles/fabiencrassatcurriculumvitae/img/monster.png'
179
            ),
180
            'twitter' => array(
181
                'title' => 'Twitter',
182
                'url'   => 'https://twitter.com',
183
                'icon'  => 'bundles/fabiencrassatcurriculumvitae/img/twitter.png'
184
            ),
185
            'googleplus' => array(
186
                'title' => 'Google+',
187
                'url'   => 'https://plus.google.com',
188
                'icon'  => 'bundles/fabiencrassatcurriculumvitae/img/googleplus.png'
189
            ),
190
            'facebook' => array(
191
                'title' => 'Facebook',
192
                'url'   => 'https://www.facebook.com',
193
                'icon'  => 'bundles/fabiencrassatcurriculumvitae/img/facebook.png'
194
            ),
195
            'scrum' => array(
196
                'title' => 'Scrum',
197
                'url'   => 'http://www.scrumalliance.org',
198
                'icon'  => 'bundles/fabiencrassatcurriculumvitae/img/scrum-alliance.png'
199
            )
200
        );
201
202
        $this->assertCVInterface();
203
204
        $this->lang = 'fr';
205
        $this->assertCVInterface();
206
    }
207
208
    public function testGetLookingFor() {
209
        $this->interface = 'getLookingFor';
210
211
        $this->arrayToCompare = array(
212
            'experience'   => 'Curriculum Vitae Title',
213
            'presentation' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
214
            .' Aenean eu lectus facilisis, posuere leo laoreet, dignissim ligula. Praesent'
215
            .' ultricies dignissim diam vitae dictum. Donec sed nisi tortor. Proin tempus'
216
            .' scelerisque lectus, sit amet convallis mi semper a. Integer blandit a ligula'
217
            .' a volutpat. Ut dolor eros, interdum quis ante ac, tempus commodo odio. Suspendisse'
218
            .' ut nisi purus. Mauris vestibulum nibh sit amet turpis consequat pharetra. Duis at'
219
            .' adipiscing risus. Vivamus vitae orci ac felis porta euismod. Fusce sit amet metus'
220
            .' sem. Maecenas suscipit tincidunt ante, sed feugiat odio eleifend eu. Sed eu'
221
            .' ultricies ipsum. In cursus tincidunt elit a gravida. Nam eu aliquet leo. Maecenas'
222
            .' nibh leo, eleifend fermentum neque sit amet, viverra consequat lorem.',
223
        );
224
        $this->assertCVInterface();
225
226
        $this->lang           = 'fr';
227
        $this->arrayToCompare = array(
228
            'experience'   => 'Titre du curriculum vitae',
229
            'presentation' => 'Mauris rutrum justo ac bibendum ultrices. Mauris a dolor a diam'
230
            .' tempus ornare vel non urna. Donec a dui vel nunc ultrices porta non vitae felis.'
231
            .' Ut blandit ullamcorper orci. Quisque quis justo vitae nisl auctor laoreet non eget'
232
            .' mauris. Sed volutpat enim est, vitae vulputate nibh laoreet gravida. Duis nec'
233
            .' tincidunt ante. Nullam metus turpis, accumsan nec laoreet et, consectetur et'
234
            .' ligula. Curabitur convallis feugiat lorem, sit amet tincidunt arcu sollicitudin'
235
            .' vel. Aliquam erat volutpat. In odio elit, accumsan in facilisis at, ultricies'
236
            .' quis justo.',
237
        );
238
        $this->assertCVInterface();
239
    }
240
241
    public function testGetExperiences() {
242
        $this->interface = 'getExperiences';
243
244
        $this->arrayToCompare = array(
245
            'FirstExperience' => array(
246
                'date' => 'Jan 2007 - Present',
247
                'job' => 'My current job',
248
                'society' => array(
249
                    'name' => 'My Company',
250
                    'address' => 'the address of the company',
251
                    'siteurl' => 'http://www.MyCompany.com'),
252
                'missions' => array(
253
                    'item' => array(
254
                        0 => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
255
                        1 => 'Suspendisse nec mauris eu orci dapibus mollis ac ac mi.'))),
256
            'SecondExperience' => array(
257
                'collapse' => 'false',
258
                'date' => 'Sept - Dec 2006',
259
                'job' => 'My previous job',
260
                'society' => array(
261
                    'name' => 'My Other Company',
262
                    'address' => 'the address of the company',
263
                    'siteurl' => 'http://www.MyOtherCompany.com')),
264
            'ThirdExperience' => array(
265
                'date' => 'Summer 2006',
266
                'job' => 'A summer job',
267
                'society' => array(
268
                    'name' => 'A company wihtout site',
269
                    'address' => 'the address of the company'),
270
                'missions' => array(
271
                    'item' => array(
272
                        0 => 'Suspendisse et arcu eget est feugiat elementum.'))),
273
            'FourthExperience' => array(
274
                'collapse' => 'true',
275
                'date' => 'Before 2006',
276
                'job' => 'The job of my life',
277
                'society' => 'A society with a name per language',
278
                'missions' => array(
279
                    'item' => array(
280
                        0 => 'Suspendisse et arcu eget est feugiat elementum.')))
281
        );
282
        $this->assertCVInterface();
283
284
        $this->lang           = 'fr';
285
        $this->arrayToCompare = array(
286
            'FirstExperience' => array(
287
                'date' => 'Jan. 2007 - Aujourd\'hui',
288
                'job' => 'Mon poste actuel',
289
                'society' => array(
290
                    'name' => 'My Company',
291
                    'address' => 'the address of the company',
292
                    'siteurl' => 'http://www.MyCompany.com'),
293
                'missions' => array(
294
                    'item' => array(
295
                        0 => 'Donec gravida enim viverra tempor dignissim.',
296
                        1 => 'Sed a eros at mauris placerat adipiscing.'))),
297
            'SecondExperience' => array(
298
                'collapse' => 'false',
299
                'date' => 'Sept - Dec 2006',
300
                'job' => 'Mon poste précédent',
301
                'society' => array(
302
                    'name' => 'Mon autre compagnie',
303
                    'address' => 'l\'adresse de la compagnie',
304
                    'siteurl' => 'http://www.MyOtherCompany.com')),
305
            'ThirdExperience' => array(
306
                'date' => 'Summer 2006',
307
                'job' => 'Un travail d\'été',
308
                'society' => array(
309
                    'name' => 'Une compagnie sans site',
310
                    'address' => 'l\'adresse de la compagnie'),
311
                'missions' => array(
312
                    'item' => array(
313
                        0 => 'Suspendisse et arcu eget est feugiat elementum.'))),
314
            'FourthExperience' => array(
315
                'collapse' => 'true',
316
                'date' => 'Before 2006',
317
                'job' => 'Le job de ma vie',
318
                'society' => 'Une société avec un nom par langue',
319
                'missions' => array(
320
                    'item' => array(
321
                        0 => 'Suspendisse et arcu eget est feugiat elementum.')))
322
        );
323
        $this->assertCVInterface();
324
    }
325
326
    public function testGetSkills() {
327
        $this->interface = 'getSkills';
328
329
        $this->arrayToCompare = array(
330
            'Functional' => array(
331
                'title' => 'Skills',
332
                'lines' => array(
333
                    'success' => array(
334
                        'percentage' => 90,
335
                        'class' => 'success',
336
                        'striped' => 'true',
337
                        'label' => 'Increasing Skills',
338
                    ),
339
                    'otherSucess' => array(
340
                        'percentage' => 90,
341
                        'class' => 'success',
342
                        'label' => 'success',
343
                    ),
344
                    'info' => array(
345
                        'percentage' => 40,
346
                        'class' => 'info',
347
                        'striped' => 'false',
348
                        'label' => 'info',
349
                    ),
350
                    'warning' => array(
351
                        'percentage' => 20,
352
                        'class' => 'warning',
353
                        'label' => 'warning',
354
                    ),
355
                    'danger' => array(
356
                        'percentage' => 10,
357
                        'class' => 'danger',
358
                        'label' => 'danger',
359
                    ),
360
                    'noClass' => array(
361
                        'percentage' => 5,
362
                        'label' => 'noClass',
363
                    ),
364
                    'nothing' => array(
365
                        'label' => 'nothing',
366
                    )
367
                )
368
            ),
369
            'OtherSkill' => array(
370
                'title' => 'One other',
371
                'lines' => array(
372
                    'success' => array(
373
                        'percentage' => 90,
374
                        'class' => 'success',
375
                        'striped' => 'false',
376
                        'label' => 'Skills List',
377
                    ),
378
                    'info' => array(
379
                        'percentage' => 40,
380
                        'class' => 'info',
381
                        'striped' => 'false',
382
                        'label' => 'Label',
383
                    ),
384
                    'warning' => array(
385
                        'percentage' => 20,
386
                        'class' => 'warning',
387
                        'striped' => 'false',
388
                        'label' => 'Label',
389
                    ),
390
                    'danger' => array(
391
                        'percentage' => 10,
392
                        'class' => 'danger',
393
                        'striped' => 'true',
394
                        'label' => 'Label',
395
                    )
396
                )
397
            )
398
        );
399
        $this->assertCVInterface();
400
401
        $this->lang = 'fr';
402
        // Only set the french labels
403
        $arrayToChange                                            = $this->arrayToCompare;
404
        $arrayToChange['Functional']['title']                     = 'Compétences';
405
        $arrayToChange['Functional']['lines']['success']['label'] = 'Compétences grandissantes';
406
        $arrayToChange['OtherSkill']['title']                     = 'Une autre';
407
        $arrayToChange['OtherSkill']['lines']['success']['label'] = 'Liste de Compétences';
408
409
        $this->arrayToCompare = $arrayToChange;
410
        $this->assertCVInterface();
411
    }
412
413
    public function testGetEducations() {
414
        $this->interface = 'getEducations';
415
416
        $this->arrayToCompare = array(
417
            'University' => array(
418
                'date' => '2002 - 2005',
419
                'education' => 'My diploma in my university',
420
                'descriptions' => array('item' => array(
421
                    0 => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc in'
422
                        .' auctor ipsum. Nullam venenatis sem.'
423
                ))
424
            ),
425
            'HighSchool' => array(
426
                'collapse' => 'false',
427
                'date' => 'June 2002',
428
                'education' => 'My diploma in my high school',
429
                'descriptions' => array('item' => array(
430
                    0 => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris elit'
431
                        .' dui, faucibus non laoreet luctus, dignissim at lectus. Quisque dignissim'
432
                        .' imperdiet consectetur. Praesent scelerisque neque.',
433
                    1 => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed pretium'
434
                        .' varius est sit amet consectetur. Suspendisse cursus dapibus egestas.'
435
                        .' Ut id augue quis mi scelerisque.'
436
                ))
437
            ),
438
            'FirstSchool' => array(
439
                'collapse' => 'true',
440
                'date' => 'June 2000',
441
                'education' => 'My diploma in my first school'
442
            )
443
        );
444
        $this->assertCVInterface();
445
446
        $this->lang           = 'fr';
447
        $this->arrayToCompare = array(
448
            'University' => array(
449
                'date' => '2002 - 2005',
450
                'education' => 'Mon diplôme dans mon université',
451
                'descriptions' => array('item' => array(
452
                    0 => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris elit dui,'
453
                        .' faucibus non laoreet luctus, dignissim at lectus. Quisque dignissim'
454
                        .' imperdiet consectetur. Praesent scelerisque neque.',
455
                    1 => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed pretium'
456
                        .' varius est sit amet consectetur. Suspendisse cursus dapibus egestas.'
457
                        .' Ut id augue quis mi scelerisque.'
458
                ))
459
            ),
460
            'HighSchool' => array(
461
                'collapse' => 'false',
462
                'date' => 'Juin 2002',
463
                'education' => 'Mon diplôme dans mon lycée',
464
                'descriptions' => array('item' => array(
465
                    0 => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc in auctor'
466
                        .' ipsum. Nullam venenatis sem.'
467
                ))
468
            ),
469
            'FirstSchool' => array(
470
                'collapse' => 'true',
471
                'date' => 'Juin 2000',
472
                'education' => 'Mon diplôme dans mon collège'
473
            )
474
        );
475
        $this->assertCVInterface();
476
    }
477
478
    public function testGetLanguageSkills() {
479
        $this->interface = 'getLanguageSkills';
480
481
        $this->arrayToCompare = array(
482
            'French' => array(
483
                'title' => 'French',
484
                'description' => 'Level of the skill.',
485
                'icon' => 'bundles/fabiencrassatcurriculumvitae/img/Flag-of-France.png'
486
            ),
487
            'English' => array(
488
                'title' => 'English',
489
                'description' => 'Level of the skill.',
490
                'icon' => 'bundles/fabiencrassatcurriculumvitae/img/Flag-of-United-Kingdom.png'
491
            )
492
        );
493
        $this->assertCVInterface();
494
495
        $this->lang           = 'fr';
496
        $this->arrayToCompare = array(
497
            'French' => array(
498
                'title' => 'Français',
499
                'description' => 'Niveau',
500
                'icon' => 'bundles/fabiencrassatcurriculumvitae/img/Flag-of-France.png'
501
            ),
502
            'English' => array(
503
                'title' => 'Anglais',
504
                'description' => 'Niveau',
505
                'icon' => 'bundles/fabiencrassatcurriculumvitae/img/Flag-of-United-Kingdom.png'
506
            )
507
        );
508
        $this->assertCVInterface();
509
    }
510
511
    public function testGetMiscellaneous() {
512
        $this->interface = 'getMiscellaneous';
513
514
        $this->arrayToCompare = array(
515
            'Practical' => array(
516
                'title' => 'Practices',
517
                'miscellaneous' => 'My practices'
518
            )
519
        );
520
        $this->assertCVInterface();
521
522
        $this->lang           = 'fr';
523
        $this->arrayToCompare = array(
524
            'Practical' => array(
525
                'title' => 'Pratiques',
526
                'miscellaneous' => 'Mes pratiques',
527
                'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
528
                        .' Curabitur nec auctor nisl, eu fringilla nisi. Morbi scelerisque,'
529
                        .' est vitae mattis faucibus, felis sapien lobortis augue.'
530
            )
531
        );
532
        $this->assertCVInterface();
533
    }
534
535
    private function assertCVInterface($pathToFile = '/../../Resources/data/example.xml') {
536
        $this->curriculumVitae = new CurriculumVitae(__DIR__.$pathToFile, $this->lang);
537
        $this->assertEquals($this->arrayToCompare, $this->curriculumVitae->{$this->interface}());
538
    }
539
}
540