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" ); |
||
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" ); |
||
71 | $mw = isReadablePath( dirname( dirname( $extDirectory ) ) . "/tests/phpunit/phpunit.php" ); |
||
0 ignored issues
–
show
|
|||
72 | |||
73 | echo "php {$mw} -c {$config} " . implode( ' ', addArguments( $GLOBALS['argv'] ) ) . "\n\n"; |
||
74 | |||
75 | passthru( "php {$mw} -c {$config} " . implode( ' ', addArguments( $GLOBALS['argv'] ) ) ); |
||
76 |
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.
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.