1 | <?php |
||
2 | /** |
||
3 | * This file is part of the MediaWiki extension Lingo. |
||
4 | * |
||
5 | * @copyright 2011 - 2016, Stephan Gambke, mwjames |
||
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 | * @author mwjames |
||
23 | * @since 2.0 |
||
24 | * @file |
||
25 | * @ingroup Lingo |
||
26 | */ |
||
27 | |||
28 | /** |
||
29 | * Lazy script to invoke the MediaWiki phpunit runner |
||
30 | * |
||
31 | * php mw-phpunit-runner.php [options] |
||
32 | */ |
||
33 | |||
34 | if ( php_sapi_name() !== 'cli' ) { |
||
35 | die( 'Not an entry point' ); |
||
36 | } |
||
37 | |||
38 | print( "\nMediaWiki phpunit runnner ... \n" ); |
||
39 | |||
40 | function isReadablePath( $path ) { |
||
41 | if ( is_readable( $path ) ) { |
||
42 | return $path; |
||
43 | } |
||
44 | |||
45 | throw new RuntimeException( "Expected an accessible {$path} path" ); |
||
0 ignored issues
–
show
|
|||
46 | } |
||
47 | |||
48 | function addArguments( $args ) { |
||
49 | array_shift( $args ); |
||
50 | return $args; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @return string |
||
55 | */ |
||
56 | function getDirectory() { |
||
57 | $directory = $GLOBALS[ 'argv' ][ 0 ]; |
||
58 | |||
59 | if ( $directory[ 0 ] !== DIRECTORY_SEPARATOR ) { |
||
60 | $directory = $_SERVER[ 'PWD' ] . DIRECTORY_SEPARATOR . $directory; |
||
61 | } |
||
62 | |||
63 | $directory = dirname( $directory ); |
||
64 | |||
65 | return $directory; |
||
66 | } |
||
67 | |||
68 | $extDirectory = dirname( getDirectory() ); |
||
69 | |||
70 | $config = isReadablePath( "$extDirectory/phpunit.xml.dist" ); |
||
0 ignored issues
–
show
As per coding-style, please use concatenation or
sprintf for the variable $extDirectory instead of interpolation.
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings. // Instead of
$x = "foo $bar $baz";
// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
|
|||
71 | $mw = isReadablePath( dirname( dirname( $extDirectory ) ) . "/tests/phpunit/phpunit.php" ); |
||
72 | |||
73 | echo "php {$mw} -c {$config} " . implode( ' ', addArguments( $GLOBALS['argv'] ) ) . "\n\n"; |
||
0 ignored issues
–
show
As per coding-style, please use concatenation or
sprintf for the variable $mw instead of interpolation.
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings. // Instead of
$x = "foo $bar $baz";
// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
As per coding-style, please use concatenation or
sprintf for the variable $config instead of interpolation.
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings. // Instead of
$x = "foo $bar $baz";
// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
|
|||
74 | |||
75 | passthru( "php {$mw} -c {$config} " . implode( ' ', addArguments( $GLOBALS['argv'] ) ) ); |
||
0 ignored issues
–
show
As per coding-style, please use concatenation or
sprintf for the variable $mw instead of interpolation.
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings. // Instead of
$x = "foo $bar $baz";
// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
As per coding-style, please use concatenation or
sprintf for the variable $config instead of interpolation.
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings. // Instead of
$x = "foo $bar $baz";
// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
|
|||
76 |
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.