ZipTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Gaufrette\Functional\Adapter;
  3. use Gaufrette\Adapter\Zip;
  4. use Gaufrette\Filesystem;
  5. class ZipTest extends FunctionalTestCase
  6. {
  7. public function setUp()
  8. {
  9. if (!extension_loaded('zip')) {
  10. return $this->markTestSkipped('The zip extension is not available.');
  11. } elseif (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
  12. $this->markTestSkipped('Zip adapter is not supported on Windows.');
  13. }
  14. @touch(__DIR__ . '/test.zip');
  15. $this->filesystem = new Filesystem(new Zip(__DIR__ . '/test.zip'));
  16. }
  17. public function tearDown()
  18. {
  19. parent::tearDown();
  20. @unlink(__DIR__ . '/test.zip');
  21. }
  22. /**
  23. * @test
  24. * @expectedException \RuntimeException
  25. * @group functional
  26. */
  27. public function shouldNotAcceptInvalidZipArchive()
  28. {
  29. new Zip(__FILE__);
  30. }
  31. /**
  32. * @test
  33. * @group functional
  34. */
  35. public function shouldCreateNewZipArchive()
  36. {
  37. $tmp = tempnam(sys_get_temp_dir(), uniqid());
  38. $za = new Zip($tmp);
  39. $this->assertFileExists($tmp);
  40. return $za;
  41. }
  42. }