コード例 #1
0
ファイル: testbagit.php プロジェクト: Dragonpurse/mediamosa
 public function testHasBagInfoData()
 {
     $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->assertTrue($bag->hasBagInfoData('Source-organization'));
         $this->assertFalse($bag->hasBagInfoData('source-organization'));
         $this->assertFalse($bag->hasBagInfoData('SOURCE-ORGANIZATION'));
         $this->assertFalse($bag->hasBagInfoData('Source-Organization'));
         $this->assertFalse($bag->hasBagInfoData('SoUrCe-oRgAnIzAtIoN'));
         $this->assertTrue($bag->hasBagInfoData('Contact-name'));
         $this->assertFalse($bag->hasBagInfoData('contact-name'));
         $this->assertFalse($bag->hasBagInfoData('CONTACT-NAME'));
         $this->assertFalse($bag->hasBagInfoData('Contact-Name'));
         $this->assertFalse($bag->hasBagInfoData('CoNtAcT-NaMe'));
         $this->assertTrue($bag->hasBagInfoData('Bag-size'));
         $this->assertFalse($bag->hasBagInfoData('bag-size'));
         $this->assertFalse($bag->hasBagInfoData('BAG-SIZE'));
         $this->assertFalse($bag->hasBagInfoData('Bag-Size'));
         $this->assertFalse($bag->hasBagInfoData('BaG-SiZe'));
         $this->assertFalse($bag->hasBagInfoData('copyright-date'));
         $this->assertFalse($bag->hasBagInfoData('other-metadata'));
         $this->assertFalse($bag->hasBagInfoData('thrown-away-the-key'));
     } catch (Exception $e) {
         if (file_exists($tmp2)) {
             rrmdir($tmp2);
         }
         throw $e;
     }
     rrmdir($tmp2);
 }