Debian Codegraph @

tests/phpunit/includes/api/generateRandomImages.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Tests\Api;
4
5 use MediaWiki\Maintenance\Maintenance;
6
7 /**
8 * Bootstrapping for test image file generation
9 *
10 * @file
11 */
12
13 // Start up MediaWiki in command-line mode
14 require_once __DIR__ . "/../../../../maintenance/Maintenance.php";
15 require_once __DIR__ . "/RandomImageGenerator.php";
16
17 class GenerateRandomImages extends Maintenance {
18
19 public function getDbType() {
20 return Maintenance::DB_NONE;
21 }
22
23 public function execute() {
24 $getOptSpec = [
25 'minWidth::',
26 'maxWidth::',
27 'minHeight::',
28 'maxHeight::',
29
30 'number::',
31 'format::'
32 ];
33 $options = getopt( '', $getOptSpec );
34
35 $format = $options['format'] ?? 'svg';
36 unset( $options['format'] );
37
38 $number = (int)( $options['number'] ?? 1 );
39 unset( $options['number'] );
40
41 $randomImageGenerator = new RandomImageGenerator( $options );
42 $randomImageGenerator->writeImages( $number, $format );
43 }
44 }
45
46 $maintClass = GenerateRandomImages::class;
47 require_once RUN_MAINTENANCE_IF_MAIN;