Files
23cm/vendor/omnilight/yii2-scheduling/tests/EventTest.php
2026-01-25 18:18:09 +08:00

35 lines
1.0 KiB
PHP

<?php
namespace omnilight\scheduling\Tests;
use omnilight\scheduling\Event;
use yii\mutex\Mutex;
class EventTest extends \PHPUnit_Framework_TestCase
{
public function buildCommandData()
{
return [
[false, 'php -i', '/dev/null', 'php -i > /dev/null'],
[false, 'php -i', '/my folder/foo.log', 'php -i > /my folder/foo.log'],
[true, 'php -i', '/dev/null', 'php -i > /dev/null 2>&1 &'],
[true, 'php -i', '/my folder/foo.log', 'php -i > /my folder/foo.log 2>&1 &'],
];
}
/**
* @dataProvider buildCommandData
* @param bool $omitErrors
* @param string $command
* @param string $outputTo
* @param string $result
*/
public function testBuildCommandSendOutputTo($omitErrors, $command, $outputTo, $result)
{
$event = new Event($this->getMock(Mutex::className()), $command);
$event->omitErrors($omitErrors);
$event->sendOutputTo($outputTo);
$this->assertSame($result, $event->buildCommand());
}
}