Passed
Push — master ( d0e7a6...44374d )
by Dispositif
02:28
created

Wikidata2OuvrageTest::testIntegrationComplete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 16
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 28
rs 9.7333
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Domain\Publisher\Tests;
6
7
use App\Domain\Models\Wiki\OuvrageTemplate;
8
use App\Domain\OuvrageOptimize;
9
use App\Domain\Publisher\Wikidata2Ouvrage;
10
use PHPUnit\Framework\TestCase;
11
12
include __DIR__.'/../../../Application/myBootstrap.php';
13
14
class Wikidata2OuvrageTest extends TestCase
15
{
16
    /**
17
     * @throws \Exception
18
     */
19
    public function testIntegrationComplete()
20
    {
21
        $this::markTestSkipped("test d'integration avec requete WIKIDATA");
22
        // besoin bootstrap user-agent pour requete ?
23
24
        $ouvrage = new OuvrageTemplate();
25
        $ouvrage->hydrateFromText('{{Ouvrage|auteur=Bob|titre=Ma vie|passage=407-408}}');
26
        // Houellebecq : La carte et le Territoire
27
        $ouvrage->setInfos(
28
            [
29
                'isbn' => '978-2-08-124633-1',
30
                'ISNIAuteur1' => '0000 0001 2137 320X',
31
            ]
32
        );
33
34
        $convert = new Wikidata2Ouvrage($ouvrage);
35
        $wdOuvrage = $convert->getOuvrage();
36
        $this::assertSame(
37
            '{{Ouvrage|auteur1=Bob|lien auteur1=Michel Houellebecq|titre=Ma vie|lien titre=La Carte et le Territoire|éditeur=|année=|passage=407-408|isbn=}}',
38
            $wdOuvrage->serialize(true)
39
        );
40
41
        // Après optimization
42
        $optimizer = new OuvrageOptimize($wdOuvrage, 'Bla');
43
        $optimizer->doTasks();
44
        $this::assertSame(
45
            '{{Ouvrage|auteur1=Bob|lien auteur1=Michel Houellebecq|titre=Ma vie|lien titre=La Carte et le Territoire|éditeur=|année=|passage=407-408|isbn=}}',
46
            $optimizer->getOuvrage()->serialize(true)
47
        );
48
49
    }
50
}
51