Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

tar instead of tar.gz, new abstract dumpertest class

  • Loading branch information...
commit 1de018ee120fe04905845d186a9d73f769fec03a 1 parent 064d570
Ulf Harnhammar authored
View
8 src/Composer/Package/Dumper/TarGzDumper.php → src/Composer/Package/Dumper/TarDumper.php
@@ -19,15 +19,15 @@
/**
* @author Ulf Härnhammar <ulfharn@gmail.com>
*/
-class TarGzDumper extends BaseDumper
+class TarDumper extends BaseDumper
{
- protected $format = 'tar.gz';
+ protected $format = 'tar';
public function dump(PackageInterface $package)
{
$workDir = $this->getAndEnsureWorkDirectory($package);
- $fileName = $this->getFilename($package, 'tar.gz');
+ $fileName = $this->getFilename($package, 'tar');
$sourceType = $package->getSourceType();
$sourceRef = $package->getSourceReference();
@@ -43,7 +43,7 @@ public function dump(PackageInterface $package)
case 'svn':
$dir = $workDir . (substr($sourceRef, 0, 1) !== '/')?'/':'' . $sourceRef;
$this->downloadSvn($package, $workDir);
- $this->package($fileName, $dir, \Phar::GZ);
+ $this->package($fileName, $dir, \Phar::TAR);
break;
default:
throw new \InvalidArgumentException("Unable to handle repositories of type '{$sourceType}'.");
View
25 .../Composer/Test/Package/Dumper/TarGzDumperTest.php → tests/Composer/Test/Package/Dumper/DumperTest.php
@@ -11,40 +11,23 @@
namespace Composer\Test\Package\Dumper;
-use Composer\Package\Dumper\TarGzDumper;
use Composer\Package\MemoryPackage;
-class TarGzDumperTest extends \PHPUnit_Framework_TestCase
+abstract class DumperTest extends \PHPUnit_Framework_TestCase
{
/**
* @todo Replace with local git repo to run offline.
*/
- public function testThis()
+ public function getPackageName()
{
$package = new MemoryPackage('lagged/Lagged_Session_SaveHandler_Memcache', '0.5.0', '0.5.0');
$package->setSourceUrl('git://github.com/lagged/Lagged_Session_SaveHandler_Memcache.git');
$package->setSourceReference('0.5.0');
$package->setSourceType('git');
- $temp = sys_get_temp_dir();
-
- $targz = new TarGzDumper($temp);
- $targz->dump($package);
-
$name = preg_replace('#[^a-z0-9_-]#', '-', $package->getUniqueName());
- $dist = sprintf('%s/%s.tar.gz',
- $temp, $name
- );
- $this->assertFileExists($dist);
- unlink($dist);
- }
-
- /**
- * @expectedException \InvalidArgumentException
- */
- public function testException()
- {
- new TarGzDumper("/totally-random-" . time());
+ $retu = array('package' => $package, 'name' => $name);
+ return $retu;
}
}
View
45 tests/Composer/Test/Package/Dumper/TarDumperTest.php
@@ -0,0 +1,45 @@
+<?php
+/*
+ * This file is part of Composer.
+ *
+ * (c) Nils Adermann <naderman@naderman.de>
+ * Jordi Boggiano <j.boggiano@seld.be>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer\Test\Package\Dumper;
+
+use Composer\Package\Dumper\TarDumper;
+
+class TarDumperTest extends DumperTest
+{
+ /**
+ * @todo Replace with local git repo to run offline.
+ */
+ public function testThis()
+ {
+ $retu = $this->getPackageName();
+ $package = $retu['package'];
+ $name = $retu['name'];
+
+ $temp = sys_get_temp_dir();
+ $tar = new TarDumper($temp);
+ $tar->dump($package);
+
+ $dist = sprintf('%s/%s.tar',
+ $temp, $name
+ );
+ $this->assertFileExists($dist);
+ unlink($dist);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testException()
+ {
+ new TarDumper("/totally-random-" . time());
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.