MediaWiki REL1_31
ClassCollectorTest.php
Go to the documentation of this file.
1<?php
2
6class ClassCollectorTest extends PHPUnit\Framework\TestCase {
7
8 use MediaWikiCoversValidator;
9
10 public static function provideCases() {
11 return [
12 [
13 "class Foo {}",
14 [ 'Foo' ],
15 ],
16 [
17 "namespace Example;\nclass Foo {}\nclass Bar {}",
18 [ 'Example\Foo', 'Example\Bar' ],
19 ],
20 [
21 "class_alias( 'Foo', 'Bar' );",
22 [ 'Bar' ],
23 ],
24 [
25 "namespace Example;\nclass Foo {}\nclass_alias( 'Example\Foo', 'Foo' );",
26 [ 'Example\Foo', 'Foo' ],
27 ],
28 [
29 "namespace Example;\nclass Foo {}\nclass_alias( 'Example\Foo', 'Bar' );",
30 [ 'Example\Foo', 'Bar' ],
31 ],
32 [
33 "class_alias( Foo::class, 'Bar' );",
34 [ 'Bar' ],
35 ],
36 [
37 // Namespaced class is not currently supported. Must use namespace declaration
38 // earlier in the file.
39 "class_alias( Example\Foo::class, 'Bar' );",
40 [],
41 ],
42 [
43 "namespace Example;\nclass Foo {}\nclass_alias( Foo::class, 'Bar' );",
44 [ 'Example\Foo', 'Bar' ],
45 ],
46 ];
47 }
48
52 public function testGetClasses( $code, array $classes, $message = null ) {
53 $cc = new ClassCollector();
54 $this->assertEquals( $classes, $cc->getClasses( "<?php\n$code" ), $message );
55 }
56}
Reads PHP code and returns the FQCN of every class defined within it.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
Definition hooks.txt:865