Ejemplo n.º 1
0
 public function testThatOutputIsRetrievableForASingleFile()
 {
     $returnValue = array("Index: my/little/file.txt", "===================================================================", "--- my/little/file.txt\t(revision 3)", "+++ my/little/file.txt\t(working copy)", "@@ -1,4 +1,5 @@", "-bar", "+foo", " something unchanged");
     $bashCommandMock = $this->getMockBuilder('Kafoso\\SvnNumber\\Bash\\Command')->setMethods(array('exec', 'getMaxTerminalColumns'))->getMock();
     $bashCommandMock->expects($this->any())->method('exec')->will($this->returnValue($returnValue));
     $bashCommandMock->expects($this->any())->method('getMaxTerminalColumns')->will($this->returnValue(32));
     $svnNumberMock = $this->getMockBuilder('Kafoso\\SvnNumber')->setMethods(array('getBashCommand'))->setConstructorArgs(array(array("svn-number.php", "diff", "1"), $bashCommandMock))->getMock();
     $svnNumberMock->expects($this->any())->method('getBashCommand')->will($this->returnValue($bashCommandMock));
     $diff = new Diff($svnNumberMock);
     $expectedArray = array("Index: my/little/file.txt", "===================================================================", "--- my/little/file.txt\t(revision 3)", "+++ my/little/file.txt\t(working copy)", "@@ -1,4 +1,5 @@", "-bar", "+foo", " something unchanged");
     $expected = implode(PHP_EOL, $expectedArray);
     ob_start();
     $found = trim($diff->getOutputForFilePaths(array("my/little/file.txt")));
     $output = ob_get_contents();
     ob_end_clean();
     $this->assertSame("svn diff \"my/little/file.txt\"", trim($output));
     $this->assertSame($expected, $found);
 }
Ejemplo n.º 2
0
             exit(printStatus($status));
     }
 } else {
     if (in_array($svnNumber->getAction(), array("st", "status"))) {
         $status = new Status($svnNumber, $staging);
         printStatus($status);
     } else {
         if (in_array($svnNumber->getAction(), array("di", "diff"))) {
             $diff = new Diff($svnNumber);
             if ($svnNumber->hasRequestedNumbers()) {
                 $status = new Status($svnNumber, $staging);
                 $allLinesInformation = $status->getLineInformationFromFileNumbers($svnNumber->getRequestedNumbers());
                 $filePaths = array_map(function (Line $line) {
                     return $line->getFilePath();
                 }, $allLinesInformation);
                 exit($diff->getOutputForFilePaths($filePaths));
             } else {
                 exit($diff->getOutputAll());
             }
         } else {
             if (in_array($svnNumber->getAction(), array("ci", "commit"))) {
                 /**
                  * Apply same action to multiple files (bulk). E.g.:
                  *      # svn commit foo.txt bar.txt -m "Two files committed"
                  */
                 if ($svnNumber->hasRequestedNumbers()) {
                     $status = new Status($svnNumber, $staging);
                     $filePaths = array_map(function (Line $line) {
                         return escapeshellarg($line->getFilePath());
                     }, $status->getLineInformationFromFileNumbers($svnNumber->getRequestedNumbers()));
                     $svnNumber->exec(sprintf("svn %s %s %s", $svnNumber->getAction(), implode(" ", $filePaths), $svnNumber->getAdditionalArgsStr()));