Exemple #1
0
 /**
  * @dataProvider contextProvider
  *
  * @param int    $maxContext
  * @param string $from
  * @param string $to
  * @param string $expected
  */
 public function testContext($maxContext, $from, $to, $expected)
 {
     $context = new ContextDiff();
     $context->setMaxContext($maxContext);
     $diff = Diff::create($from, $to, $context);
     $formatter = new Text();
     $this->assertSame($expected, $formatter->format($diff));
 }
Exemple #2
0
 private function showDiff(Document $document, $existingFilepath)
 {
     $before = file_get_contents($existingFilepath);
     $after = $document->getContent();
     $diff = Diff\Diff::create($before, $after);
     $this->stdio->out('Differences to existing file:');
     if (!count($diff->getDiffLines())) {
         $this->stdio->outln(' <<yellow>>None<<reset>>');
         $this->stdio->outln();
         return;
     }
     $this->stdio->outln();
     $this->stdio->outln();
     if ($this->stdio->getStdout()->isPosix()) {
         $t = new Diff\Format\Template\POSIX();
     } else {
         $t = new Diff\Format\Template\Text();
     }
     $this->stdio->outln($t->format($diff));
     $this->stdio->outln();
 }
Exemple #3
0
 /**
  * @return int|string
  */
 private function showDiffs()
 {
     if ($this->stdio->getStdout()->isPosix()) {
         $diffTemplate = new Template\POSIX();
     } else {
         $diffTemplate = new Template\Text();
     }
     foreach ($this->files as $file) {
         if ($file->hasDiff() && count($file->getDiff()->getDiffLines())) {
             $this->stdio->outln('<<ul>>' . $file->getPath() . '<<reset>>:');
             $this->stdio->outln($diffTemplate->format($file->getDiff()));
         }
     }
 }