Exemplo n.º 1
0
 public function testBagInfoWriteTagCase()
 {
     $this->assertEquals(0, count($this->bag->bagInfoData));
     $tmp2 = tmpdir();
     try {
         mkdir($tmp2);
         mkdir("{$tmp2}/data");
         $this->_createBagItTxt($tmp2);
         file_put_contents("{$tmp2}/bag-info.txt", "Source-organization: University of Virginia Alderman Library\n" . "Contact-name: Eric Rochester\n" . "Bag-size: very, very small\n");
         $bag = new BagIt($tmp2);
         $this->assertNotNull($bag->bagInfoData);
         $bag->setBagInfoData('First', 'This is the first tag value.');
         $bag->setBagInfoData('Second', 'This is the second tag value.');
         $bag->update();
         $this->assertEquals("Source-organization: University of Virginia Alderman Library\n" . "Contact-name: Eric Rochester\n" . "Bag-size: very, very small\n" . "First: This is the first tag value.\n" . "Second: This is the second tag value.\n", file_get_contents("{$tmp2}/bag-info.txt"));
     } catch (Exception $e) {
         if (file_exists($tmp2)) {
             rrmdir($tmp2);
         }
         if (file_exists("{$tmp2}.tgz")) {
             unlink("{$tmp2}.tgz");
         }
         throw $e;
     }
 }