GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ArticleAnnotationTest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Importance

Changes 8
Bugs 0 Features 0
Metric Value
eloc 38
c 8
b 0
f 0
dl 0
loc 78
rs 10
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A provideData() 0 36 4
A testArticleAnnotation() 0 15 1
A tearDown() 0 8 1
A setUp() 0 2 1
1
<?php
2
/**
3
 * This file is part of the MediaWiki extension Lingo.
4
 *
5
 * @copyright 2011 - 2018, Stephan Gambke
6
 * @license GPL-2.0-or-later
7
 *
8
 * The Lingo extension is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by the Free
10
 * Software Foundation; either version 2 of the License, or (at your option) any
11
 * later version.
12
 *
13
 * The Lingo extension is distributed in the hope that it will be useful, but
14
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16
 * details.
17
 *
18
 * You should have received a copy of the GNU General Public License along
19
 * with this program. If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 * @since 2.0.1
22
 * @file
23
 * @ingroup Lingo
24
 */
25
26
namespace Lingo\Tests\Integration;
27
28
use Lingo\LingoParser;
29
use Lingo\Tests\Util\XmlFileProvider;
30
31
use Parser;
0 ignored issues
show
Bug introduced by Stephan Gambke
The type Parser was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
use ParserOptions;
0 ignored issues
show
Bug introduced by Stephan Gambke
The type ParserOptions was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by Stephan
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
34
use ReflectionClass;
35
36
/**
37
 * @group extensions-lingo
38
 * @group extensions-lingo-integration
39
 * @group mediawiki-databaseless
40
 *
41
 * @coversNothing
42
 *
43
 * @ingroup Lingo
44
 * @ingroup Test
45
 * @since 2.0.1
46
 * @author Stephan Gambke
47
 */
48
class ArticleAnnotationTest extends TestCase {
49
50
	public function setUp() {
51
		$GLOBALS[ 'wgexLingoDisplayOnce' ] = false;
52
	}
53
54
	public function tearDown() {
55
		// reset LingoParser singleton
56
		$lingoParser = LingoParser::getInstance();
57
		$reflection = new ReflectionClass( $lingoParser );
58
		$instance = $reflection->getProperty( 'parserSingleton' );
59
		$instance->setAccessible( true );
60
		$instance->setValue( null, null );
61
		$instance->setAccessible( false );
62
	}
63
64
	/**
65
	 * @dataProvider provideData
66
	 * @param $text
67
	 * @param $glossaryEntries
68
	 * @param $expected
69
	 *
70
	 * Tests fail when run via MediaWiki extensions testsuite T196456
71
	 * @group Broken
72
	 */
73
	public function testArticleAnnotation( $file = null, $text = '', $glossaryEntries = null, $expected = '' ) {
74
		$parser = new Parser();
75
		$parser->parse( $text, \Title::newFromText( 'Foo' ), new ParserOptions() );
0 ignored issues
show
Bug introduced by Stephan
The type Title was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
76
77
		$backend = $this->getMockForAbstractClass( '\Lingo\Backend' );
78
		$backend->expects( $this->any() )
79
			->method( 'next' )
80
			->will( self::onConsecutiveCalls( ...$glossaryEntries ) );
81
82
		$lingoParser = LingoParser::getInstance();
83
		$lingoParser->setBackend( $backend );
84
85
		$lingoParser->parse( $parser );
86
87
		$this->assertEquals( trim( $expected ), trim( $parser->getOutput()->getText() ) );
88
	}
89
90
	public function provideData() {
91
		$data = [];
92
93
		$xmlFileProvider = new XmlFileProvider( __DIR__ . '/../Fixture/articleAnnotation' );
94
		$files = $xmlFileProvider->getFiles();
95
96
		foreach ( $files as $file ) {
97
98
			$xml = simplexml_load_file( $file, "SimpleXMLElement", LIBXML_NOCDATA );
0 ignored issues
show
Coding Style Comprehensibility introduced by Stephan Gambke
The string literal SimpleXMLElement does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
99
			$json = json_encode( $xml );
100
			$decoded = json_decode( $json, true );
101
102
			// suppress warnings for non-existant array keys
103
			\Wikimedia\suppressWarnings();
0 ignored issues
show
Bug introduced by Reedy
The function suppressWarnings was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

103
			/** @scrutinizer ignore-call */ 
104
   \Wikimedia\suppressWarnings();
Loading history...
104
105
			$testCase = [
106
				0 => substr( $file, strlen( __DIR__ . '/../Fixture/articleAnnotation' ) ),
107
				1 => trim( $decoded[ 'text' ] ),
108
				2 => [],
109
				3 => trim( $decoded[ 'expected' ] ) . "\n",
110
			];
111
112
			if ( array_key_exists( 'term', $decoded[ 'glossary-entry' ] ) ) {
113
				$decoded[ 'glossary-entry' ] = [ $decoded[ 'glossary-entry' ] ];
114
			}
115
116
			foreach ( $decoded[ 'glossary-entry' ] as $entry ) {
117
				$testCase[ 2 ][] = [ $entry[ 'term' ], $entry[ 'definition' ], $entry[ 'link' ], $entry[ 'style' ] ];
118
			}
119
120
			\Wikimedia\restoreWarnings();
0 ignored issues
show
Bug introduced by Jayprakash12345
The function restoreWarnings was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

120
			/** @scrutinizer ignore-call */ 
121
   \Wikimedia\restoreWarnings();
Loading history...
121
122
			$data[] = $testCase;
123
		}
124
125
		return $data;
126
	}
127
}
128