ExtractMembersArchiveTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Alchemy\Zippy\Functional;
  3. use Alchemy\Zippy\Archive\ArchiveInterface;
  4. class ExtractMembersArchiveTest extends FunctionalTestCase
  5. {
  6. public function testOpen()
  7. {
  8. $adapter = $this->getAdapter();
  9. $archiveFile = $this->getArchiveFileForAdapter($adapter);
  10. $archive = $adapter->open($archiveFile);
  11. return $archive;
  12. }
  13. /**
  14. * @depends testOpen
  15. */
  16. public function testExtractMembersString(ArchiveInterface $archive)
  17. {
  18. $archive->extractMembers('directory/README.md', __DIR__ . '/samples/tmp');
  19. $archive->extractMembers('directory/photo.jpg', __DIR__ . '/samples/tmp');
  20. $this->assertFileExists(__DIR__ . '/samples/tmp/directory/README.md');
  21. $this->assertFileExists(__DIR__ . '/samples/tmp/directory/photo.jpg');
  22. }
  23. /**
  24. * @depends testOpen
  25. */
  26. public function testExtractFromMember(ArchiveInterface $archive)
  27. {
  28. foreach ($archive as $file) {
  29. if (!$file->isDir()) {
  30. $file->extract(__DIR__ . '/samples/tmp/');
  31. }
  32. }
  33. $this->assertFileExists(__DIR__ . '/samples/tmp/directory/README.md');
  34. $this->assertFileExists(__DIR__ . '/samples/tmp/directory/photo.jpg');
  35. }
  36. }