3 * This file is part of vfsStream.
5 * For the full copyright and license information, please view the LICENSE
6 * file that was distributed with this source code.
8 * @package org\bovigo\vfs
10 namespace org\bovigo\vfs;
12 * Test for org\bovigo\vfs\vfsStreamWrapper in conjunction with ext/zip.
16 class vfsStreamZipTestCase extends \PHPUnit_Framework_TestCase
19 * set up test environment
21 public function setUp()
23 if (extension_loaded('zip') === false) {
24 $this->markTestSkipped('No ext/zip installed, skipping test.');
27 $this->markTestSkipped('Zip extension can not work with vfsStream urls.');
29 vfsStreamWrapper::register();
30 vfsStreamWrapper::setRoot(vfsStream::newDirectory('root'));
37 public function createZipArchive()
39 $zip = new ZipArchive();
40 $this->assertTrue($zip->open(vfsStream::url('root/test.zip'), ZipArchive::CREATE));
41 $this->assertTrue($zip->addFromString("testfile1.txt", "#1 This is a test string added as testfile1.txt.\n"));
42 $this->assertTrue($zip->addFromString("testfile2.txt", "#2 This is a test string added as testfile2.txt.\n"));
43 $zip->setArchiveComment('a test');
45 $this->assertTrue($zip->close());
46 var_dump($zip->getStatusString());
47 var_dump($zip->close());
48 var_dump($zip->getStatusString());
50 var_dump(file_exists(vfsStream::url('root/test.zip')));