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.
Test Setup Failed
Push — master ( 1f58dd...e46154 )
by
unknown
31:29
created

phpunit/Integration/ArticleAnnotationTest.php (8 issues)

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
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
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
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
35
use PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls;
0 ignored issues
show
The type PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls 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...
36
use ReflectionClass;
37
38
/**
39
 * @group extensions-lingo
40
 * @group extensions-lingo-integration
41
 * @group mediawiki-databaseless
42
 *
43
 * @coversNothing
44
 *
45
 * @ingroup Lingo
46
 * @ingroup Test
47
 * @since 2.0.1
48
 * @author Stephan Gambke
49
 */
50
class ArticleAnnotationTest extends TestCase {
51
52
	public function setup() {
53
		$GLOBALS[ 'wgexLingoDisplayOnce' ] = false;
54
	}
55
56
	public function tearDown() {
57
		// reset LingoParser singleton
58
		$lingoParser = LingoParser::getInstance();
59
		$reflection = new ReflectionClass( $lingoParser );
60
		$instance = $reflection->getProperty( 'parserSingleton' );
61
		$instance->setAccessible( true );
62
		$instance->setValue( null, null );
63
		$instance->setAccessible( false );
64
	}
65
66
	/**
67
	 * @dataProvider provideData
68
	 * @param $text
69
	 * @param $glossaryEntries
70
	 * @param $expected
71
	 *
72
	 * Tests fail when run via MediaWiki extensions testsuite T196456
73
	 * @group Broken
74
	 */
75
	public function testArticleAnnotation( $file = null, $text = '', $glossaryEntries = null, $expected = '' ) {
76
		$parser = new Parser();
77
		$parser->parse( $text, \Title::newFromText( 'Foo' ), new ParserOptions() );
0 ignored issues
show
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...
78
79
		$backend = $this->getMockForAbstractClass( '\Lingo\Backend' );
80
		$backend->expects( $this->any() )
81
			->method( 'next' )
82
			->will( new PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls( $glossaryEntries ) );
83
84
		$lingoParser = LingoParser::getInstance();
85
		$lingoParser->setBackend( $backend );
86
87
		$lingoParser->parse( $parser );
88
89
		$this->assertEquals( trim( $expected ), trim( $parser->getOutput()->getText() ) );
90
	}
91
92
	public function provideData() {
93
		$data = [];
94
95
		$xmlFileProvider = new XmlFileProvider( __DIR__ . '/../Fixture/articleAnnotation' );
96
		$files = $xmlFileProvider->getFiles();
97
98
		foreach ( $files as $file ) {
99
100
			$xml = simplexml_load_file( $file, "SimpleXMLElement", LIBXML_NOCDATA );
0 ignored issues
show
Coding Style Comprehensibility introduced by
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...
101
			$json = json_encode( $xml );
102
			$decoded = json_decode( $json, true );
103
104
			// suppress warnings for non-existant array keys
105
			\Wikimedia\suppressWarnings();
0 ignored issues
show
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

105
			/** @scrutinizer ignore-call */ 
106
   \Wikimedia\suppressWarnings();
Loading history...
106
107
			$testCase = [
108
				0 => substr( $file, strlen( __DIR__ . '/../Fixture/articleAnnotation' ) ),
109
				1 => trim( $decoded[ 'text' ] ),
110
				2 => [],
111
				3 => trim( $decoded[ 'expected' ] ) . "\n",
112
			];
113
114
			if ( array_key_exists( 'term', $decoded[ 'glossary-entry' ] ) ) {
115
				$decoded[ 'glossary-entry' ] = [ $decoded[ 'glossary-entry' ] ];
116
			}
117
118
			foreach ( $decoded[ 'glossary-entry' ] as $entry ) {
119
				$testCase[ 2 ][] = [ $entry[ 'term' ], $entry[ 'definition' ], $entry[ 'link' ], $entry[ 'style' ] ];
120
			}
121
122
			\Wikimedia\restoreWarnings();
0 ignored issues
show
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

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