Пример #1
0
 public function testGetBagInfoData()
 {
     $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->assertEquals('University of Virginia Alderman Library', $bag->getBagInfoData('Source-organization'));
         $this->assertNotEquals('University of Virginia Alderman Library', $bag->getBagInfoData('source-organization'));
         $this->assertNotEquals('University of Virginia Alderman Library', $bag->getBagInfoData('SOURCE-ORGANIZATION'));
         $this->assertNotEquals('University of Virginia Alderman Library', $bag->getBagInfoData('Source-Organization'));
         $this->assertNotEquals('University of Virginia Alderman Library', $bag->getBagInfoData('SoUrCe-oRgAnIzAtIoN'));
         $this->assertEquals('Eric Rochester', $bag->getBagInfoData('Contact-name'));
         $this->assertNotEquals('Eric Rochester', $bag->getBagInfoData('contact-name'));
         $this->assertNotEquals('Eric Rochester', $bag->getBagInfoData('CONTACT-NAME'));
         $this->assertNotEquals('Eric Rochester', $bag->getBagInfoData('Contact-Name'));
         $this->assertNotEquals('Eric Rochester', $bag->getBagInfoData('CoNtAcT-NaMe'));
         $this->assertEquals('very, very small', $bag->getBagInfoData('Bag-size'));
         $this->assertNotEquals('very, very small', $bag->getBagInfoData('bag-size'));
         $this->assertNotEquals('very, very small', $bag->getBagInfoData('BAG-SIZE'));
         $this->assertNotEquals('very, very small', $bag->getBagInfoData('Bag-Size'));
         $this->assertNotEquals('very, very small', $bag->getBagInfoData('BaG-SiZe'));
         $this->assertNull($bag->getBagInfoData('copyright-date'));
         $this->assertNull($bag->getBagInfoData('other-metadata'));
         $this->assertNull($bag->getBagInfoData('thrown-away-the-key'));
     } catch (Exception $e) {
         if (file_exists($tmp2)) {
             rrmdir($tmp2);
         }
         throw $e;
     }
     rrmdir($tmp2);
 }