Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / maintenance / FindClassesTest.php
blob7964a95e92f4d85f84811042ebe8d499cd52889d
1 <?php
3 namespace MediaWiki\Tests\Maintenance;
5 use FindClasses;
6 use PHPUnit\Framework\ExpectationFailedException;
8 /**
9 * Mock for the input/output of FindClasses
11 * FindClasses internally tries to access stdin and stdout. We mock those aspects
12 * for testing.
14 class SemiMockedFindClasses extends FindClasses {
16 /**
17 * @var string|null Text to pass as stdin
19 private ?string $mockStdinText = null;
21 /**
22 * Data for the fake stdin
24 * @param string $stdin The string to be used instead of stdin
26 public function mockStdin( $stdin ) {
27 $this->mockStdinText = $stdin;
30 public function getStdin( $len = null ) {
31 if ( $len !== null ) {
32 throw new ExpectationFailedException( "Tried to get stdin with non null parameter" );
35 return fopen( 'data://text/plain,' . $this->mockStdinText, 'r' );
39 /**
40 * @covers \FindClasses
41 * @group Database
42 * @author Dreamy Jazz
44 class FindClassesTest extends MaintenanceBaseTestCase {
46 protected function getMaintenanceClass() {
47 return SemiMockedFindClasses::class;
50 public function testExecute() {
51 $this->maintenance->mockStdin( "MediaWiki\Maintenance\Version\n" );
52 $this->maintenance->execute();
53 $this->expectOutputString( MW_INSTALL_PATH . "/maintenance/Version.php\n" );