MediaWiki  1.30.0
StructureTest.php
Go to the documentation of this file.
1 <?php
14  if ( wfIsWindows() ) {
15  $this->markTestSkipped( 'This test does not work on Windows' );
16  }
17  $rootPath = escapeshellarg( __DIR__ . '/..' );
18  $testClassRegex = implode( '|', [
19  'ApiFormatTestBase',
20  'ApiTestCase',
21  'ApiQueryTestBase',
22  'ApiQueryContinueTestBase',
23  'MediaWikiLangTestCase',
24  'MediaWikiMediaTestCase',
25  'MediaWikiTestCase',
26  'ResourceLoaderTestCase',
27  'PHPUnit_Framework_TestCase',
28  'DumpTestCase',
29  ] );
30  $testClassRegex = "^class .* extends ($testClassRegex)";
31  $finder = "find $rootPath -name '*.php' '!' -name '*Test.php'" .
32  " | xargs grep -El '$testClassRegex|function suite\('";
33 
34  $results = null;
35  $exitCode = null;
36  exec( $finder, $results, $exitCode );
37 
38  $this->assertEquals(
39  0,
40  $exitCode,
41  'Verify find/grep command succeeds.'
42  );
43 
44  $results = array_filter(
45  $results,
46  [ $this, 'filterSuites' ]
47  );
48  $strip = strlen( $rootPath ) - 1;
49  foreach ( $results as $k => $v ) {
50  $results[$k] = substr( $v, $strip );
51  }
52  $this->assertEquals(
53  [],
54  $results,
55  "Unit test file in $rootPath must end with Test."
56  );
57  }
58 
64  public function filterSuites( $filename ) {
65  return strpos( $filename, __DIR__ . '/../suites/' ) !== 0;
66  }
67 }
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
MediaWikiTestCase
Definition: MediaWikiTestCase.php:15
wfIsWindows
wfIsWindows()
Check if the operating system is Windows.
Definition: GlobalFunctions.php:2079
StructureTest
The tests here verify the structure of the code.
Definition: StructureTest.php:7
StructureTest\filterSuites
filterSuites( $filename)
Filter to remove testUnitTestFileNamesEndWithTest false positives.
Definition: StructureTest.php:64
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
StructureTest\testUnitTestFileNamesEndWithTest
testUnitTestFileNamesEndWithTest()
Verify all files that appear to be tests have file names ending in Test.
Definition: StructureTest.php:13