Passed
Push — master ( cbc9cf...fb61b0 )
by Dispositif
03:00
created

BnfMapperTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 31
c 3
b 0
f 0
dl 0
loc 47
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testProcessIsbnRectifie() 0 12 1
A testProcess() 0 29 1
1
<?php
2
declare(strict_types=1);
3
4
namespace App\Domain\Publisher\Tests;
5
6
use App\Domain\Publisher\BnfMapper;
7
use PHPUnit\Framework\TestCase;
8
use SimpleXMLElement;
9
10
class BnfMapperTest extends TestCase
11
{
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
                'bnf' => '35049657',
25
                'isbn' => '2-85319-209-1',
26
                'isbn2' => '2-33333-209-1',
27
                'langue' => 'fr',
28
                'langue originale' => 'it',
29
                'langue titre' => null,
30
                'titre' => 'Dictionnaire des chanteurs francophones',
31
                'sous-titre' => 'de 1900 à nos jours, 900 biographies d\'interprètes, 6000 titres de chansons',
32
                'auteur1' => 'Alain-Pierre Noyer',
33
                'auteur2' => 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
            ],
41
            $actual
42
        );
43
    }
44
45
    public function testProcessIsbnRectifie()
46
    {
47
        $text = file_get_contents(__DIR__.'/bnf_multi_isbn_rectifie.xml');
48
49
        $xml = new SimpleXMLElement($text);
50
        $xml->registerXPathNamespace('mxc', "info:lc/xmlns/marcxchange-v2");
51
52
        $mapper = new BnfMapper();
53
        $actual = $mapper->process($xml);
54
        $this::assertSame(
55
            [],
56
            $actual
57
        );
58
    }
59
}
60