public function __construct(\SPLFileInfo $asset, Pg $db)
 {
     $this->location = realpath($asset->getPathname());
     $dbSql = $this->dbSql = $db->query(new Query("SELECT * FROM build.assets WHERE location = %location:%", array('location' => $this->location)))->fetch(Result::FETCH_SINGLE);
     if ($dbSql) {
         $diff = new Diff();
         $this->diffText = $diff->diff($dbSql['sql'], file_get_contents($this->location));
     } else {
         $this->diffText = 'Asset not in database';
     }
     $this->message = sprintf("Database asset `%s` at %s changed at %s.\n%s", substr($asset->getBasename(), 0, -4), $this->location, date('Y-m-d H:i:s', $asset->getMTime()), $this->diffText);
 }
Esempio n. 2
0
 protected function additionalFailureDescription($other)
 {
     $from = preg_split('(\\r\\n|\\r|\\n)', $this->string);
     $to = preg_split('(\\r\\n|\\r|\\n)', $other);
     foreach ($from as $index => $line) {
         if (isset($to[$index]) && $line !== $to[$index]) {
             $line = $this->createPatternFromFormat($line);
             if (preg_match($line, $to[$index]) > 0) {
                 $from[$index] = $to[$index];
             }
         }
     }
     $this->string = join("\n", $from);
     $other = join("\n", $to);
     $diff = new Diff("--- Expected\n+++ Actual\n");
     return $diff->diff($this->string, $other);
 }
Esempio n. 3
0
 /**
  * @return string
  */
 public function getDiff()
 {
     if (!$this->actualAsString && !$this->expectedAsString) {
         return '';
     }
     $diff = new Diff("--- Expected\n+++ Actual\n");
     return $diff->diff($this->expectedAsString, $this->actualAsString);
 }