Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing up UT's

  • Loading branch information...
commit 5e1db7e9922e1fa0e8dfaffdd469540069a6eb98 1 parent cfc62b2
@dongilbert authored
View
7 vendor/Joomla/Archive/Archive.php
@@ -42,7 +42,7 @@ class Archive implements LoggerAwareInterface
* @var mixed Array or object that implements \ArrayAccess
* @since 1.0
*/
- protected $options = array();
+ public $options = array();
/**
* Create a new Archive object.
@@ -73,6 +73,7 @@ public function extract($archivename, $extractdir)
$result = false;
$ext = pathinfo($archivename, PATHINFO_EXTENSION);
$filename = pathinfo($archivename, PATHINFO_FILENAME);
+ $path = pathinfo($archivename, PATHINFO_DIRNAME);
switch ($ext)
{
@@ -105,7 +106,7 @@ public function extract($archivename, $extractdir)
else
{
Folder::create($path);
- $result = File::copy($tmpfname, $path . '/' . $filename, null, 1);
+ $result = File::copy($tmpfname, $extractdir, null, 1);
}
@unlink($tmpfname);
@@ -133,7 +134,7 @@ public function extract($archivename, $extractdir)
else
{
Folder::create($path);
- $result = File::copy($tmpfname, $path . '/' . $filename, null, 1);
+ $result = File::copy($tmpfname, $extractdir, null, 1);
}
@unlink($tmpfname);
View
1  vendor/Joomla/Archive/Gzip.php
@@ -138,6 +138,7 @@ public function extract($archive, $destination)
$output->close();
$input->close();
}
+
return true;
}
View
66 vendor/Joomla/Archive/Tests/ArchiveTest.php
@@ -11,7 +11,6 @@
use Joomla\Archive\Tar as ArchiveTar;
use Joomla\Archive\Gzip as ArchiveGzip;
use Joomla\Archive\Bzip2 as ArchiveBzip2;
-use Joomla\Factory;
/**
* Test class for Joomla\Archive\Archive.
@@ -20,7 +19,8 @@
*/
class ArchiveTest extends \PHPUnit_Framework_TestCase
{
- protected static $outputPath;
+ protected $fixture;
+ protected $outputPath;
/**
* Sets up the fixture.
@@ -33,12 +33,14 @@ protected function setUp()
{
parent::setUp();
- self::$outputPath = __DIR__ . '/output';
+ $this->outputPath = __DIR__ . '/output';
- if (!is_dir(self::$outputPath))
+ if (!is_dir($this->outputPath))
{
- mkdir(self::$outputPath, 0777);
+ mkdir($this->outputPath, 0777);
}
+
+ $this->fixture = new Archive(array('tmp_path' => '/tmp'));
}
/**
@@ -50,7 +52,7 @@ protected function setUp()
*/
public function testExtractZip()
{
- if (!is_dir(self::$outputPath))
+ if (!is_dir($this->outputPath))
{
$this->markTestSkipped("Couldn't create folder.");
@@ -64,12 +66,12 @@ public function testExtractZip()
return;
}
- Archive::extract(__DIR__ . '/logo.zip', self::$outputPath);
- $this->assertTrue(is_file(self::$outputPath . '/logo-zip.png'));
+ $this->fixture->extract(__DIR__ . '/logo.zip', $this->outputPath);
+ $this->assertTrue(is_file($this->outputPath . '/logo-zip.png'));
- if (is_file(self::$outputPath . '/logo-zip.png'))
+ if (is_file($this->outputPath . '/logo-zip.png'))
{
- unlink(self::$outputPath . '/logo-zip.png');
+ unlink($this->outputPath . '/logo-zip.png');
}
}
@@ -82,7 +84,7 @@ public function testExtractZip()
*/
public function testExtractTar()
{
- if (!is_dir(self::$outputPath))
+ if (!is_dir($this->outputPath))
{
$this->markTestSkipped("Couldn't create folder.");
@@ -96,12 +98,12 @@ public function testExtractTar()
return;
}
- Archive::extract(__DIR__ . '/logo.tar', self::$outputPath);
- $this->assertTrue(is_file(self::$outputPath . '/logo-tar.png'));
+ $this->fixture->extract(__DIR__ . '/logo.tar', $this->outputPath);
+ $this->assertTrue(is_file($this->outputPath . '/logo-tar.png'));
- if (is_file(self::$outputPath . '/logo-tar.png'))
+ if (is_file($this->outputPath . '/logo-tar.png'))
{
- unlink(self::$outputPath . '/logo-tar.png');
+ unlink($this->outputPath . '/logo-tar.png');
}
}
@@ -114,14 +116,14 @@ public function testExtractTar()
*/
public function testExtractGzip()
{
- if (!is_dir(self::$outputPath))
+ if (!is_dir($this->outputPath))
{
$this->markTestSkipped("Couldn't create folder.");
return;
}
- if (!is_writable(self::$outputPath) || !is_writable(Factory::getConfig()->get('tmp_path')))
+ if (!is_writable($this->outputPath) || !is_writable($this->fixture->options['tmp_path']))
{
$this->markTestSkipped("Folder not writable.");
@@ -135,12 +137,12 @@ public function testExtractGzip()
return;
}
- Archive::extract(__DIR__ . '/logo.gz', self::$outputPath . '/logo-gz.png');
- $this->assertTrue(is_file(self::$outputPath . '/logo-gz.png'));
+ $this->fixture->extract(__DIR__ . '/logo.gz', $this->outputPath . '/logo-gz.png');
+ $this->assertTrue(is_file($this->outputPath . '/logo-gz.png'));
- if (is_file(self::$outputPath . '/logo-gz.png'))
+ if (is_file($this->outputPath . '/logo-gz.png'))
{
- unlink(self::$outputPath . '/logo-gz.png');
+ unlink($this->outputPath . '/logo-gz.png');
}
}
@@ -153,14 +155,14 @@ public function testExtractGzip()
*/
public function testExtractBzip2()
{
- if (!is_dir(self::$outputPath))
+ if (!is_dir($this->outputPath))
{
$this->markTestSkipped("Couldn't create folder.");
return;
}
- if (!is_writable(self::$outputPath) || !is_writable(Factory::getConfig()->get('tmp_path')))
+ if (!is_writable($this->outputPath) || !is_writable($this->fixture->options['tmp_path']))
{
$this->markTestSkipped("Folder not writable.");
@@ -174,12 +176,12 @@ public function testExtractBzip2()
return;
}
- Archive::extract(__DIR__ . '/logo.bz2', self::$outputPath . '/logo-bz2.png');
- $this->assertTrue(is_file(self::$outputPath . '/logo-bz2.png'));
+ $this->fixture->extract(__DIR__ . '/logo.bz2', $this->outputPath . '/logo-bz2.png');
+ $this->assertTrue(is_file($this->outputPath . '/logo-bz2.png'));
- if (is_file(self::$outputPath . '/logo-bz2.png'))
+ if (is_file($this->outputPath . '/logo-bz2.png'))
{
- unlink(self::$outputPath . '/logo-bz2.png');
+ unlink($this->outputPath . '/logo-bz2.png');
}
}
@@ -192,13 +194,13 @@ public function testExtractBzip2()
*/
public function testGetAdapter()
{
- $zip = Archive::getAdapter('zip');
+ $zip = $this->fixture->getAdapter('zip');
$this->assertInstanceOf('Joomla\\Archive\\Zip', $zip);
- $bzip2 = Archive::getAdapter('bzip2');
+ $bzip2 = $this->fixture->getAdapter('bzip2');
$this->assertInstanceOf('Joomla\\Archive\\Bzip2', $bzip2);
- $gzip = Archive::getAdapter('gzip');
+ $gzip = $this->fixture->getAdapter('gzip');
$this->assertInstanceOf('Joomla\\Archive\\Gzip', $gzip);
- $tar = Archive::getAdapter('tar');
+ $tar = $this->fixture->getAdapter('tar');
$this->assertInstanceOf('Joomla\\Archive\\Tar', $tar);
}
@@ -212,6 +214,6 @@ public function testGetAdapter()
*/
public function testGetAdapterException()
{
- $zip = Archive::getAdapter('unknown');
+ $zip = $this->fixture->getAdapter('unknown');
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.