本文整理汇总了PHP中Command::removeOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::removeOption方法的具体用法?PHP Command::removeOption怎么用?PHP Command::removeOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Command
的用法示例。
在下文中一共展示了Command::removeOption方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCommandClass
public function testCommandClass()
{
$commandLine = "echo \"Hello world!\"";
$c = new Command($commandLine);
$this->assertEquals($commandLine, $c);
$stdOut = "./stdout.log";
$c->setStdOut($stdOut);
$this->assertEquals($stdOut, $c->getStdOut(), "stdout setter and getter are ok.");
$stdErr = "./stderr.log";
$c->setStdErr($stdErr);
$this->assertEquals($stdErr, $c->getStdErr(), "stderr setter and getter are ok.");
$c = new Command($commandLine);
$c->runInBackground();
if (substr(php_uname(), 0, 7) == "Windows") {
$stdOutNul = ">NUL";
$stdErrNul = "2>NUL";
} else {
$stdOutNul = "/dev/null";
$stdErrNul = "2>/dev/null";
}
$this->assertEquals($stdOutNul, $c->getStdOut(), "If stdout is not set set it to {$stdOutNul} when running in background.");
$this->assertEquals($stdErrNul, $c->getStdErr(), "If stderr is not set set it to {$stdErrNul} when running in background.");
$c = new Command($commandLine);
$c->setStdErr($stdErr);
$c->setStdOut($stdOut);
$c->runInBackground();
$this->assertEquals($stdOut, $c->getStdOut(), "If stdout is set don't overwrite it when running in background.");
$this->assertEquals($stdErr, $c->getStdErr(), "If stderr is set don't overwrite it when running in background.");
$arg1 = "arg1";
$arg2 = "arg2";
$arg3 = "arg3";
$c->addArgument($arg1);
$c->addArgument($arg3);
$expectedLine = "{$commandLine} {$arg1} {$arg3}";
$this->assertEquals($expectedLine, (string) $c, "Command properly appends arguments.");
$c->addArgument($arg2, 2);
$expectedLine = "{$commandLine} {$arg1} {$arg2} {$arg3}";
$this->assertEquals($expectedLine, (string) $c, "Command properly insertets arguments at given position.");
$arg2_1 = "arg2_1";
$c->addArgument($arg2_1, 2, true);
$expectedLine = "{$commandLine} {$arg1} {$arg2_1} {$arg3}";
$this->assertEquals($expectedLine, (string) $c, "Command properly replaces arguments.");
$c = new Command($commandLine);
$c->addArgument($arg3, 3);
$c->addArgument($arg1, 1);
$c->addArgument($arg2, 2);
$expectedLine = "{$commandLine} {$arg1} {$arg2} {$arg3}";
$this->assertEquals($expectedLine, (string) $c, "Command properly insertets arguments added in mixed order.");
$c = new Command($commandLine);
$c->addOption("-c");
$expectedLine = "{$commandLine} -c";
$this->assertEquals($expectedLine, (string) $c, "Command properly appends no-value option.");
$c->removeOption("-c");
$this->assertEquals($commandLine, (string) $c, "Command properly removesg options.");
$c->addOption("-c:", "value_c");
$expectedLine = "{$commandLine} -c \"value_c\"";
$this->assertEquals($expectedLine, (string) $c, "Commadn properly appends options with required value.");
$c = new Command($commandLine);
$c->addOption("-c::");
$expectedLine = "{$commandLine} -c";
$this->assertEquals($expectedLine, (string) $c, "Command properly appends optional value option without value set.");
$c = new Command($commandLine);
$c->addOption("-c::", "value_c");
$expectedLine = "{$commandLine} -c=\"value_c\"";
$this->assertEquals($expectedLine, (string) $c, "Command properly appends optional value option.");
$c = new Command($commandLine);
$c->addOption("-c", "value_c");
$expectedLine = "{$commandLine} -c";
$this->assertEquals($expectedLine, (string) $c, "Command properly appends no-value option without value even if value is set.");
$c = new Command($commandLine);
$c->addOption("-a");
$c->addOption("-b");
$expectedLine = "{$commandLine} -a -b";
$this->assertEquals($expectedLine, (string) $c, "Command properly appends multiple options");
}