ZipTest.php 1001 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. }
  12. @touch(__DIR__ . '/test.zip');
  13. $this->filesystem = new Filesystem(new Zip(__DIR__ . '/test.zip'));
  14. }
  15. public function tearDown()
  16. {
  17. parent::tearDown();
  18. @unlink(__DIR__ . '/test.zip');
  19. }
  20. /**
  21. * @test
  22. * @expectedException \RuntimeException
  23. * @group functional
  24. */
  25. public function shouldNotAcceptInvalidZipArchive()
  26. {
  27. new Zip(__FILE__);
  28. }
  29. /**
  30. * @test
  31. * @group functional
  32. */
  33. public function shouldCreateNewZipArchive()
  34. {
  35. $tmp = tempnam(sys_get_temp_dir(), uniqid());
  36. $za = new Zip($tmp);
  37. $this->assertFileExists($tmp);
  38. return $za;
  39. }
  40. }