コード例 #1
0
 public function testValidateChecksum()
 {
     $tmp = tmpdir();
     try {
         mkdir($tmp);
         mkdir($tmp . '/data');
         file_put_contents("{$tmp}/manifest-sha1.txt", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa data/missing.txt\n");
         touch("{$tmp}/data/missing.txt");
         $manifest = new BagItManifest("{$tmp}/manifest-sha1.txt", "{$tmp}/");
         $errors = array();
         $this->assertFalse($manifest->validate($errors));
         $this->assertTrue(seenAtKey($errors, 0, 'data/missing.txt'));
         $this->assertTrue(seenAtKey($errors, 1, 'Checksum mismatch.'));
     } catch (Exception $e) {
         rrmdir($tmp);
         throw $e;
     }
     rrmdir($tmp);
 }
コード例 #2
0
ファイル: bagit.php プロジェクト: AdrienneSerra/Digitalsc
 /**
  * Runs the bag validator on the contents of the bag. This verifies the
  * presence of required iles and folders and verifies the checksum for
  * each file.
  *
  * For the results of validation, check isValid() and getBagErrors().
  *
  * @return array The list of bag errors.
  */
 function validate()
 {
     $errors = array();
     BagIt_validateExists($this->bagitFile, $errors);
     BagIt_validateExists($this->getDataDirectory(), $errors);
     $this->manifest->validate($errors);
     $this->bagErrors = $errors;
     return $this->bagErrors;
 }