public function testSeenAtKeyFail() { $data = array(array('a' => 1, 'z' => 2), array('a' => 3, 'z' => 4), array('a' => 5, 'z' => 6), array('a' => 7, 'z' => 8)); $this->assertFalse(seenAtKey($data, 'a', 2)); $this->assertFalse(seenAtKey($data, 'z', 5)); $this->assertFalse(seenAtKey($data, 'a', 6)); $this->assertFalse(seenAtKey($data, 'z', 9)); $this->assertFalse(seenAtKey($data, 'm', 13)); }
public function testValidateChecksum() { $tmp = tmpdir(); try { mkdir($tmp); file_put_contents($tmp . "/manifest-sha1.txt", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa data/missing.txt\n"); mkdir($tmp . '/data'); touch($tmp . '/data/missing.txt'); $bag = new BagIt($tmp); $bag->validate(); $bagErrors = $bag->getBagErrors(); $this->assertFalse($bag->isValid()); $this->assertTrue(seenAtKey($bagErrors, 0, 'data/missing.txt')); $this->assertTrue(seenAtKey($bagErrors, 1, 'Checksum mismatch.')); } catch (Exception $e) { rrmdir($tmp); throw $e; } rrmdir($tmp); }
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); }