MediaWiki REL1_31
CommandFactoryTest.php
Go to the documentation of this file.
1<?php
2
6use Psr\Log\NullLogger;
7use Wikimedia\TestingAccessWrapper;
8
12class CommandFactoryTest extends PHPUnit\Framework\TestCase {
13
14 use MediaWikiCoversValidator;
15
19 public function testCreate() {
20 $logger = new NullLogger();
21 $cgroup = '/sys/fs/cgroup/memory/mygroup';
22 $limits = [
23 'filesize' => 1000,
24 'memory' => 1000,
25 'time' => 30,
26 'walltime' => 40,
27 ];
28
29 $factory = new CommandFactory( $limits, $cgroup, false );
30 $factory->setLogger( $logger );
31 $factory->logStderr();
32 $command = $factory->create();
33 $this->assertInstanceOf( Command::class, $command );
34
35 $wrapper = TestingAccessWrapper::newFromObject( $command );
36 $this->assertSame( $logger, $wrapper->logger );
37 $this->assertSame( $cgroup, $wrapper->cgroup );
38 $this->assertSame( $limits, $wrapper->limits );
39 $this->assertTrue( $wrapper->doLogStderr );
40 }
41
45 public function testFirejailCreate() {
46 $factory = new CommandFactory( [], false, 'firejail' );
47 $factory->setLogger( new NullLogger() );
48 $this->assertInstanceOf( FirejailCommand::class, $factory->create() );
49 }
50}
$command
Definition cdb.php:65
testCreate()
MediaWiki\Shell\CommandFactory::create.
testFirejailCreate()
MediaWiki\Shell\CommandFactory::create.
Factory facilitating dependency injection for Command.
Class used for executing shell commands.
Definition Command.php:35
Restricts execution of shell commands using firejail.