Debian Codegraph @

extensions/Linter/tests/phpunit/unit/LintErrorTest.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21 namespace MediaWiki\Linter\Test\Unit;
22
23 use MediaWiki\Linter\LintError;
24 use MediaWikiUnitTestCase;
25
26 /**
27 * @covers \MediaWiki\Linter\LintError
28 */
29 class LintErrorTest extends MediaWikiUnitTestCase {
30 public function testLintError() {
31 $error1 = new LintError(
32 'fostered',
33 [ 0, 10 ],
34 []
35 );
36 $this->assertInstanceOf( LintError::class, $error1 );
37 $this->assertEquals( 'fostered', $error1->category );
38 $this->assertEquals( [ 0, 10 ], $error1->location );
39 $this->assertEquals( [], $error1->params );
40 $this->assertNull( $error1->templateInfo );
41 $this->assertEquals( 'fostered,0,10,[]', $error1->id() );
42
43 $error2 = new LintError(
44 'obsolete-tag',
45 [ 10, 20 ],
46 [ 'name' => 'big' ],
47 null,
48 5
49 );
50 $this->assertInstanceOf( LintError::class, $error2 );
51 $this->assertEquals( 'obsolete-tag', $error2->category );
52 $this->assertEquals( [ 10, 20 ], $error2->location );
53 $this->assertEquals( [ 'name' => 'big' ], $error2->params );
54 $this->assertEquals( [ 'name' => 'big' ], $error2->getExtraParams() );
55 $this->assertNull( $error2->templateInfo );
56 $this->assertEquals( 5, $error2->lintId );
57 $this->assertEquals( 'obsolete-tag,10,20,{"name":"big"}', $error2->id() );
58
59 $error3 = new LintError(
60 'obsolete-tag',
61 [ 10, 20 ],
62 '{"name":"big","templateInfo":{"name":"1x"}}'
63 );
64 $this->assertInstanceOf( LintError::class, $error3 );
65 $this->assertEquals( 'obsolete-tag', $error3->category );
66 $this->assertEquals( [ 10, 20 ], $error3->location );
67 $this->assertEquals( [ 'name' => 'big', 'templateInfo' => [ 'name' => '1x' ] ], $error3->params );
68 $this->assertEquals( [ 'name' => '1x' ], $error3->templateInfo );
69 $this->assertEquals( [ 'name' => 'big' ], $error3->getExtraParams() );
70 $this->assertEquals(
71 'obsolete-tag,10,20,{"name":"big","templateInfo":{"name":"1x"}}',
72 $error3->id()
73 );
74 }
75
76 }