Open Journal Systems  3.3.0
testbagit.php
1 <?php
2 
3 require_once 'lib/bagit.php';
4 require_once 'lib/bagit_utils.php';
5 
6 class BagItTest extends PHPUnit_Framework_TestCase
7 {
8  var $tmpdir;
9  var $bag;
10 
11  private function _createBagItTxt($dirname)
12  {
13  file_put_contents(
14  "$dirname/bagit.txt",
15  "BagIt-Version: 1.3\n" .
16  "Tag-File-Character-Encoding: ISO-8859-1\n"
17  );
18  }
19 
20  public function setUp()
21  {
22  $this->tmpdir = tmpdir();
23  $this->bag = new BagIt($this->tmpdir);
24  }
25 
26  public function tearDown()
27  {
28  rrmdir($this->tmpdir);
29  }
30 
31  public function testBagDirectory()
32  {
33  $this->assertEquals($this->tmpdir, $this->bag->bagDirectory);
34  }
35 
36  public function testExtended()
37  {
38  $this->assertTrue($this->bag->extended);
39 
40  $tmp2 = tmpdir();
41  try
42  {
43  mkdir($tmp2);
44  touch($tmp2 . "/bag-info.txt");
45  $bag = new BagIt($tmp2, false, false);
46  $this->assertFalse($bag->extended);
47  }
48  catch (Exception $e)
49  {
50  rrmdir($tmp2);
51  throw $e;
52  }
53  rrmdir($tmp2);
54  }
55 
56  public function testBagVersion()
57  {
58  $this->assertEquals(0, $this->bag->bagVersion['major']);
59  $this->assertEquals(96, $this->bag->bagVersion['minor']);
60 
61  $tmp2 = tmpdir();
62  try
63  {
64  mkdir($tmp2);
65  $this->_createBagItTxt($tmp2);
66  $bag = new BagIt($tmp2);
67  $this->assertEquals(1, $bag->bagVersion['major']);
68  $this->assertEquals(3, $bag->bagVersion['minor']);
69  }
70  catch (Exception $e)
71  {
72  rrmdir($tmp2);
73  throw $e;
74  }
75  rrmdir($tmp2);
76  }
77 
78  public function testTagFileEncoding()
79  {
80  $this->assertEquals('UTF-8', $this->bag->tagFileEncoding);
81 
82  $tmp2 = tmpdir();
83  try
84  {
85  mkdir($tmp2);
86  $this->_createBagItTxt($tmp2);
87  $bag = new BagIt($tmp2);
88  $this->assertEquals('ISO-8859-1', $bag->tagFileEncoding);
89  }
90  catch (Exception $e)
91  {
92  rrmdir($tmp2);
93  throw $e;
94  }
95  rrmdir($tmp2);
96  }
97 
98  public function testBagitFile()
99  {
100  $this->assertEquals(
101  $this->tmpdir . "/bagit.txt",
102  $this->bag->bagitFile
103  );
104  $this->assertFileExists($this->bag->bagitFile);
105  $this->assertEquals(
106  "BagIt-Version: 0.96\n" .
107  "Tag-File-Character-Encoding: UTF-8\n",
108  file_get_contents($this->bag->bagitFile)
109  );
110  }
111 
112  public function testManifest()
113  {
114  $this->assertInstanceOf('BagItManifest', $this->bag->manifest);
115  }
116 
117  public function testTagManifest()
118  {
119  $this->assertInstanceOf('BagItManifest', $this->bag->tagManifest);
120  }
121 
122  public function testFetch()
123  {
124  $this->assertInstanceOf('BagItFetch', $this->bag->fetch);
125  }
126 
127  public function testBagInfoFile()
128  {
129  $this->assertEquals(
130  $this->tmpdir . "/bag-info.txt",
131  $this->bag->bagInfoFile
132  );
133  $this->assertFileExists($this->bag->bagInfoFile);
134  }
135 
136  public function testBagInfoContructor()
137  {
138  $tmp2 = tmpdir();
139  try
140  {
141  $bag = new BagIt($tmp2, FALSE, FALSE, FALSE, array(
142  'source-organization' => 'University of Virginia',
143  'contact-name' => 'Someone'
144  ));
145  $this->assertTrue($bag->extended);
146  $this->assertNotNull($bag->bagInfoData);
147  $this->assertTrue($bag->hasBagInfoData("source-organization"));
148  $this->assertTrue($bag->hasBagInfoData("contact-name"));
149  $this->assertFalse($bag->hasBagInfoData("bag-date"));
150  }
151  catch (Exception $e)
152  {
153  rrmdir($tmp2);
154  throw $e;
155  }
156  rrmdir($tmp2);
157  }
158 
159  public function testBagInfoData()
160  {
161  $this->assertEquals(0, count($this->bag->bagInfoData));
162 
163  $tmp2 = tmpdir();
164  try
165  {
166  mkdir($tmp2);
167  $this->_createBagItTxt($tmp2);
168  file_put_contents(
169  $tmp2 . "/bag-info.txt",
170  "Source-organization: University of Virginia Alderman Library\n" .
171  "Contact-name: Eric Rochester\n" .
172  "Bag-size: very, very small\n"
173  );
174  $bag = new BagIt($tmp2);
175  $this->assertNotNull($bag->bagInfoData);
176  $this->assertCount(3, $bag->bagInfoData);
177  $this->assertTrue($bag->hasBagInfoData("Source-organization"));
178  $this->assertTrue($bag->hasBagInfoData("Contact-name"));
179  $this->assertTrue($bag->hasBagInfoData("Bag-size"));
180  $this->assertFalse($bag->hasBagInfoData("bag-size"));
181  $this->assertFalse($bag->hasBagInfoData("BAG-SIZE"));
182  $this->assertFalse($bag->hasBagInfoData("bag-date"));
183  }
184  catch (Exception $e)
185  {
186  rrmdir($tmp2);
187  throw $e;
188  }
189  rrmdir($tmp2);
190  }
191 
192  public function testBagInfoDuplicateData()
193  {
194  $this->assertEquals(0, count($this->bag->bagInfoData));
195 
196  $tmp2 = tmpdir();
197  try
198  {
199  mkdir($tmp2);
200  $this->_createBagItTxt($tmp2);
201  file_put_contents(
202  $tmp2 . "/bag-info.txt",
203  "Source-organization: University of Virginia Alderman Library\n" .
204  "Contact-name: Eric Rochester\n" .
205  "Bag-size: very, very small\n" .
206  "DC-Author: Me\n" .
207  "DC-Author: Myself\n" .
208  "DC-Author: The other\n" .
209  " and more\n"
210  );
211  $bag = new BagIt($tmp2);
212  $this->assertNotNull($bag->bagInfoData);
213  $this->assertCount(4, $bag->bagInfoData);
214 
215  $this->assertTrue($bag->hasBagInfoData('DC-Author'));
216  $this->assertEquals(
217  array( 'Me', 'Myself', 'The other and more' ),
218  $bag->getBagInfoData('DC-Author')
219  );
220  }
221  catch (Exception $e)
222  {
223  rrmdir($tmp2);
224  throw $e;
225  }
226  rrmdir($tmp2);
227  }
228 
230  {
231  $this->assertEquals(0, count($this->bag->bagInfoData));
232 
233  $tmp2 = tmpdir();
234  try
235  {
236  mkdir($tmp2);
237  file_put_contents(
238  $tmp2 . "/bag-info.txt",
239  "Source-organization: University of Virginia Alderman Library\n" .
240  "Contact-name: Eric Rochester\n" .
241  "Bag-size: very, very small\n" .
242  "DC-Author: Me\n" .
243  "DC-Author: Myself\n" .
244  "DC-Author: The other\n"
245  );
246  $bag = new BagIt($tmp2);
247 
248  $bag->setBagInfoData('First', 'This is the first tag value.');
249  $bag->setBagInfoData('Second', 'This is the second tag value.');
250  $bag->setBagInfoData('Second', 'This is the third tag value.');
251  $bag->setBagInfoData('Third', 'This is the fourth tag value.');
252  $bag->setBagInfoData('Third', 'This is the fifth tag value.');
253  $bag->setBagInfoData('Third', 'This is the sixth tag value.');
254 
255  $this->assertEquals(
256  'This is the first tag value.',
257  $bag->getBagInfoData('First')
258  );
259  $this->assertEquals(
260  array( 'This is the second tag value.', 'This is the third tag value.' ),
261  $bag->getBagInfoData('Second')
262  );
263  $this->assertEquals(
264  array(
265  'This is the fourth tag value.',
266  'This is the fifth tag value.',
267  'This is the sixth tag value.'
268  ),
269  $bag->getBagInfoData('Third')
270  );
271 
272  }
273  catch (Exception $e)
274  {
275  rrmdir($tmp2);
276  throw $e;
277  }
278  rrmdir($tmp2);
279  }
280 
282  {
283  $this->assertEquals(0, count($this->bag->bagInfoData));
284 
285  $tmp2 = tmpdir();
286  try
287  {
288  mkdir($tmp2);
289  file_put_contents(
290  $tmp2 . "/bag-info.txt",
291  "Source-organization: University of Virginia Alderman Library\n" .
292  "Contact-name: Eric Rochester\n" .
293  "Bag-size: very, very small\n" .
294  "DC-Author: Me\n" .
295  "DC-Author: Myself\n" .
296  "DC-Author: The other\n"
297  );
298  $bag = new BagIt($tmp2);
299 
300  $bag->setBagInfoData('First', 'This is the first tag value.');
301  $bag->setBagInfoData('Second', 'This is the second tag value.');
302  $bag->setBagInfoData('Second', 'This is the third tag value.');
303  $bag->setBagInfoData('Third', 'This is the fourth tag value.');
304  $bag->setBagInfoData('Third', 'This is the fifth tag value.');
305  $bag->setBagInfoData('Third', 'This is the sixth tag value.');
306 
307  $this->assertEquals(
308  'This is the first tag value.',
309  $bag->getBagInfoData('First')
310  );
311  $this->assertEquals(
312  array( 'This is the second tag value.', 'This is the third tag value.' ),
313  $bag->getBagInfoData('Second')
314  );
315  $this->assertEquals(
316  array(
317  'This is the fourth tag value.',
318  'This is the fifth tag value.',
319  'This is the sixth tag value.'
320  ),
321  $bag->getBagInfoData('Third')
322  );
323 
324  $bag->clearBagInfoData('Third');
325  $this->assertNotNull($bag->getBagInfoData('First'));
326  $this->assertNotNull($bag->getBagInfoData('Second'));
327  $this->assertNull( $bag->getBagInfoData('Third'));
328 
329  }
330  catch (Exception $e)
331  {
332  rrmdir($tmp2);
333  throw $e;
334  }
335  rrmdir($tmp2);
336  }
337 
339  {
340  $this->assertEquals(0, count($this->bag->bagInfoData));
341 
342  $tmp2 = tmpdir();
343  try
344  {
345  mkdir($tmp2);
346  mkdir("$tmp2/data");
347  $this->_createBagItTxt($tmp2);
348  file_put_contents(
349  $tmp2 . "/bag-info.txt",
350  "Source-organization: University of Virginia Alderman Library\n" .
351  "Contact-name: Eric Rochester\n" .
352  "Bag-size: very, very small\n" .
353  "DC-Author: Me\n" .
354  "DC-Author: Myself\n" .
355  "DC-Author: The other\n"
356  );
357  $bag = new BagIt($tmp2);
358 
359  $bag->setBagInfoData('First', 'This is the first tag value.');
360  $bag->setBagInfoData('Second', 'This is the second tag value.');
361  $bag->setBagInfoData('Second', 'This is the third tag value.');
362  $bag->setBagInfoData('Third', 'This is the fourth tag value.');
363  $bag->setBagInfoData('Third', 'This is the fifth tag value.');
364  $bag->setBagInfoData('Third', 'This is the sixth tag value.');
365 
366  $bag->update();
367 
368  $this->assertEquals(
369  "Source-organization: University of Virginia Alderman Library\n" .
370  "Contact-name: Eric Rochester\n" .
371  "Bag-size: very, very small\n" .
372  "DC-Author: Me\n" .
373  "DC-Author: Myself\n" .
374  "DC-Author: The other\n" .
375  "First: This is the first tag value.\n" .
376  "Second: This is the second tag value.\n" .
377  "Second: This is the third tag value.\n" .
378  "Third: This is the fourth tag value.\n" .
379  "Third: This is the fifth tag value.\n" .
380  "Third: This is the sixth tag value.\n",
381  file_get_contents("$tmp2/bag-info.txt")
382  );
383 
384  }
385  catch (Exception $e)
386  {
387  rrmdir($tmp2);
388  throw $e;
389  }
390  rrmdir($tmp2);
391  }
392 
393  public function testBagInfoWrite()
394  {
395  $this->assertEquals(0, count($this->bag->bagInfoData));
396 
397  $tmp2 = tmpdir();
398  try
399  {
400  mkdir($tmp2);
401  mkdir("$tmp2/data");
402 
403  file_put_contents(
404  "$tmp2/bag-info.txt",
405  "Source-organization: University of Virginia Alderman Library\n" .
406  "Contact-name: Eric Rochester\n" .
407  "Bag-size: very, very small\n"
408  );
409  $bag = new BagIt($tmp2);
410  $this->assertNotNull($bag->bagInfoData);
411 
412  $bag->setBagInfoData('First', 'This is the first tag value.');
413  $bag->setBagInfoData('Second', 'This is the second tag value.');
414 
415  $bag->update();
416  $bag->package("$tmp2.tgz");
417  rrmdir($tmp2);
418 
419  $bag2 = new BagIt("$tmp2.tgz");
420  $tmp2 = $bag2->bagDirectory;
421 
422  $this->assertTrue($bag2->hasBagInfoData('First'));
423  $this->assertEquals(
424  'This is the first tag value.',
425  $bag2->getBagInfoData('First')
426  );
427  $this->assertTrue($bag2->hasBagInfoData('Second'));
428  $this->assertEquals(
429  'This is the second tag value.',
430  $bag2->getBagInfoData('Second')
431  );
432  }
433  catch (Exception $e)
434  {
435  if (file_exists($tmp2)) {
436  rrmdir($tmp2);
437  }
438  if (file_exists("$tmp2.tgz")) {
439  unlink("$tmp2.tgz");
440  }
441  throw $e;
442  }
443  rrmdir($tmp2);
444  }
445 
446  public function testBagInfoWriteTagCase()
447  {
448  $this->assertEquals(0, count($this->bag->bagInfoData));
449 
450  $tmp2 = tmpdir();
451  try
452  {
453  mkdir($tmp2);
454  mkdir("$tmp2/data");
455 
456  $this->_createBagItTxt($tmp2);
457  file_put_contents(
458  "$tmp2/bag-info.txt",
459  "Source-organization: University of Virginia Alderman Library\n" .
460  "Contact-name: Eric Rochester\n" .
461  "Bag-size: very, very small\n"
462  );
463  $bag = new BagIt($tmp2);
464  $this->assertNotNull($bag->bagInfoData);
465 
466  $bag->setBagInfoData('First', 'This is the first tag value.');
467  $bag->setBagInfoData('Second', 'This is the second tag value.');
468 
469  $bag->update();
470 
471  $this->assertEquals(
472  "Source-organization: University of Virginia Alderman Library\n" .
473  "Contact-name: Eric Rochester\n" .
474  "Bag-size: very, very small\n" .
475  "First: This is the first tag value.\n" .
476  "Second: This is the second tag value.\n",
477  file_get_contents("$tmp2/bag-info.txt")
478  );
479  }
480  catch (Exception $e)
481  {
482  if (file_exists($tmp2)) {
483  rrmdir($tmp2);
484  }
485  if (file_exists("$tmp2.tgz")) {
486  unlink("$tmp2.tgz");
487  }
488  throw $e;
489  }
490  }
491 
492  public function testBagInfoNull()
493  {
494  $this->bag->bagInfoData = null;
495  $this->assertNull($this->bag->bagInfoData);
496  $this->bag->hasBagInfoData('hi');
497  $this->assertFalse(is_null($this->bag->bagInfoData));
498  $this->assertCount(0, $this->bag->bagInfoData);
499  }
500 
501  public function testHasBagInfoData()
502  {
503  $tmp2 = tmpdir();
504  try
505  {
506  mkdir($tmp2);
507  mkdir("$tmp2/data");
508 
509  $this->_createBagItTxt($tmp2);
510  file_put_contents(
511  "$tmp2/bag-info.txt",
512  "Source-organization: University of Virginia Alderman Library\n" .
513  "Contact-name: Eric Rochester\n" .
514  "Bag-size: very, very small\n"
515  );
516  $bag = new BagIt($tmp2);
517 
518  $this->assertTrue( $bag->hasBagInfoData('Source-organization'));
519  $this->assertFalse($bag->hasBagInfoData('source-organization'));
520  $this->assertFalse($bag->hasBagInfoData('SOURCE-ORGANIZATION'));
521  $this->assertFalse($bag->hasBagInfoData('Source-Organization'));
522  $this->assertFalse($bag->hasBagInfoData('SoUrCe-oRgAnIzAtIoN'));
523 
524  $this->assertTrue( $bag->hasBagInfoData('Contact-name'));
525  $this->assertFalse($bag->hasBagInfoData('contact-name'));
526  $this->assertFalse($bag->hasBagInfoData('CONTACT-NAME'));
527  $this->assertFalse($bag->hasBagInfoData('Contact-Name'));
528  $this->assertFalse($bag->hasBagInfoData('CoNtAcT-NaMe'));
529 
530  $this->assertTrue( $bag->hasBagInfoData('Bag-size'));
531  $this->assertFalse($bag->hasBagInfoData('bag-size'));
532  $this->assertFalse($bag->hasBagInfoData('BAG-SIZE'));
533  $this->assertFalse($bag->hasBagInfoData('Bag-Size'));
534  $this->assertFalse($bag->hasBagInfoData('BaG-SiZe'));
535 
536  $this->assertFalse($bag->hasBagInfoData('copyright-date'));
537  $this->assertFalse($bag->hasBagInfoData('other-metadata'));
538  $this->assertFalse($bag->hasBagInfoData('thrown-away-the-key'));
539  }
540  catch (Exception $e)
541  {
542  if (file_exists($tmp2)) {
543  rrmdir($tmp2);
544  }
545  throw $e;
546  }
547  rrmdir($tmp2);
548  }
549 
550  public function testGetBagInfoData()
551  {
552  $tmp2 = tmpdir();
553  try
554  {
555  mkdir($tmp2);
556  mkdir("$tmp2/data");
557 
558  $this->_createBagItTxt($tmp2);
559  file_put_contents(
560  "$tmp2/bag-info.txt",
561  "Source-organization: University of Virginia Alderman Library\n" .
562  "Contact-name: Eric Rochester\n" .
563  "Bag-size: very, very small\n"
564  );
565  $bag = new BagIt($tmp2);
566 
567  $this->assertEquals( 'University of Virginia Alderman Library', $bag->getBagInfoData('Source-organization'));
568  $this->assertNotEquals('University of Virginia Alderman Library', $bag->getBagInfoData('source-organization'));
569  $this->assertNotEquals('University of Virginia Alderman Library', $bag->getBagInfoData('SOURCE-ORGANIZATION'));
570  $this->assertNotEquals('University of Virginia Alderman Library', $bag->getBagInfoData('Source-Organization'));
571  $this->assertNotEquals('University of Virginia Alderman Library', $bag->getBagInfoData('SoUrCe-oRgAnIzAtIoN'));
572 
573  $this->assertEquals( 'Eric Rochester', $bag->getBagInfoData('Contact-name'));
574  $this->assertNotEquals('Eric Rochester', $bag->getBagInfoData('contact-name'));
575  $this->assertNotEquals('Eric Rochester', $bag->getBagInfoData('CONTACT-NAME'));
576  $this->assertNotEquals('Eric Rochester', $bag->getBagInfoData('Contact-Name'));
577  $this->assertNotEquals('Eric Rochester', $bag->getBagInfoData('CoNtAcT-NaMe'));
578 
579  $this->assertEquals( 'very, very small', $bag->getBagInfoData('Bag-size'));
580  $this->assertNotEquals('very, very small', $bag->getBagInfoData('bag-size'));
581  $this->assertNotEquals('very, very small', $bag->getBagInfoData('BAG-SIZE'));
582  $this->assertNotEquals('very, very small', $bag->getBagInfoData('Bag-Size'));
583  $this->assertNotEquals('very, very small', $bag->getBagInfoData('BaG-SiZe'));
584 
585  $this->assertNull($bag->getBagInfoData('copyright-date'));
586  $this->assertNull($bag->getBagInfoData('other-metadata'));
587  $this->assertNull($bag->getBagInfoData('thrown-away-the-key'));
588  }
589  catch (Exception $e)
590  {
591  if (file_exists($tmp2)) {
592  rrmdir($tmp2);
593  }
594  throw $e;
595  }
596  rrmdir($tmp2);
597  }
598 
599  public function testSetBagInfoData()
600  {
601  $this->assertCount(0, $this->bag->bagInfoData);
602  $this->bag->setBagInfoData('hi', 'some value');
603 
604  $this->assertTrue($this->bag->hasBagInfoData('hi'));
605  $this->assertFalse($this->bag->hasBagInfoData('HI'));
606  $this->assertFalse($this->bag->hasBagInfoData('Hi'));
607  $this->assertFalse($this->bag->hasBagInfoData('hI'));
608 
609  $this->assertEquals('some value', $this->bag->getBagInfoData('hi'));
610  $this->assertCount(1, $this->bag->bagInfoData);
611  }
612 
613  public function testBagCompression()
614  {
615  $this->assertNull($this->bag->bagCompression);
616  }
617 
618  public function testBagErrors()
619  {
620  $this->assertInternalType('array', $this->bag->bagErrors);
621  $this->assertEquals(0, count($this->bag->bagErrors));
622  }
623 
624  public function testConstructorValidate()
625  {
626  $this->assertTrue($this->bag->isValid());
627  $this->assertEquals(0, count($this->bag->bagErrors));
628 
629  $tmp = tmpdir();
630  try
631  {
632  mkdir($tmp);
633  $this->_createBagItTxt($tmp);
634  $bag = new BagIt($tmp, true);
635  $this->assertFalse($bag->isValid());
636  $this->assertGreaterThan(0, count($bag->bagErrors));
637  }
638  catch (Exception $e)
639  {
640  rrmdir($tmp);
641  throw $e;
642  }
643  rrmdir($tmp);
644  }
645 
646  public function testConstructorExtended()
647  {
648  $this->assertFileExists($this->tmpdir . '/bag-info.txt');
649  $this->assertFileNotExists($this->tmpdir . '/fetch.txt');
650  $this->assertFileExists($this->tmpdir . '/tagmanifest-sha1.txt');
651 
652  $tmp = tmpdir();
653  try
654  {
655  $bag = new BagIt($tmp, false, false);
656  $this->assertFalse(is_file($tmp . '/bag-info.txt'));
657  $this->assertFalse(is_file($tmp . '/fetch.txt'));
658  $this->assertFalse(is_file($tmp . '/tagmanifest-sha1.txt'));
659  }
660  catch (Exception $e)
661  {
662  rrmdir($tmp);
663  throw $e;
664  }
665  rrmdir($tmp);
666  }
667 
668  public function testConstructorFetch()
669  {
670  $tmp = tmpdir();
671  try
672  {
673  mkdir($tmp);
674  file_put_contents(
675  $tmp . "/fetch.txt",
676  "http://www.google.com - google/index.html\n" .
677  "http://www.yahoo.com - yahoo/index.html\n"
678  );
679  $bag = new BagIt($tmp, false, true, false);
680  $this->assertFalse(
681  is_file($bag->getDataDirectory() . '/google/index.html')
682  );
683  $this->assertFalse(
684  is_file($bag->getDataDirectory() . '/yahoo/index.html')
685  );
686  }
687  catch (Exception $e)
688  {
689  rrmdir($tmp);
690  throw $e;
691  }
692  rrmdir($tmp);
693 
694  $tmp = tmpdir();
695  try
696  {
697  mkdir($tmp);
698  file_put_contents(
699  $tmp . "/fetch.txt",
700  "http://www.google.com - data/google/index.html\n" .
701  "http://www.yahoo.com - data/yahoo/index.html\n"
702  );
703  $bag = new BagIt($tmp, false, true, true);
704  $this->assertFileExists($bag->getDataDirectory() . '/google/index.html');
705  $this->assertFileExists($bag->getDataDirectory() . '/yahoo/index.html');
706  }
707  catch (Exception $e)
708  {
709  rrmdir($tmp);
710  throw $e;
711  }
712  rrmdir($tmp);
713  }
714 
716  {
717  $this->assertEquals(0, $this->bag->bagVersion['major']);
718 
719  $tmp = tmpdir();
720  try
721  {
722  mkdir($tmp);
723  file_put_contents(
724  $tmp . "/bagit.txt",
725  "BagIt-Version: a.b\n" .
726  "Tag-File-Character-Encoding: ISO-8859-1\n"
727  );
728  $bag = new BagIt($tmp);
729  $this->assertFalse($bag->isValid());
730  $bagErrors = $bag->getBagErrors();
731  $this->assertTrue(seenAtKey($bagErrors, 0, 'bagit'));
732  }
733  catch (Exception $e)
734  {
735  rrmdir($tmp);
736  throw $e;
737  }
738  rrmdir($tmp);
739  }
740 
741  private function _testSampleBag($bag)
742  {
743  $this->assertTrue($bag->isValid());
744 
745  // Testing what's in the bag (relativize the paths).
746  $stripLen = strlen($bag->bagDirectory) + 1;
747  $files = $bag->getBagContents();
748  for ($i=0, $lsLen=count($files); $i<$lsLen; $i++)
749  {
750  $files[$i] = substr($files[$i], $stripLen);
751  }
752  $this->assertContains('data/imgs/109x109xcoins1-150x150.jpg', $files);
753  $this->assertContains('data/imgs/109x109xprosody.png', $files);
754  $this->assertContains('data/imgs/110x108xmetaphor1.png', $files);
755  $this->assertContains('data/imgs/fellows1-150x150.png', $files);
756  $this->assertContains('data/imgs/fibtriangle-110x110.jpg', $files);
757  $this->assertContains('data/imgs/uvalib.png', $files);
758  $this->assertContains('data/README.txt', $files);
759 
760  // Testing the checksums.
761  $this->assertEquals('547b21e9c710f562d448a6cd7d32f8257b04e561', $bag->manifest->data['data/imgs/109x109xcoins1-150x150.jpg']);
762  $this->assertEquals('fba552acae866d24fb143fef0ddb24efc49b097a', $bag->manifest->data['data/imgs/109x109xprosody.png']);
763  $this->assertEquals('4beed314513ad81e1f5fad42672a3b1bd3a018ea', $bag->manifest->data['data/imgs/110x108xmetaphor1.png']);
764  $this->assertEquals('4372383348c55775966bb1deeeb2b758b197e2a1', $bag->manifest->data['data/imgs/fellows1-150x150.png']);
765  $this->assertEquals('b8593e2b3c2fa3756d2b206a90c7259967ff6650', $bag->manifest->data['data/imgs/fibtriangle-110x110.jpg']);
766  $this->assertEquals('aec60202453733a976433833c9d408a449f136b3', $bag->manifest->data['data/imgs/uvalib.png']);
767  $this->assertEquals('0de174b95ebacc2d91b0839cb2874b2e8f604b98', $bag->manifest->data['data/README.txt']);
768 
769  // Testing the fetch file.
770  $data = $bag->fetch->getData();
771  $this->assertEquals('http://www.scholarslab.org', $data[0]['url']);
772  $this->assertEquals('data/index.html', $data[0]['filename']);
773  }
774 
775  public function testConstructorDir()
776  {
777  $bagDir = __DIR__ . '/TestBag';
778  $bag = new BagIt($bagDir);
779 
780  $this->assertNull($bag->bagCompression);
781  $this->_testSampleBag($bag);
782  }
783 
784  public function testConstructorZip()
785  {
786  $bagZip = __DIR__ . '/TestBag.zip';
787  $bag = new BagIt($bagZip);
788 
789  $this->assertEquals('zip', $bag->bagCompression);
790  $this->_testSampleBag($bag);
791  }
792 
793  public function testConstructorTGz()
794  {
795  $bagTar = __DIR__ . '/TestBag.tgz';
796  $bag = new BagIt($bagTar);
797 
798  $this->assertEquals('tgz', $bag->bagCompression);
799  $this->_testSampleBag($bag);
800  }
801 
802  public function testIsValid()
803  {
804  $this->assertTrue($this->bag->isValid());
805  }
806 
807  public function testIsExtended()
808  {
809  $this->assertTrue($this->bag->isExtended());
810 
811  $tmp = tmpdir();
812  try
813  {
814  $bag = new BagIt($tmp, false, false);
815  $this->assertFalse($bag->isExtended());
816  }
817  catch (Exception $e)
818  {
819  rrmdir($tmp);
820  throw $e;
821  }
822  rrmdir($tmp);
823 
824  $tmp = tmpdir();
825  try
826  {
827  mkdir($tmp);
828  file_put_contents(
829  $tmp . "/bag-info.txt",
830  "Source-organization: University of Virginia Alderman Library\n" .
831  "Contact-name: Eric Rochester\n" .
832  "Bag-size: very, very small\n"
833  );
834  $bag = new BagIt($tmp, false, false);
835  $this->assertFalse($bag->isExtended());
836  }
837  catch (Exception $e)
838  {
839  rrmdir($tmp);
840  throw $e;
841  }
842  rrmdir($tmp);
843  }
844 
845  public function testGetBagInfo()
846  {
847  $bagInfo = $this->bag->getBagInfo();
848 
849  $this->assertInternalType('array', $bagInfo);
850 
851  $this->assertArrayHasKey('version', $bagInfo);
852  $this->assertArrayHasKey('encoding', $bagInfo);
853  $this->assertArrayHasKey('hash', $bagInfo);
854 
855  $this->assertEquals('0.96', $bagInfo['version']);
856  $this->assertEquals('UTF-8', $bagInfo['encoding']);
857  $this->assertEquals('sha1', $bagInfo['hash']);
858  }
859 
860  public function testGetDataDirectory()
861  {
862  $dataDir = $this->bag->getDataDirectory();
863  $this->assertStringStartsWith($this->tmpdir, $dataDir);
864  }
865 
866  public function testGetHashEncoding()
867  {
868  $hash = $this->bag->getHashEncoding();
869  $this->assertEquals('sha1', $hash);
870  }
871 
872  public function testSetHashEncodingMD5()
873  {
874  $this->bag->setHashEncoding('md5');
875  $this->assertEquals('md5', $this->bag->getHashEncoding());
876  }
877 
878  public function testSetHashEncodingSHA1()
879  {
880  $this->bag->setHashEncoding('md5');
881  $this->bag->setHashEncoding('sha1');
882  $this->assertEquals('sha1', $this->bag->getHashEncoding());
883  }
884 
888  public function testSetHashEncodingERR()
889  {
890  $this->bag->setHashEncoding('err');
891  }
892 
893  public function testSetHashEncodingBoth()
894  {
895  $this->bag->setHashEncoding('md5');
896  $this->assertEquals('md5', $this->bag->manifest->getHashEncoding());
897  $this->assertEquals('md5', $this->bag->tagManifest->getHashEncoding());
898  }
899 
900  public function testGetBagContents()
901  {
902  $bagContents = $this->bag->getBagContents();
903 
904  $this->assertInternalType('array', $bagContents);
905  $this->assertEquals(0, count($bagContents));
906 
907  $tmp = tmpdir();
908  try
909  {
910  mkdir($tmp);
911  mkdir("$tmp/data");
912  file_put_contents(
913  $tmp . "/data/something.txt",
914  "Source-organization: University of Virginia Alderman Library\n" .
915  "Contact-name: Eric Rochester\n" .
916  "Bag-size: very, very small\n"
917  );
918  $bag = new BagIt($tmp);
919 
920  $bagContents = $bag->getBagContents();
921  $this->assertEquals(1, count($bagContents));
922  $this->assertEquals($tmp . '/data/something.txt', $bagContents[0]);
923  }
924  catch (Exception $e)
925  {
926  rrmdir($tmp);
927  throw $e;
928  }
929  rrmdir($tmp);
930  }
931 
932  public function testGetBagErrors()
933  {
934  $bagErrors = $this->bag->getBagErrors();
935  $this->assertInternalType('array', $bagErrors);
936  $this->assertEquals(0, count($bagErrors));
937 
938  rrmdir($this->bag->getDataDirectory());
939  $this->bag->validate();
940  $this->assertGreaterThan(0, count($this->bag->getBagErrors()));
941  }
942 
943  public function testGetBagErrorsValidate()
944  {
945  rrmdir($this->bag->getDataDirectory());
946  $bagErrors = $this->bag->getBagErrors(true);
947  $this->assertInternalType('array', $bagErrors);
948  $this->assertGreaterThan(0, count($bagErrors));
949  }
950 
951  public function testValidateMissingBagFile()
952  {
953  unlink($this->bag->bagitFile);
954 
955  $this->bag->validate();
956  $bagErrors = $this->bag->getBagErrors();
957 
958  $this->assertFalse($this->bag->isValid());
959  $this->assertTrue(seenAtKey($bagErrors, 0, 'bagit.txt'));
960  }
961 
962  public function testValidateChecksum()
963  {
964  $tmp = tmpdir();
965  try
966  {
967  mkdir($tmp);
968  file_put_contents(
969  $tmp . "/manifest-sha1.txt",
970  "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa data/missing.txt\n"
971  );
972  mkdir($tmp . '/data');
973  touch($tmp . '/data/missing.txt');
974  $bag = new BagIt($tmp);
975  $bag->validate();
976  $bagErrors = $bag->getBagErrors();
977 
978  $this->assertFalse($bag->isValid());
979  $this->assertTrue(seenAtKey($bagErrors, 0, 'data/missing.txt'));
980  $this->assertTrue(seenAtKey($bagErrors, 1, 'Checksum mismatch.'));
981  }
982  catch (Exception $e)
983  {
984  rrmdir($tmp);
985  throw $e;
986  }
987  rrmdir($tmp);
988  }
989 
990  public function testUpdateCreateMissing()
991  {
992  $tmp = tmpdir();
993  try
994  {
995  $bag = new BagIt($tmp);
996  $bag->update();
997 
998  $this->assertFileExists($tmp . '/bagit.txt');
999  $this->assertFileExists($tmp . '/manifest-sha1.txt');
1000  $this->assertTrue(is_dir($tmp . '/data'));
1001 
1002  }
1003  catch (Exception $e)
1004  {
1005  rrmdir($tmp);
1006  throw $e;
1007  }
1008  rrmdir($tmp);
1009  }
1010 
1011  public function testUpdateSanitize()
1012  {
1013  $tmp = tmpdir();
1014  try
1015  {
1016  mkdir($tmp);
1017  mkdir($tmp . '/data');
1018  touch($tmp . '/data/has space');
1019  touch($tmp . '/data/PRN');
1020  touch($tmp . '/data/backup~');
1021  touch($tmp . '/data/.hidden');
1022  touch($tmp . '/data/quoted "yep" quoted');
1023 
1024  $bag = new BagIt($tmp);
1025  $bag->update();
1026 
1027  $this->assertFalse(is_file($tmp . '/data/has space'));
1028  $this->assertFileExists($tmp . '/data/has_space');
1029 
1030  $this->assertFalse(is_file($tmp . '/data/PRN'));
1031  $this->assertEquals(1, count(glob($tmp . '/data/prn_*')));
1032 
1033  $this->assertFalse(is_file($tmp . '/data/backup~'));
1034 
1035  $this->assertFalse(is_file($tmp . '/data/quoted "yep" quoted'));
1036  $this->assertFileExists($tmp . '/data/quoted_yep_quoted');
1037 
1038  }
1039  catch (Exception $e)
1040  {
1041  rrmdir($tmp);
1042  throw $e;
1043  }
1044  rrmdir($tmp);
1045  }
1046 
1047  public function testUpdateChecksums()
1048  {
1049  $tmp = tmpdir();
1050  try
1051  {
1052  mkdir($tmp);
1053  file_put_contents(
1054  $tmp . "/manifest-sha1.txt",
1055  "abababababababababababababababababababab data/missing.txt\n"
1056  );
1057  mkdir($tmp . '/data');
1058  file_put_contents(
1059  $tmp . '/data/missing.txt',
1060  "This space intentionally left blank.\n"
1061  );
1062  $bag = new BagIt($tmp);
1063  $bag->update();
1064 
1065  $this->assertEquals(
1066  "a5c44171ca6618c6ee24c3f3f3019df8df09a2e0 data/missing.txt\n",
1067  file_get_contents($tmp . '/manifest-sha1.txt')
1068  );
1069  $this->assertEquals(
1070  'a5c44171ca6618c6ee24c3f3f3019df8df09a2e0',
1071  $bag->manifest->data['data/missing.txt']
1072  );
1073 
1074  }
1075  catch (Exception $e)
1076  {
1077  rrmdir($tmp);
1078  throw $e;
1079  }
1080  rrmdir($tmp);
1081  }
1082 
1083  public function testUpdateNewFiles()
1084  {
1085  $tmp = tmpdir();
1086  try
1087  {
1088  mkdir($tmp);
1089  mkdir($tmp . '/data');
1090  file_put_contents(
1091  $tmp . '/data/missing.txt',
1092  "This space intentionally left blank.\n"
1093  );
1094  $bag = new BagIt($tmp);
1095  $bag->update();
1096 
1097  $this->assertEquals(
1098  "a5c44171ca6618c6ee24c3f3f3019df8df09a2e0 data/missing.txt\n",
1099  file_get_contents($tmp . '/manifest-sha1.txt')
1100  );
1101  $this->assertEquals(
1102  'a5c44171ca6618c6ee24c3f3f3019df8df09a2e0',
1103  $bag->manifest->data['data/missing.txt']
1104  );
1105 
1106  }
1107  catch (Exception $e)
1108  {
1109  rrmdir($tmp);
1110  throw $e;
1111  }
1112  rrmdir($tmp);
1113  }
1114 
1115  public function testUpdateDeletedFiles()
1116  {
1117  $tmp = tmpdir();
1118  try
1119  {
1120  mkdir($tmp);
1121  file_put_contents(
1122  $tmp . "/manifest-sha1.txt",
1123  "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd data/missing.txt\n"
1124  );
1125  mkdir($tmp . '/data');
1126  $bag = new BagIt($tmp);
1127  $bag->update();
1128 
1129  $this->assertEquals(
1130  '',
1131  file_get_contents($tmp . '/manifest-sha1.txt')
1132  );
1133  $this->assertFalse(
1134  array_key_exists('data/missing.txt', $bag->manifest->data)
1135  );
1136 
1137  }
1138  catch (Exception $e)
1139  {
1140  rrmdir($tmp);
1141  throw $e;
1142  }
1143  rrmdir($tmp);
1144  }
1145 
1146  public function testUpdateExtended()
1147  {
1148  $tmp = tmpdir();
1149  try
1150  {
1151  $bag = new BagIt($tmp);
1152  $bag->update();
1153 
1154  $this->assertFileExists($tmp . '/bag-info.txt');
1155  $this->assertFileExists($tmp . '/tagmanifest-sha1.txt');
1156  $this->assertFileNotExists($tmp . '/fetch.txt');
1157 
1158  }
1159  catch (Exception $e)
1160  {
1161  rrmdir($tmp);
1162  throw $e;
1163  }
1164  rrmdir($tmp);
1165  }
1166 
1167  public function testAddFile()
1168  {
1169  $srcdir = __DIR__ . '/TestBag/data';
1170 
1171  $this->bag->addFile("$srcdir/README.txt", 'data/README.txt');
1172 
1173  $datadir = $this->bag->getDataDirectory();
1174  $this->assertFileExists("{$datadir}/README.txt");
1175  $this->assertFileEquals("$srcdir/README.txt", "{$datadir}/README.txt");
1176 
1177  $this->bag->addFile("$srcdir/imgs/uvalib.png", "data/pics/uvalib.png");
1178 
1179  $this->assertFileExists("{$datadir}/pics/uvalib.png");
1180  $this->assertFileEquals(
1181  "$srcdir/imgs/uvalib.png",
1182  "{$datadir}/pics/uvalib.png"
1183  );
1184  }
1185 
1186  public function testAddFileAddDataDir()
1187  {
1188  $srcdir = __DIR__ . '/TestBag/data';
1189 
1190  $this->bag->addFile("$srcdir/README.txt", 'README.txt');
1191 
1192  $datadir = $this->bag->getDataDirectory();
1193  $this->assertFileExists("{$datadir}/README.txt");
1194  $this->assertFileEquals("$srcdir/README.txt", "{$datadir}/README.txt");
1195 
1196  $this->bag->addFile("$srcdir/imgs/uvalib.png", "pics/uvalib.png");
1197 
1198  $this->assertFileExists("{$datadir}/pics/uvalib.png");
1199  $this->assertFileEquals(
1200  "$srcdir/imgs/uvalib.png",
1201  "{$datadir}/pics/uvalib.png"
1202  );
1203  }
1204 
1205  public function testCreateFile()
1206  {
1207  $testContent = "This is some test content.";
1208 
1209  $this->bag->createFile($testContent, "data/testCreateFile.txt");
1210  $datadir = $this->bag->getDataDirectory();
1211  $this->assertFileExists("{$datadir}/testCreateFile.txt");
1212  $content = file_get_contents("{$datadir}/testCreateFile.txt");
1213  $this->assertEquals($content, $testContent);
1214  }
1215 
1216  public function testCreateFileAddDataDir()
1217  {
1218  $testContent = "This is some test content.";
1219 
1220  $this->bag->createFile($testContent, "testCreateFile.txt");
1221  $datadir = $this->bag->getDataDirectory();
1222  $this->assertFileExists("{$datadir}/testCreateFile.txt");
1223  $content = file_get_contents("{$datadir}/testCreateFile.txt");
1224  $this->assertEquals($content, $testContent);
1225  }
1226 
1230  public function testCreateFileDuplicate()
1231  {
1232  $testContent = "This is some test content.";
1233 
1234  $this->bag->createFile($testContent, "testCreateFile.txt");
1235  $this->bag->createFile('', "testCreateFile.txt");
1236  }
1237 
1238 
1239 
1243  public function testAddFileMissing()
1244  {
1245  $srcdir = __DIR__ . '/TestBag/data';
1246  $this->bag->addFile("$srcdir/missing.txt", 'data/missing.txt');
1247  }
1248 
1249  public function testPackageZip()
1250  {
1251  $tmp = tmpdir();
1252  try
1253  {
1254  mkdir($tmp);
1255  mkdir($tmp . '/data');
1256  file_put_contents(
1257  $tmp . '/data/missing.txt',
1258  'This space intentionally left blank.\n'
1259  );
1260  file_put_contents(
1261  $tmp . "/fetch.txt",
1262  "http://www.google.com - data/google/index.html\n" .
1263  "http://www.yahoo.com - data/yahoo/index.html\n"
1264  );
1265  $bag = new BagIt($tmp);
1266 
1267  $bag->update();
1268 
1269  $bag->package($tmp . '/../bagtmp1.zip', 'zip');
1270  $this->assertFileExists($tmp . '/../bagtmp1.zip');
1271 
1272  $bag->package($tmp . '/../bagtmp2', 'zip');
1273  $this->assertFileExists($tmp . '/../bagtmp2.zip');
1274 
1275  // TODO: Test the contents of the package.
1276 
1277  }
1278  catch (Exception $e)
1279  {
1280  rrmdir($tmp);
1281  throw $e;
1282  }
1283  rrmdir($tmp);
1284  }
1285 
1286  public function testPackageTGz()
1287  {
1288  $tmp = tmpdir();
1289  try
1290  {
1291  mkdir($tmp);
1292  mkdir($tmp . '/data');
1293  file_put_contents(
1294  $tmp . '/data/missing.txt',
1295  'This space intentionally left blank.\n'
1296  );
1297  file_put_contents(
1298  $tmp . "/fetch.txt",
1299  "http://www.google.com - data/google/index.html\n" .
1300  "http://www.yahoo.com - data/yahoo/index.html\n"
1301  );
1302  $bag = new BagIt($tmp);
1303 
1304  $bag->update();
1305 
1306  $bag->package($tmp . '/../bagtmp1.tgz', 'tgz');
1307  $this->assertFileExists($tmp . '/../bagtmp1.tgz');
1308  rename("{$tmp}/../bagtmp1.tgz", "/tmp/bagtmp1.tgz");
1309 
1310  $bag->package($tmp . '/../bagtmp2', 'tgz');
1311  $this->assertFileExists($tmp . '/../bagtmp2.tgz');
1312  rename("{$tmp}/../bagtmp2.tgz", "/tmp/bagtmp2.tgz");
1313 
1314  // TODO: Test the contents of the package.
1315 
1316  }
1317  catch (Exception $e)
1318  {
1319  rrmdir($tmp);
1320  throw $e;
1321  }
1322  rrmdir($tmp);
1323  }
1324 
1325  public function testEmptyDirectory()
1326  {
1327  $tmp = tmpdir();
1328  try
1329  {
1330  mkdir($tmp);
1331 
1332  $bag = new BagIt($tmp);
1333  $this->assertFileExists("$tmp/bagit.txt");
1334  $this->assertFileExists("$tmp/manifest-sha1.txt");
1335  $this->assertFileExists("$tmp/bag-info.txt");
1336  $this->assertFileNotExists("$tmp/fetch.txt");
1337  $this->assertFileExists("$tmp/tagmanifest-sha1.txt");
1338  }
1339  catch (Exception $e)
1340  {
1341  rrmdir($tmp);
1342  throw $e;
1343  }
1344  rrmdir($tmp);
1345  }
1346 }
1347 
1348 ?>
BagItTest\testSetHashEncodingMD5
testSetHashEncodingMD5()
Definition: testbagit.php:872
BagItTest\$tmpdir
$tmpdir
Definition: testbagit.php:8
BagItTest\testConstructorInvalidBagitFile
testConstructorInvalidBagitFile()
Definition: testbagit.php:715
BagItTest\testBagInfoContructor
testBagInfoContructor()
Definition: testbagit.php:136
BagItTest
Definition: testbagit.php:6
BagItTest\testBagDirectory
testBagDirectory()
Definition: testbagit.php:31
BagItTest\testGetHashEncoding
testGetHashEncoding()
Definition: testbagit.php:866
BagItTest\testConstructorExtended
testConstructorExtended()
Definition: testbagit.php:646
BagItTest\testConstructorFetch
testConstructorFetch()
Definition: testbagit.php:668
BagItTest\testValidateChecksum
testValidateChecksum()
Definition: testbagit.php:962
BagItTest\testPackageTGz
testPackageTGz()
Definition: testbagit.php:1286
BagItTest\testBagInfoData
testBagInfoData()
Definition: testbagit.php:159
BagItTest\testTagManifest
testTagManifest()
Definition: testbagit.php:117
BagItTest\testCreateFileAddDataDir
testCreateFileAddDataDir()
Definition: testbagit.php:1216
BagItTest\testUpdateNewFiles
testUpdateNewFiles()
Definition: testbagit.php:1083
BagItTest\testAddFileAddDataDir
testAddFileAddDataDir()
Definition: testbagit.php:1186
BagItTest\testBagInfoDuplicateClearBagData
testBagInfoDuplicateClearBagData()
Definition: testbagit.php:281
BagItTest\testTagFileEncoding
testTagFileEncoding()
Definition: testbagit.php:78
BagItTest\testFetch
testFetch()
Definition: testbagit.php:122
BagItTest\testSetHashEncodingSHA1
testSetHashEncodingSHA1()
Definition: testbagit.php:878
BagItTest\testSetHashEncodingBoth
testSetHashEncodingBoth()
Definition: testbagit.php:893
BagItTest\testPackageZip
testPackageZip()
Definition: testbagit.php:1249
BagItTest\testHasBagInfoData
testHasBagInfoData()
Definition: testbagit.php:501
BagItTest\testGetBagContents
testGetBagContents()
Definition: testbagit.php:900
BagItTest\testBagInfoDuplicateData
testBagInfoDuplicateData()
Definition: testbagit.php:192
BagItTest\testCreateFileDuplicate
testCreateFileDuplicate()
Definition: testbagit.php:1230
BagItTest\testIsExtended
testIsExtended()
Definition: testbagit.php:807
BagItTest\testIsValid
testIsValid()
Definition: testbagit.php:802
BagItTest\testBagVersion
testBagVersion()
Definition: testbagit.php:56
BagItTest\testUpdateChecksums
testUpdateChecksums()
Definition: testbagit.php:1047
BagItTest\testValidateMissingBagFile
testValidateMissingBagFile()
Definition: testbagit.php:951
BagItTest\testGetBagInfoData
testGetBagInfoData()
Definition: testbagit.php:550
BagItTest\testBagInfoDuplicateSetBagData
testBagInfoDuplicateSetBagData()
Definition: testbagit.php:229
BagItTest\testUpdateCreateMissing
testUpdateCreateMissing()
Definition: testbagit.php:990
BagItTest\tearDown
tearDown()
Definition: testbagit.php:26
BagItTest\$bag
$bag
Definition: testbagit.php:9
BagItTest\testBagCompression
testBagCompression()
Definition: testbagit.php:613
BagItTest\setUp
setUp()
Definition: testbagit.php:20
BagItTest\testBagInfoFile
testBagInfoFile()
Definition: testbagit.php:127
BagItTest\testConstructorTGz
testConstructorTGz()
Definition: testbagit.php:793
BagItTest\testUpdateExtended
testUpdateExtended()
Definition: testbagit.php:1146
BagItTest\testEmptyDirectory
testEmptyDirectory()
Definition: testbagit.php:1325
BagItTest\testConstructorDir
testConstructorDir()
Definition: testbagit.php:775
BagItTest\testBagInfoWrite
testBagInfoWrite()
Definition: testbagit.php:393
BagItTest\testManifest
testManifest()
Definition: testbagit.php:112
BagItTest\testBagInfoDuplicateDataWrite
testBagInfoDuplicateDataWrite()
Definition: testbagit.php:338
BagItTest\testGetBagErrors
testGetBagErrors()
Definition: testbagit.php:932
BagItTest\testExtended
testExtended()
Definition: testbagit.php:36
BagItTest\testBagInfoWriteTagCase
testBagInfoWriteTagCase()
Definition: testbagit.php:446
BagItTest\testCreateFile
testCreateFile()
Definition: testbagit.php:1205
BagItTest\testUpdateSanitize
testUpdateSanitize()
Definition: testbagit.php:1011
BagItTest\testConstructorZip
testConstructorZip()
Definition: testbagit.php:784
BagItTest\testUpdateDeletedFiles
testUpdateDeletedFiles()
Definition: testbagit.php:1115
BagItTest\testAddFile
testAddFile()
Definition: testbagit.php:1167
BagItTest\testBagInfoNull
testBagInfoNull()
Definition: testbagit.php:492
BagItTest\testGetBagInfo
testGetBagInfo()
Definition: testbagit.php:845
BagItTest\testSetBagInfoData
testSetBagInfoData()
Definition: testbagit.php:599
BagItTest\testSetHashEncodingERR
testSetHashEncodingERR()
Definition: testbagit.php:888
BagItTest\testGetBagErrorsValidate
testGetBagErrorsValidate()
Definition: testbagit.php:943
BagIt
Definition: bagit.php:69
BagItTest\testBagErrors
testBagErrors()
Definition: testbagit.php:618
BagItTest\testAddFileMissing
testAddFileMissing()
Definition: testbagit.php:1243
BagItTest\testConstructorValidate
testConstructorValidate()
Definition: testbagit.php:624
BagItTest\testGetDataDirectory
testGetDataDirectory()
Definition: testbagit.php:860
BagItTest\testBagitFile
testBagitFile()
Definition: testbagit.php:98