pharext\CliArgsTest::testOptArg PHP Method

testOptArg() public method

public testOptArg ( )
    public function testOptArg()
    {
        $this->assertFalse(isset($this->args->sudo));
        $this->assertSame("sudo -S %s", $this->args->sudo);
        foreach ($this->args->parse(1, ["--sudo"]) as $error) {
            throw new \Exception("Unexpected parse error: {$error}");
        }
        $this->assertSame("sudo -S %s", $this->args->sudo);
        $this->assertNull($this->args->quiet);
        foreach ($this->args->parse(2, ["--sudo", "--quiet"]) as $error) {
            throw new \Exception("Unexpected parse error: {$error}");
        }
        $this->assertSame("sudo -S %s", $this->args->sudo);
        $this->assertTrue($this->args->quiet);
        foreach ($this->args->parse(3, ["--sudo", "su -c '%s'", "--quiet"]) as $error) {
            throw new \Exception("Unexpected parse error: {$error}");
        }
        $this->assertSame("su -c '%s'", $this->args->sudo);
    }