e87e25cdf60359b65103ba55baf5ae03e2f0fc98
[yaffs-website] / vendor / mikey179 / vfsStream / src / test / php / org / bovigo / vfs / vfsStreamZipTestCase.php
1 <?php
2 /**
3  * This file is part of vfsStream.
4  *
5  * For the full copyright and license information, please view the LICENSE
6  * file that was distributed with this source code.
7  *
8  * @package  org\bovigo\vfs
9  */
10 namespace org\bovigo\vfs;
11 /**
12  * Test for org\bovigo\vfs\vfsStreamWrapper in conjunction with ext/zip.
13  *
14  * @group  zip
15  */
16 class vfsStreamZipTestCase extends \PHPUnit_Framework_TestCase
17 {
18     /**
19      * set up test environment
20      */
21     public function setUp()
22     {
23         if (extension_loaded('zip') === false) {
24             $this->markTestSkipped('No ext/zip installed, skipping test.');
25         }
26
27         $this->markTestSkipped('Zip extension can not work with vfsStream urls.');
28
29         vfsStreamWrapper::register();
30         vfsStreamWrapper::setRoot(vfsStream::newDirectory('root'));
31
32     }
33
34     /**
35      * @test
36      */
37     public function createZipArchive()
38     {
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');
44         var_dump($zip);
45         $this->assertTrue($zip->close());
46         var_dump($zip->getStatusString());
47         var_dump($zip->close());
48         var_dump($zip->getStatusString());
49         var_dump($zip);
50         var_dump(file_exists(vfsStream::url('root/test.zip')));
51     }
52 }