| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Tests\Maintenance; |
| 4 |
|
| 5 |
use FindClasses; |
| 6 |
use PHPUnit\Framework\ExpectationFailedException; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
class SemiMockedFindClasses extends FindClasses { |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
private ?string $mockStdinText = null; |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
public function mockStdin( $stdin ) { |
| 27 |
$this->mockStdinText = $stdin; |
| 28 |
} |
| 29 |
|
| 30 |
public function getStdin( $len = null ) { |
| 31 |
if ( $len !== null ) { |
| 32 |
throw new ExpectationFailedException( "Tried to get stdin with non null parameter" ); |
| 33 |
} |
| 34 |
|
| 35 |
return fopen( 'data://text/plain,' . $this->mockStdinText, 'r' ); |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
class FindClassesTest extends MaintenanceBaseTestCase { |
| 45 |
|
| 46 |
protected function getMaintenanceClass() { |
| 47 |
return SemiMockedFindClasses::class; |
| 48 |
} |
| 49 |
|
| 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" ); |
| 54 |
} |
| 55 |
} |