/**
  * Returns differences of hashes
  *
  * @param Robo47_DirectoryHasher_Result_File $oldFileResult
  * @param Robo47_DirectoryHasher_Result_File $newFileResult
  * @return \Robo47_DirectoryHasher_Comparator_Difference_WrongHash
  */
 public function getHashDifferences(Robo47_DirectoryHasher_Result_File $oldFileResult, Robo47_DirectoryHasher_Result_File $newFileResult)
 {
     $differences = array();
     $oldHashes = $oldFileResult->getHashes();
     $newHashes = $newFileResult->getHashes();
     foreach ($oldHashes as $hashname => $value) {
         if (!isset($newHashes[$hashname])) {
             $differences[] = new Robo47_DirectoryHasher_Comparator_Difference_MissingHash($oldFileResult->getFilename(), $hashname);
         } elseif ($oldHashes[$hashname] !== $newHashes[$hashname]) {
             $differences[] = new Robo47_DirectoryHasher_Comparator_Difference_WrongHash($oldFileResult->getFilename(), $hashname, $newHashes[$hashname], $oldHashes[$hashname]);
         }
     }
     return $differences;
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function addHashsToFileResult(Robo47_DirectoryHasher_Result_File $file)
 {
     $hashs = $this->getHashsForFile($file->getFilename());
     foreach ($hashs as $name => $value) {
         $file->addHash($name, $value);
     }
     return $this;
 }
Esempio n. 3
0
 /**
  * @covers Robo47_DirectoryHasher_Result_File::getFilename
  */
 public function testGetFilename()
 {
     $file = new Robo47_DirectoryHasher_Result_File('/some/file.php');
     $this->assertSame('/some/file.php', $file->getFilename());
 }