/** * @dataProvider dataProvider_Aguments */ public function testArguments($expectedAction, $expectedNumber, $args) { array_unshift($args, "svn-number.php"); // First argument is the script itself $svnNumber = new SvnNumber($args, $this->getBashCommandMock()); $this->assertSame($expectedAction, $svnNumber->getAction()); $this->assertSame($expectedNumber, $svnNumber->getRequestedNumbers()); }
$svnNumber = new SvnNumber($argv, $bashCommand); if (false == $svnNumber->hasAction()) { $svnNumber->exec("svn"); // To show help hints exit; } $staging = new Staging(__DIR__ . "/data/staging.txt"); function printStatus(Status $status, $forceOutputAll = false) { if (false === $forceOutputAll && $status->getSvnNumber()->hasRequestedNumbers()) { exit($status->getOutput($status->getSvnNumber()->getRequestedNumbers())); } else { exit($status->getOutput(null)); } } if (in_array($svnNumber->getAction(), array("commit-staged", "stage", "stage-all", "unstage", "unstage-all"))) { switch ($svnNumber->getAction()) { case "commit-staged": $stagedFilePaths = $staging->getStagedFilePaths(); $status = new Status($svnNumber, $staging); $commitingFilePaths = array(); foreach ($status->getLines() as $line) { if (in_array($line->getFilePath(), $stagedFilePaths)) { $commitingFilePaths[] = escapeshellarg($line->getFilePath()); } } $svnNumber->exec(sprintf("svn commit %s %s", implode(" ", $commitingFilePaths), $svnNumber->getAdditionalArgsStr())); $staging->clear()->save(); $status = new Status($svnNumber, $staging); exit(printStatus($status, true)); case "stage":