1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the MediaWiki extension Lingo. |
4
|
|
|
* |
5
|
|
|
* @copyright 2011 - 2016, 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
|
|
|
* @author Stephan Gambke |
22
|
|
|
* @since 2.0 |
23
|
|
|
* @file |
24
|
|
|
* @ingroup Lingo |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
namespace Lingo\Tests\Unit; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @group extensions-lingo |
31
|
|
|
* @group extensions-lingo-unit |
32
|
|
|
* @group mediawiki-databaseless |
33
|
|
|
* |
34
|
|
|
* @ingroup Lingo |
35
|
|
|
* @ingroup Test |
36
|
|
|
*/ |
37
|
|
|
class LingoI18NTest extends \PHPUnit\Framework\TestCase { |
|
|
|
|
38
|
|
|
|
39
|
|
|
public function testJsonSchemaValidatorExists() { |
40
|
|
|
$this->assertTrue( class_exists( '\JsonSchema\Validator' ) ); |
41
|
|
|
$this->assertTrue( method_exists( '\JsonSchema\Validator', 'check' ) ); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testMagicWordsLoaded() { |
45
|
|
|
// load magic words |
46
|
|
|
require __DIR__ . '/../../../src/Lingo.i18n.magic.php'; |
47
|
|
|
|
48
|
|
|
// assert $magicWords was created |
49
|
|
|
$defined_vars = get_defined_vars(); |
50
|
|
|
$this->assertArrayHasKey( 'magicWords', $defined_vars ); |
51
|
|
|
|
52
|
|
|
// validate structure |
53
|
|
|
|
54
|
|
|
$data = json_decode( json_encode( $defined_vars[ 'magicWords' ] ) ); |
55
|
|
|
|
56
|
|
|
$validator = new \JsonSchema\Validator(); |
57
|
|
|
$validator->check( $data, (object)[ '$ref' => |
58
|
|
|
'file://' . realpath( __DIR__ . '/../Fixture/magicWordsSchema.json' ) ] ); |
59
|
|
|
|
60
|
|
|
// format error message |
61
|
|
|
$errors = implode( '', array_map( |
62
|
|
|
function ( $error ) { |
63
|
|
|
return "* [{$error[ 'property' ]}] {$error[ 'message' ]}\n"; |
|
|
|
|
64
|
|
|
}, |
65
|
|
|
$validator->getErrors() |
66
|
|
|
) ); |
67
|
|
|
|
68
|
|
|
// assert structure is valid |
69
|
|
|
$this->assertTrue( $validator->isValid(), "JSON does not validate. Violations:\n" . $errors ); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths