Passed
Push — dev ( 043eb4...bf3609 )
by Dispositif
06:23
created

WebMapperTest::testLiberationMapper()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 15
nc 1
nop 0
dl 0
loc 22
rs 9.7666
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Domain\Publisher\Tests;
6
7
use App\Application\PublisherAction;
8
use App\Domain\Publisher\FigaroMapper;
9
use App\Domain\Publisher\LeMondeMapper;
10
use App\Domain\Publisher\LiberationMapper;
11
use PHPUnit\Framework\TestCase;
12
13
include __DIR__.'/../../../Application/myBootstrap.php';
14
15
class WebMapperTest extends TestCase
16
{
17
    public function testFigaroMapper()
18
    {
19
        $html = file_get_contents(__DIR__.'/fixture_news_figaro.html');
20
21
        $publiAction = new PublisherAction('bla');
22
        $htmlData = $publiAction->extractWebData($html);
23
24
        $mapper = new FigaroMapper();
25
        $actual = $mapper->process($htmlData);
26
27
        $this::assertSame(
28
            [
29
                'périodique' => '[[Le Figaro]]',
30
                'titre' => 'Face au Covid-19, les cliniques privées mobilisées… mais en manque de masques',
31
                'lire en ligne' => 'http://www.lefigaro.fr/sciences/face-au-covid-19-les-cliniques-privees-mobilisees-mais-en-manque-de-masques-20200318',
32
                'date' => '18-03-2020',
33
                'auteur1' => 'Marie-Cécile Renault',
34
                'auteur2' => null,
35
                'auteur3' => null,
36
                'auteur institutionnel' => null,
37
            ],
38
            $actual
39
        );
40
    }
41
42
    public function testLeMondeMapper()
43
    {
44
        $html = file_get_contents(__DIR__.'/fixture_news_lemonde.html');
45
46
        $publiAction = new PublisherAction('bla');
47
        $htmlData = $publiAction->extractWebData($html);
48
49
        $mapper = new LeMondeMapper();
50
        $actual = $mapper->process($htmlData);
51
52
        $this::assertSame(
53
            [
54
                'périodique' => '[[Le Monde]]',
55
                'titre' => 'Coronavirus : la Californie placée à son tour en confinement',
56
                'lire en ligne' => 'https://www.lemonde.fr/planete/article/2020/03/20/coronavirus-la-californie-placee-en-confinement_6033754_3244.html',
57
                'auteur1' => 'Le Monde avec AFP',
58
                'date' => '20-03-2020',
59
            ],
60
            $actual
61
        );
62
    }
63
64
    public function testLiberationMapper()
65
    {
66
        $html = file_get_contents(__DIR__.'/fixture_news_liberation.html');
67
68
        $publiAction = new PublisherAction('bla');
69
        $htmlData = $publiAction->extractWebData($html);
70
71
        $mapper = new LiberationMapper();
72
        $actual = $mapper->process($htmlData);
73
74
        $this::assertSame(
75
            [
76
                'périodique' => '[[Libération (journal)|Libération]]',
77
                'titre' => 'En Bretagne, le Parisiens-bashing guette',
78
                'lire en ligne' => 'https://www.liberation.fr/france/2020/03/20/en-bretagne-le-parisiens-bashing-guette_1782471',
79
                'date' => '20-03-2020',
80
                'auteur1' => 'Pierre-Henri Allain',
81
                'auteur2' => null,
82
                'auteur3' => null,
83
                'auteur institutionnel' => null,
84
            ],
85
            $actual
86
        );
87
    }
88
}
89