I believe we don't need this any more. A test should never leave an uploaded image behind, but delete it. It should be totally fine when the same trivial test uploads the same image over and over again. All the extra complexity to trick MediaWiki's duplicate detection shouldn't be necessary (any more). Also change the default to svg instead of jpg. Again, this creates much smaller files with much less effort. Note this code was already mostly unused because of the previous patch I7f3d586. Change-Id: I5c16ba7bed0fffa43549b786e50d6d1dd5592ad0
47 lines
958 B
PHP
47 lines
958 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\Api;
|
|
|
|
use Maintenance;
|
|
|
|
/**
|
|
* Bootstrapping for test image file generation
|
|
*
|
|
* @file
|
|
*/
|
|
|
|
// Start up MediaWiki in command-line mode
|
|
require_once __DIR__ . "/../../../../maintenance/Maintenance.php";
|
|
require_once __DIR__ . "/RandomImageGenerator.php";
|
|
|
|
class GenerateRandomImages extends Maintenance {
|
|
|
|
public function getDbType() {
|
|
return Maintenance::DB_NONE;
|
|
}
|
|
|
|
public function execute() {
|
|
$getOptSpec = [
|
|
'minWidth::',
|
|
'maxWidth::',
|
|
'minHeight::',
|
|
'maxHeight::',
|
|
|
|
'number::',
|
|
'format::'
|
|
];
|
|
$options = getopt( '', $getOptSpec );
|
|
|
|
$format = $options['format'] ?? 'svg';
|
|
unset( $options['format'] );
|
|
|
|
$number = (int)( $options['number'] ?? 1 );
|
|
unset( $options['number'] );
|
|
|
|
$randomImageGenerator = new RandomImageGenerator( $options );
|
|
$randomImageGenerator->writeImages( $number, $format );
|
|
}
|
|
}
|
|
|
|
$maintClass = GenerateRandomImages::class;
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|