X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fshell%2FCommandTest.php;h=2e031638857d41a84cacc55d75d20e6ae8c32f27;hp=f7275e14e8c3e0d460f734f01f4ce1f15e9ee8e4;hb=8269ed4dfd5e4395e25945b1fa2ed391684606ed;hpb=5405fd880e914e7d460a9148477688770aeb7d1a diff --git a/tests/phpunit/includes/shell/CommandTest.php b/tests/phpunit/includes/shell/CommandTest.php index f7275e14e8..2e03163885 100644 --- a/tests/phpunit/includes/shell/CommandTest.php +++ b/tests/phpunit/includes/shell/CommandTest.php @@ -4,9 +4,13 @@ use MediaWiki\Shell\Command; use Wikimedia\TestingAccessWrapper; /** + * @covers \MediaWiki\Shell\Command * @group Shell */ -class CommandTest extends PHPUnit_Framework_TestCase { +class CommandTest extends PHPUnit\Framework\TestCase { + + use MediaWikiCoversValidator; + private function requirePosix() { if ( wfIsWindows() ) { $this->markTestSkipped( 'This test requires a POSIX environment.' ); @@ -150,4 +154,28 @@ class CommandTest extends PHPUnit_Framework_TestCase { $this->assertSame( 1, count( $logger->getBuffer() ) ); $this->assertSame( trim( $logger->getBuffer()[0][2]['error'] ), 'ThisIsStderr' ); } + + public function testInput() { + $this->requirePosix(); + + $command = new Command(); + $command->params( 'cat' ); + $command->input( 'abc' ); + $result = $command->execute(); + $this->assertSame( 'abc', $result->getStdout() ); + + // now try it with something that does not fit into a single block + $command = new Command(); + $command->params( 'cat' ); + $command->input( str_repeat( '!', 1000000 ) ); + $result = $command->execute(); + $this->assertSame( 1000000, strlen( $result->getStdout() ) ); + + // And try it with empty input + $command = new Command(); + $command->params( 'cat' ); + $command->input( '' ); + $result = $command->execute(); + $this->assertSame( '', $result->getStdout() ); + } }