Passed
Push — master ( b5507b...28d9c0 )
by Dispositif
02:37
created

OuvrageTemplateTest::testDoublonAlias()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
/**
3
 * This file is part of dispositif/wikibot application
4
 * 2019 : Philippe M. <[email protected]>
5
 * For the full copyright and MIT license information, please view the LICENSE file.
6
 */
7
8
declare(strict_types=1);
9
10
namespace App\Domain\Models\Wiki\Tests;
11
12
use App\Domain\Models\Wiki\OuvrageTemplate;
13
use PHPUnit\Framework\TestCase;
14
15
class OuvrageTemplateTest extends TestCase
16
{
17
    public function testDoublonAlias()
18
    {
19
        $ouvrage = new OuvrageTemplate();
20
        $ouvrage->hydrateFromText(
21
            "{{Ouvrage |titre=bla |volume=5 |vol=3}}"
22
        );
23
        $this::assertSame(
24
            "{{Ouvrage |titre=bla |volume=5 |éditeur= |année= |isbn= |volume-doublon=3 <!--PARAMETRE 'volume-doublon' N'EXISTE PAS -->}}",
25
            $ouvrage->serialize(true)
26
        );
27
    }
28
29
    /**
30
     * @dataProvider provideSpanInitial
31
     */
32
    public function testSpanInitial(array $data, ?string $expected)
33
    {
34
        $ouvrage = new OuvrageTemplate();
35
        $ouvrage->hydrate($data);
36
37
        $this::assertSame(
38
            $expected,
39
            $ouvrage->getSpanInitial()
40
        );
41
    }
42
43
    public function provideSpanInitial()
44
    {
45
        return [
46
            [
47
                ['id' => 'Bla'],
48
                'Bla',
49
            ],
50
            [
51
                ['auteur' => 'Dupont', 'année' => '1989'],
52
                'Dupont1989',
53
            ],
54
            [
55
                ['auteur1' => 'Dupont', 'auteur2' => 'Durand', 'année' => '1989'],
56
                'DupontDurand1989',
57
            ],
58
        ];
59
    }
60
}
61