Пример #1
0
 /**
  * @covers Robo47_DirectoryHasher_Comparator_Result::addDifferences
  */
 public function testAddDifferences()
 {
     $result = new Robo47_DirectoryHasher_Comparator_Result();
     $differences = array(new Robo47_DirectoryHasher_Comparator_Difference_NewFile('/baa/foo.php'), new Robo47_DirectoryHasher_Comparator_Difference_NewFile('/baa/blub.php'));
     $result->addDifferences($differences);
     $this->assertCount(2, $result->getDifferences());
     $this->assertContains($differences[0], $result->getDifferences());
     $this->assertContains($differences[1], $result->getDifferences());
 }
Пример #2
0
 /**
  * Compares two Results
  *
  * @param Robo47_DirectoryHasher_Result $old
  * @param Robo47_DirectoryHasher_Result $new
  * @return Robo47_DirectoryHasher_Comparator_Result
  */
 public function compare(Robo47_DirectoryHasher_Result $old, Robo47_DirectoryHasher_Result $new)
 {
     $result = new Robo47_DirectoryHasher_Comparator_Result();
     foreach ($old->getIterator() as $fileResult) {
         /* @var $fileResult Robo47_DirectoryHasher_Result_File */
         if (!$new->hasFileResultFor($fileResult->getFilename())) {
             $result->addDifference(new Robo47_DirectoryHasher_Comparator_Difference_MissingFile($fileResult->getFilename()));
         } else {
             $result->addDifferences($this->getHashDifferences($fileResult, $new->getFileResultFor($fileResult->getFilename())));
         }
     }
     foreach ($new->getIterator() as $fileResult) {
         /* @var $fileResult Robo47_DirectoryHasher_Result_File */
         if (!$old->hasFileResultFor($fileResult->getFilename())) {
             $result->addDifference(new Robo47_DirectoryHasher_Comparator_Difference_NewFile($fileResult->getFilename()));
         }
     }
     return $result;
 }