PopTest\Archive\TarTest::testTbz2Extract PHP Метод

testTbz2Extract() публичный Метод

public testTbz2Extract ( )
    public function testTbz2Extract()
    {
        $tar = false;
        $includePath = explode(PATH_SEPARATOR, get_include_path());
        foreach ($includePath as $path) {
            if (file_exists($path . DIRECTORY_SEPARATOR . 'Archive' . DIRECTORY_SEPARATOR . 'Tar.php')) {
                $tar = true;
            }
        }
        if ($tar && function_exists('bzopen')) {
            $a = new Archive(__DIR__ . '/../tmp/test.tar');
            $a->addFiles(__DIR__ . '/../tmp');
            $a->compress('bz2');
            chmod(__DIR__ . '/../tmp/test.tar.bz2', 0777);
            unset($a);
            $a = new Archive(__DIR__ . '/../tmp/test.tar.bz2');
            mkdir(__DIR__ . '/../tmp/test');
            chmod(__DIR__ . '/../tmp/test', 0777);
            $a->extract(__DIR__ . '/../tmp/test');
            $dir = new Dir(__DIR__ . '/../tmp/test');
            $this->assertGreaterThan(0, count($dir->getFiles()));
            $dir->emptyDir();
            rmdir(__DIR__ . '/../tmp/test');
            if (file_exists(__DIR__ . '/../tmp/test.tar')) {
                unlink(__DIR__ . '/../tmp/test.tar');
            }
            if (file_exists(__DIR__ . '/../tmp/test.tar.bz2')) {
                unlink(__DIR__ . '/../tmp/test.tar.bz2');
            }
        }
    }