Passed
Push — master ( bacc5f...5eccc7 )
by Dispositif
02:22
created

BnfMapperTest::testProcess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 39
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 6
Bugs 0 Features 0
Metric Value
cc 1
eloc 31
nc 1
nop 0
dl 0
loc 39
rs 9.424
c 6
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Domain\Publisher\Tests;
6
7
use App\Domain\Publisher\BnfMapper;
8
use PHPUnit\Framework\TestCase;
9
use SimpleXMLElement;
10
11
class BnfMapperTest extends TestCase
12
{
13
    public function testProcess()
14
    {
15
        $text = file_get_contents(__DIR__.'/fixture_bnf.xml');
16
17
        $xml = new SimpleXMLElement($text);
18
        $xml->registerXPathNamespace('mxc', 'info:lc/xmlns/marcxchange-v2');
19
20
        $mapper = new BnfMapper();
21
        $actual = $mapper->process($xml);
22
        $this::assertSame(
23
            [
24
                'langue' => 'fr',
25
                'langue originale' => 'it',
26
                'langue titre' => null,
27
                'titre' => 'Dictionnaire des chanteurs francophones',
28
                'titre original' => null,
29
                'sous-titre' => 'de 1900 à nos jours', //, 900 biographies d\'interprètes, 6000 titres de chansons',
30
                'prénom1' => 'Pierre-Alain',
31
                'nom1' => 'Noyer',
32
                'prénom2' => null,
33
                'nom2' => null,
34
                'volume' => null,
35
                'collection' => null,
36
                'lieu' => 'Paris/Saint-Denis',
37
                'éditeur' => 'Conseil international de la langue française / Université de la Réunion',
38
                'date' => '1996',
39
                'pages totales' => '622',
40
                'isbn2' => '2-33333-209-1',
41
                'isbn' => '2-85319-209-1',
42
                //'bnf' => '35049657',
43
                'infos' => [
44
                    'source' => 'BnF',
45
                    'sourceTag' => 'BnF:2019',
46
                    'bnfAuteur1' => '12136586',
47
                    'ISNIAuteur1' => '0000 0003 6089 3659',
48
                    'yearsAuteur1' => '1948-....',
49
                ],
50
            ],
51
            $actual
52
        );
53
    }
54
55
    public function testProcessIsbnRectifie()
56
    {
57
        $text = file_get_contents(__DIR__.'/bnf_multi_isbn_rectifie.xml');
58
59
        $xml = new SimpleXMLElement($text);
60
        $xml->registerXPathNamespace('mxc', 'info:lc/xmlns/marcxchange-v2');
61
62
        $mapper = new BnfMapper();
63
        $actual = $mapper->process($xml);
64
        $this::assertSame(
65
            [],
66
            $actual
67
        );
68
    }
69
}
70