Skip to content

Commit

Permalink
Test the one 'getter' method of the CommandlineArgument class (#1154)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenguest authored and mrook committed Oct 8, 2019
1 parent 9fb8703 commit 82b9881
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/classes/phing/types/CommandlineArgumentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
class CommandlineArgumentTest extends \PHPUnit\Framework\TestCase
{
/**
* Test the one 'getter' method of the CommandlineArgument class
*
* @return void
*/
public function testGetParts()
{
$command = "usblamp -s -r 5 red green blue off";
$exploded = explode(" ", "-s -r 5 red green blue off");
$commandline = new Commandline($command);
$arguments = ($commandline->arguments);
foreach ($arguments as $counter => $argument) {
$parts = $argument->getParts();
$this->assertEquals($exploded[$counter], $parts[0]);
$this->assertEquals(false, $argument->escape);
}
}

public function testSetEscape()
{
$command = "usblamp -s -r 5 red green blue off";
$commandline = new Commandline($command);
$argument = new CommandlineArgument($commandline);
$this->assertEquals($argument->escape, false);
$argument->setEscape(true);
$this->assertEquals($argument->escape, true);
}

public function testSetline()
{
$commandline = new Commandline();
$argument = new CommandlineArgument($commandline);
$argument->setLine(null);
$parts = $argument->getParts();
$this->assertEquals($parts, []);
$argument->setLine("perl -pie 's/foo/bar/g' test.txt");
$parts = $argument->getParts();
$this->assertNotEquals($parts, []);

}
}

0 comments on commit 82b9881

Please sign in to comment.