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

ErrorReportTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 33
c 1
b 0
f 0
dl 0
loc 53
rs 10
wmc 3
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\Application\Tests;
11
12
use App\Application\ErrorReport;
13
use PHPUnit\Framework\TestCase;
14
15
class ErrorReportTest extends TestCase
16
{
17
    public function testGetReport()
18
    {
19
        $text = file_get_contents(__DIR__.'/../resources/fixture_error_report.wiki');
20
        $report = new ErrorReport();
21
        $errors = $report->getReport($text);
22
        $this::assertSame(
23
            [
24
                "|editor=JT Staley, MP Bryant, N Pfennig, and JG Holt, eds. <!--PARAMETRE 'editor' N'EXISTE PAS -->",
25
                "|editor=DR Boone and RW Castenholz, eds. <!--PARAMETRE 'editor' N'EXISTE PAS -->",
26
            ],
27
            $errors
28
        );
29
30
        return $errors;
31
    }
32
33
    /**
34
     * @depends testGetReport
35
     */
36
    public function testCountErrorInText($errors)
37
    {
38
        $article = <<<'EOF'
39
sadfzd |editor=JT Staley, MP Bryant, N Pfennig, and JG Holt, eds. <!--PARAMETRE 'editor' N'EXISTE PAS -->
40
qsfqsf |editor=DR Boone and RW Castenholz, eds. <!--PARAMETRE 'editor' N'EXISTE PAS --> sqdf bla
41
EOF;
42
        $report = new ErrorReport();
43
        $this::assertSame(
44
            2,
45
            $report->countErrorInText($errors, $article)
46
        );
47
    }
48
49
    public function testDeleteAllReports()
50
    {
51
        $botName = 'CodexBot';
52
        $text = file_get_contents(__DIR__.'/../resources/fixture_error_report.wiki');
53
        $report = new ErrorReport();
54
        $this::assertSame(
55
            '{{À faire}}
56
57
== Bla ==
58
Erat autem diritatis eius hoc quoque indicium nec obscurum nec latens, quod ludicris cruentis delectabatur et in circo sex vel septem aliquotiens vetitis certaminibus pugilum vicissim se concidentium perfusorumque sanguine specie ut lucratus ingentia laetabatur.
59
60
[[Utilisateur:ZiziBot|ZiziBot]]
61
62
== Blabla ==
63
64
Erat autem diritatis eius hoc quoque indicium nec obscurum nec latens, quod ludicris
65
cruentis delectabatur et in circo sex vel septem aliquotiens vetitis certaminibus pugilum vicissim se concidentium perfusorumque sanguine specie ut lucratus ingentia laetabatur.
66
',
67
            $report->deleteAllReports($text, $botName)
68
        );
69
    }
70
}
71