MediaWiki  REL1_31
Go to the documentation of this file.
1 <?php
8 class ExtensionsTestSuite extends PHPUnit_Framework_TestSuite {
9  public function __construct() {
10  parent::__construct();
12  $paths = [];
13  // Autodiscover extension unit tests
14  $registry = ExtensionRegistry::getInstance();
15  foreach ( $registry->getAllThings() as $info ) {
16  $paths[] = dirname( $info['path'] ) . '/tests/phpunit';
17  }
18  // Extensions can return a list of files or directories
19  Hooks::run( 'UnitTestsList', [ &$paths ] );
20  foreach ( array_unique( $paths ) as $path ) {
21  if ( is_dir( $path ) ) {
22  // If the path is a directory, search for test cases.
23  // @since 1.24
24  $suffixes = [ 'Test.php' ];
25  $fileIterator = new File_Iterator_Facade();
26  $matchingFiles = $fileIterator->getFilesAsArray( $path, $suffixes );
27  $this->addTestFiles( $matchingFiles );
28  } elseif ( file_exists( $path ) ) {
29  // Add a single test case or suite class
30  $this->addTestFile( $path );
31  }
32  }
33  if ( !$paths ) {
34  $this->addTest( new DummyExtensionsTest( 'testNothing' ) );
35  }
36  }
38  public static function suite() {
39  return new self;
40  }
41 }
48  public function testNothing() {
49  $this->assertTrue( true );
50  }
51 }
Definition: ExtensionsTestSuite.php:48
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:37
static getInstance()
Definition: ExtensionRegistry.php:88
Definition: ExtensionsTestSuite.php:9
static suite()
Definition: ExtensionsTestSuite.php:38
Definition: MediaWikiTestCase.php:17
Needed to avoid warnings like 'No tests found in class "ExtensionsTestSuite".
Definition: ExtensionsTestSuite.php:47
Definition: NoLocalSettings.php:25
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:22
This test suite runs unit tests registered by extensions.
Definition: ExtensionsTestSuite.php:8
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203