Finish tar, tar.gz, tar.bz2 and tests
modifié: core/lib/Thelia/Config/Resources/config.xml modifié: core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiveBuilder.php modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilder.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilder.php modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php modifié: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php nouveau fichier: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilderTest.php nouveau fichier: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilderTest.php modifié: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php
This commit is contained in:
@@ -150,18 +150,18 @@
|
|||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- tar -->
|
<!-- tar -->
|
||||||
<service id="thelia.manager.tar_archive_builder" class="Thelia\Core\FileFormat\Archive\ArchiveBuilder\ZipArchiveBuilder">
|
<service id="thelia.manager.tar_archive_builder" class="Thelia\Core\FileFormat\Archive\ArchiveBuilder\TarArchiveBuilder">
|
||||||
<tag name="thelia.manager.archive_builder" />
|
<tag name="thelia.manager.archive_builder" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- tar.gz -->
|
<!-- tar.gz -->
|
||||||
<service id="thelia.manager.tar_gz_archive_builder" class="Thelia\Core\FileFormat\Archive\ArchiveBuilder\ZipArchiveBuilder">
|
<service id="thelia.manager.tar_gz_archive_builder" class="Thelia\Core\FileFormat\Archive\ArchiveBuilder\TarGzArchiveBuilder">
|
||||||
<argument id="compressionType" type="string">gz</argument>
|
<argument id="compressionType" type="string">gz</argument>
|
||||||
<tag name="thelia.manager.archive_builder" />
|
<tag name="thelia.manager.archive_builder" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- tar.bz2 -->
|
<!-- tar.bz2 -->
|
||||||
<service id="thelia.manager.tar_bz2_archive_builder" class="Thelia\Core\FileFormat\Archive\ArchiveBuilder\ZipArchiveBuilder">
|
<service id="thelia.manager.tar_bz2_archive_builder" class="Thelia\Core\FileFormat\Archive\ArchiveBuilder\TarBz2ArchiveBuilder">
|
||||||
<argument id="compressionType" type="string">bz2</argument>
|
<argument id="compressionType" type="string">bz2</argument>
|
||||||
<tag name="thelia.manager.archive_builder" />
|
<tag name="thelia.manager.archive_builder" />
|
||||||
</service>
|
</service>
|
||||||
|
|||||||
@@ -62,12 +62,18 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected $cacheDir;
|
protected $cacheDir;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $environment;
|
protected $environment;
|
||||||
|
|
||||||
=======
|
=======
|
||||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||||
|
=======
|
||||||
|
/** @var string */
|
||||||
|
protected $environment;
|
||||||
|
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->translator = Translator::getInstance();
|
$this->translator = Translator::getInstance();
|
||||||
@@ -244,10 +250,16 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder
|
|||||||
{
|
{
|
||||||
return $this->cacheFile;
|
return $this->cacheFile;
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $environment
|
* @param string $environment
|
||||||
|
=======
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $environment
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* Sets the execution environment of the Kernel,
|
* Sets the execution environment of the Kernel,
|
||||||
@@ -257,6 +269,7 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder
|
|||||||
{
|
{
|
||||||
$this->environment = $environment;
|
$this->environment = $environment;
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
}
|
}
|
||||||
=======
|
=======
|
||||||
}
|
}
|
||||||
@@ -267,3 +280,6 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder
|
|||||||
=======
|
=======
|
||||||
}
|
}
|
||||||
>>>>>>> Finish implementing and testing zip
|
>>>>>>> Finish implementing and testing zip
|
||||||
|
=======
|
||||||
|
}
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
/** @var \Thelia\Log\Tlog */
|
/** @var \Thelia\Log\Tlog */
|
||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
=======
|
=======
|
||||||
function __construct($compressionType = null)
|
function __construct($compressionType = null)
|
||||||
@@ -90,6 +91,8 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
=======
|
=======
|
||||||
|
|
||||||
>>>>>>> Finish Tar archive builder
|
>>>>>>> Finish Tar archive builder
|
||||||
|
=======
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
if ($this->tar instanceof \PharData) {
|
if ($this->tar instanceof \PharData) {
|
||||||
@@ -433,6 +436,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
*
|
*
|
||||||
* Loads an archive
|
* Loads an archive
|
||||||
*/
|
*/
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
public function loadArchive($pathToArchive, $isOnline = false)
|
public function loadArchive($pathToArchive, $isOnline = false)
|
||||||
{
|
{
|
||||||
@@ -463,11 +467,21 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
$instance->setCacheFile($instance->generateCacheFile($environment))
|
$instance->setCacheFile($instance->generateCacheFile($environment))
|
||||||
->copyFile($pathToArchive, $instance->getCacheFile(), $isOnline);
|
->copyFile($pathToArchive, $instance->getCacheFile(), $isOnline);
|
||||||
>>>>>>> Fix FileDownloader test
|
>>>>>>> Fix FileDownloader test
|
||||||
|
=======
|
||||||
|
public function loadArchive($pathToArchive, $isOnline = false)
|
||||||
|
{
|
||||||
|
$tar = clone $this;
|
||||||
|
|
||||||
|
$tar
|
||||||
|
->setCacheFile($tar->generateCacheFile($this->environment))
|
||||||
|
->copyFile($pathToArchive, $tar->getCacheFile(), $isOnline);
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This throws TarArchiveBuilderException if
|
* This throws TarArchiveBuilderException if
|
||||||
* the archive is not valid.
|
* the archive is not valid.
|
||||||
*/
|
*/
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
|
||||||
return $tar->setEnvironment($tar->environment);
|
return $tar->setEnvironment($tar->environment);
|
||||||
@@ -476,6 +490,9 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
|
|
||||||
return $instance;
|
return $instance;
|
||||||
>>>>>>> Finish implementing and testing zip
|
>>>>>>> Finish implementing and testing zip
|
||||||
|
=======
|
||||||
|
return $tar->setEnvironment($tar->environment);
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -566,6 +583,9 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
public function setEnvironment($environment)
|
public function setEnvironment($environment)
|
||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
if (empty($environment)) {
|
if (empty($environment)) {
|
||||||
throw new \ErrorException(
|
throw new \ErrorException(
|
||||||
$this->translator->trans(
|
$this->translator->trans(
|
||||||
@@ -574,8 +594,11 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
=======
|
=======
|
||||||
>>>>>>> Finish implementing and testing zip
|
>>>>>>> Finish implementing and testing zip
|
||||||
|
=======
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
if ($this->cacheFile === null) {
|
if ($this->cacheFile === null) {
|
||||||
$cacheFile = $this->generateCacheFile($environment);
|
$cacheFile = $this->generateCacheFile($environment);
|
||||||
|
|
||||||
@@ -591,6 +614,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
try {
|
try {
|
||||||
$this->tar = new \PharData($cacheFile, null, null, static::PHAR_FORMAT);
|
$this->tar = new \PharData($cacheFile, null, null, static::PHAR_FORMAT);
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
$this->compressionEntryPoint();
|
$this->compressionEntryPoint();
|
||||||
|
|
||||||
@@ -606,6 +630,10 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
$cacheFile .= ".bz2";
|
$cacheFile .= ".bz2";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
$this->compressionEntryPoint();
|
||||||
|
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|
||||||
} catch(\BadMethodCallException $e) {
|
} catch(\BadMethodCallException $e) {
|
||||||
>>>>>>> Finish implementing and testing zip
|
>>>>>>> Finish implementing and testing zip
|
||||||
@@ -633,10 +661,14 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->cacheFile = $cacheFile;
|
$this->cacheFile = $cacheFile;
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
$this->environment = $environment;
|
$this->environment = $environment;
|
||||||
=======
|
=======
|
||||||
>>>>>>> Finish implementing and testing zip
|
>>>>>>> Finish implementing and testing zip
|
||||||
|
=======
|
||||||
|
$this->environment = $environment;
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -693,6 +725,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
return "tar";
|
return "tar";
|
||||||
=======
|
=======
|
||||||
@@ -704,6 +737,9 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
|
|
||||||
return $name;
|
return $name;
|
||||||
>>>>>>> Finish implementing and testing zip
|
>>>>>>> Finish implementing and testing zip
|
||||||
|
=======
|
||||||
|
return "tar";
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -717,11 +753,15 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
*/
|
*/
|
||||||
public function getExtension()
|
public function getExtension()
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
return "tar";
|
return "tar";
|
||||||
=======
|
=======
|
||||||
return $this->getName();
|
return $this->getName();
|
||||||
>>>>>>> Finish implementing and testing zip
|
>>>>>>> Finish implementing and testing zip
|
||||||
|
=======
|
||||||
|
return "tar";
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -735,6 +775,9 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
public function getMimeType()
|
public function getMimeType()
|
||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
return "application/x-tar";
|
return "application/x-tar";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -744,6 +787,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
* This method must be overwritten if you want to do some
|
* This method must be overwritten if you want to do some
|
||||||
* stuff to compress you archive
|
* stuff to compress you archive
|
||||||
*/
|
*/
|
||||||
|
<<<<<<< HEAD
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCompression()
|
public function getCompression()
|
||||||
@@ -760,3 +804,12 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
|
|
||||||
}
|
}
|
||||||
>>>>>>> Finish implementing and testing zip
|
>>>>>>> Finish implementing and testing zip
|
||||||
|
=======
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCompression()
|
||||||
|
{
|
||||||
|
return $this->compression;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|||||||
@@ -44,4 +44,8 @@ class TarBz2ArchiveBuilder extends TarArchiveBuilder
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
}
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|||||||
@@ -49,4 +49,8 @@ class TarGzArchiveBuilder extends TarArchiveBuilder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
}
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|||||||
@@ -373,6 +373,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
* If it's local check if the file exists and if it is redable
|
* If it's local check if the file exists and if it is redable
|
||||||
*/
|
*/
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||||
if ($isOnline) {
|
if ($isOnline) {
|
||||||
$fileDownloadCache = $this->cacheDir . DS . "download";
|
$fileDownloadCache = $this->cacheDir . DS . "download";
|
||||||
@@ -403,6 +404,9 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
=======
|
=======
|
||||||
$fileDownloadCache = $this->cacheDir . DS . "download.tmp";
|
$fileDownloadCache = $this->cacheDir . DS . "download.tmp";
|
||||||
|
=======
|
||||||
|
$fileDownloadCache = $this->cacheDir . DS . md5(uniqid()) . ".tmp";
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
$this->copyFile($filePath, $fileDownloadCache, $isOnline);
|
$this->copyFile($filePath, $fileDownloadCache, $isOnline);
|
||||||
>>>>>>> Finish implementing and testing zip
|
>>>>>>> Finish implementing and testing zip
|
||||||
|
|
||||||
@@ -421,9 +425,15 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
|
|
||||||
$this->logger->error($translatedErrorMessage);
|
$this->logger->error($translatedErrorMessage);
|
||||||
|
|
||||||
|
// if error delete the cache file
|
||||||
|
unlink($fileDownloadCache);
|
||||||
|
|
||||||
throw new \ErrorException($translatedErrorMessage);
|
throw new \ErrorException($translatedErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If not too
|
||||||
|
unlink($fileDownloadCache);
|
||||||
|
|
||||||
$this->commit();
|
$this->commit();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -714,23 +724,30 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
* @return ZipArchiveBuilder
|
* @return ZipArchiveBuilder
|
||||||
=======
|
=======
|
||||||
* @param string $pathToArchive
|
* @param string $pathToArchive
|
||||||
* @param string $environment
|
|
||||||
* @param bool $isOnline
|
* @param bool $isOnline
|
||||||
* @param FileDownloaderInterface $fileDownloader
|
* @param FileDownloaderInterface $fileDownloader
|
||||||
|
<<<<<<< HEAD
|
||||||
* @return $this
|
* @return $this
|
||||||
>>>>>>> Define archive builders and formatters
|
>>>>>>> Define archive builders and formatters
|
||||||
|
=======
|
||||||
|
* @return ZipArchiveBuilder
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
* @throws \Thelia\Exception\FileNotFoundException
|
* @throws \Thelia\Exception\FileNotFoundException
|
||||||
* @throws \Thelia\Exception\HttpUrlException
|
* @throws \Thelia\Exception\HttpUrlException
|
||||||
*
|
*
|
||||||
* Loads an archive
|
* Loads an archive
|
||||||
*/
|
*/
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
public function loadArchive($pathToArchive, $isOnline = false)
|
public function loadArchive($pathToArchive, $isOnline = false)
|
||||||
{
|
{
|
||||||
$back = $this->zip;
|
$back = $this->zip;
|
||||||
$this->zip = new \ZipArchive();
|
$this->zip = new \ZipArchive();
|
||||||
$zip = clone $this;
|
$zip = clone $this;
|
||||||
$this->zip = $back;
|
$this->zip = $back;
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
$zip->setEnvironment($this->environment);
|
$zip->setEnvironment($this->environment);
|
||||||
|
|
||||||
@@ -764,17 +781,29 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
if ($fileDownloader !== null) {
|
if ($fileDownloader !== null) {
|
||||||
$instance->setFileDownloader($fileDownloader);
|
$instance->setFileDownloader($fileDownloader);
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|
||||||
$instance->copyFile($pathToArchive, $instance->getCacheFile(), $isOnline);
|
$zip->setEnvironment($this->environment);
|
||||||
|
|
||||||
if (true !== $return = $zip->open($instance->getCacheFile())) {
|
$zip->copyFile(
|
||||||
|
$pathToArchive,
|
||||||
|
$zip->getCacheFile(),
|
||||||
|
$isOnline
|
||||||
|
);
|
||||||
|
|
||||||
|
if (true !== $return = $zip->getRawZipArchive()->open($zip->getCacheFile())) {
|
||||||
throw new ZipArchiveException(
|
throw new ZipArchiveException(
|
||||||
$instance->getZipErrorMessage($return)
|
$zip->getZipErrorMessage($return)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
return $instance;
|
return $instance;
|
||||||
>>>>>>> Define archive builders and formatters
|
>>>>>>> Define archive builders and formatters
|
||||||
|
=======
|
||||||
|
return $zip;
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -837,6 +866,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
public function setEnvironment($environment)
|
public function setEnvironment($environment)
|
||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
parent::setEnvironment($environment);
|
parent::setEnvironment($environment);
|
||||||
|
|
||||||
@@ -874,6 +904,9 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
$cacheFile .= "." . $this->getExtension();
|
$cacheFile .= "." . $this->getExtension();
|
||||||
>>>>>>> Define archive builders and formatters
|
>>>>>>> Define archive builders and formatters
|
||||||
=======
|
=======
|
||||||
|
=======
|
||||||
|
parent::setEnvironment($environment);
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
$cacheFileName = md5 (uniqid());
|
$cacheFileName = md5 (uniqid());
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
namespace Thelia\Core\FileFormat\Archive;
|
namespace Thelia\Core\FileFormat\Archive;
|
||||||
use Thelia\Tools\FileDownload\FileDownloaderInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface ArchiveBuilderInterface
|
* Interface ArchiveBuilderInterface
|
||||||
@@ -150,13 +150,15 @@ interface ArchiveBuilderInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $pathToArchive
|
* @param string $pathToArchive
|
||||||
* @param string $environment
|
|
||||||
* @param bool $isOnline
|
* @param bool $isOnline
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
>>>>>>> Define archive builders and formatters
|
>>>>>>> Define archive builders and formatters
|
||||||
=======
|
=======
|
||||||
* @param FileDownloaderInterface $fileDownloader
|
* @param FileDownloaderInterface $fileDownloader
|
||||||
>>>>>>> Finish implementing and testing zip
|
>>>>>>> Finish implementing and testing zip
|
||||||
|
=======
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
* @return $this
|
* @return $this
|
||||||
* @throws \Thelia\Exception\FileNotFoundException
|
* @throws \Thelia\Exception\FileNotFoundException
|
||||||
* @throws \Thelia\Exception\HttpUrlException
|
* @throws \Thelia\Exception\HttpUrlException
|
||||||
@@ -164,6 +166,7 @@ interface ArchiveBuilderInterface
|
|||||||
* Loads an archive
|
* Loads an archive
|
||||||
*/
|
*/
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
public function loadArchive($pathToArchive, $isOnline = false);
|
public function loadArchive($pathToArchive, $isOnline = false);
|
||||||
=======
|
=======
|
||||||
@@ -172,6 +175,9 @@ interface ArchiveBuilderInterface
|
|||||||
=======
|
=======
|
||||||
public static function loadArchive($pathToArchive, $environment, $isOnline = false, FileDownloaderInterface $fileDownloader = null);
|
public static function loadArchive($pathToArchive, $environment, $isOnline = false, FileDownloaderInterface $fileDownloader = null);
|
||||||
>>>>>>> Finish implementing and testing zip
|
>>>>>>> Finish implementing and testing zip
|
||||||
|
=======
|
||||||
|
public function loadArchive($pathToArchive, $isOnline = false);
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $pathToFile
|
* @param $pathToFile
|
||||||
@@ -193,6 +199,7 @@ interface ArchiveBuilderInterface
|
|||||||
*/
|
*/
|
||||||
public function hasDirectory($directory);
|
public function hasDirectory($directory);
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
}
|
}
|
||||||
=======
|
=======
|
||||||
@@ -206,3 +213,6 @@ interface ArchiveBuilderInterface
|
|||||||
public function setEnvironment($environment);
|
public function setEnvironment($environment);
|
||||||
}
|
}
|
||||||
>>>>>>> Define archive builders and formatters
|
>>>>>>> Define archive builders and formatters
|
||||||
|
=======
|
||||||
|
}
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|||||||
@@ -381,9 +381,8 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testLoadValidArchive()
|
public function testLoadValidArchive()
|
||||||
{
|
{
|
||||||
$tar = TarArchiveBuilder::loadArchive(
|
$tar = $this->tar->loadArchive(
|
||||||
__DIR__ . DS . "TestResources/well_formatted.tar",
|
__DIR__ . DS . "TestResources/well_formatted.tar"
|
||||||
"dev"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInstanceOf(
|
$this->assertInstanceOf(
|
||||||
@@ -401,9 +400,8 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testLoadInvalidArchive()
|
public function testLoadInvalidArchive()
|
||||||
{
|
{
|
||||||
$tar = TarArchiveBuilder::loadArchive(
|
$tar = $this->tar->loadArchive(
|
||||||
__DIR__ . DS . "TestResources/bad_formatted.tar",
|
__DIR__ . DS . "TestResources/bad_formatted.tar"
|
||||||
"dev"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,5 +510,17 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->tar->formatFilePath("//foo/bar///baz/")
|
$this->tar->formatFilePath("//foo/bar///baz/")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
}
|
}
|
||||||
>>>>>>> Finish Tar archive builder
|
>>>>>>> Finish Tar archive builder
|
||||||
|
=======
|
||||||
|
|
||||||
|
public function testCompression()
|
||||||
|
{
|
||||||
|
$this->assertEquals(
|
||||||
|
null,
|
||||||
|
$this->tar->getCompression()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|||||||
@@ -35,4 +35,8 @@ class TarBz2ArchiveBuilderTest extends TarArchiveBuilderTest
|
|||||||
$this->tar->getCompression()
|
$this->tar->getCompression()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
}
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|||||||
@@ -12,6 +12,10 @@
|
|||||||
|
|
||||||
namespace Thelia\Tests\FileFormat\Archive\ArchiveBuilder;
|
namespace Thelia\Tests\FileFormat\Archive\ArchiveBuilder;
|
||||||
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\TarGzArchiveBuilder;
|
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\TarGzArchiveBuilder;
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
use Thelia\Core\HttpFoundation\Response;
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TarGzArchiveBuilderTest
|
* Class TarGzArchiveBuilderTest
|
||||||
@@ -35,4 +39,8 @@ class TarGzArchiveBuilderTest extends TarArchiveBuilderTest
|
|||||||
$this->tar->getCompression()
|
$this->tar->getCompression()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
}
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->zip = new ZipArchiveBuilder();
|
$this->zip = new ZipArchiveBuilder();
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
$this->zip->setEnvironment("dev");
|
$this->zip->setEnvironment("dev");
|
||||||
|
|
||||||
@@ -50,6 +51,12 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
__DIR__ . DS . "TestResources/well_formatted.zip",
|
__DIR__ . DS . "TestResources/well_formatted.zip",
|
||||||
"dev"
|
"dev"
|
||||||
>>>>>>> Define archive builders and formatters
|
>>>>>>> Define archive builders and formatters
|
||||||
|
=======
|
||||||
|
$this->zip->setEnvironment("dev");
|
||||||
|
|
||||||
|
$this->loadedZip = $this->zip->loadArchive(
|
||||||
|
__DIR__ . DS . "TestResources/well_formatted.zip"
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,12 +349,16 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testLoadValidZip()
|
public function testLoadValidZip()
|
||||||
{
|
{
|
||||||
$loadedZip = $this->zip->loadArchive(
|
$loadedZip = $this->zip->loadArchive(
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
__DIR__ . DS . "TestResources/well_formatted.zip"
|
__DIR__ . DS . "TestResources/well_formatted.zip"
|
||||||
=======
|
=======
|
||||||
__DIR__ . DS . "TestResources/well_formatted.zip",
|
__DIR__ . DS . "TestResources/well_formatted.zip",
|
||||||
"dev"
|
"dev"
|
||||||
>>>>>>> Define archive builders and formatters
|
>>>>>>> Define archive builders and formatters
|
||||||
|
=======
|
||||||
|
__DIR__ . DS . "TestResources/well_formatted.zip"
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInstanceOf(
|
$this->assertInstanceOf(
|
||||||
@@ -371,12 +382,16 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testLoadNotValidZip()
|
public function testLoadNotValidZip()
|
||||||
{
|
{
|
||||||
$this->zip->loadArchive(
|
$this->zip->loadArchive(
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
__DIR__ . DS . "TestResources/bad_formatted.zip"
|
__DIR__ . DS . "TestResources/bad_formatted.zip"
|
||||||
=======
|
=======
|
||||||
__DIR__ . DS . "TestResources/bad_formatted.zip",
|
__DIR__ . DS . "TestResources/bad_formatted.zip",
|
||||||
"dev"
|
"dev"
|
||||||
>>>>>>> Define archive builders and formatters
|
>>>>>>> Define archive builders and formatters
|
||||||
|
=======
|
||||||
|
__DIR__ . DS . "TestResources/bad_formatted.zip"
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,17 +401,22 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testLoadNotExistingFile()
|
public function testLoadNotExistingFile()
|
||||||
{
|
{
|
||||||
$this->zip->loadArchive(
|
$this->zip->loadArchive(
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
__DIR__ . DS . "TestResources/this_file_doesn_t_exist.zip"
|
__DIR__ . DS . "TestResources/this_file_doesn_t_exist.zip"
|
||||||
=======
|
=======
|
||||||
__DIR__ . DS . "TestResources/this_file_doesn_t_exist.zip",
|
__DIR__ . DS . "TestResources/this_file_doesn_t_exist.zip",
|
||||||
"dev"
|
"dev"
|
||||||
>>>>>>> Define archive builders and formatters
|
>>>>>>> Define archive builders and formatters
|
||||||
|
=======
|
||||||
|
__DIR__ . DS . "TestResources/this_file_doesn_t_exist.zip"
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoadOnlineAvailableAndValidFile()
|
public function testLoadOnlineAvailableAndValidFile()
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
||||||
|
|
||||||
@@ -410,6 +430,13 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
true,
|
true,
|
||||||
FakeFileDownloader::getInstance()
|
FakeFileDownloader::getInstance()
|
||||||
>>>>>>> Define archive builders and formatters
|
>>>>>>> Define archive builders and formatters
|
||||||
|
=======
|
||||||
|
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
||||||
|
|
||||||
|
$this->zip->loadArchive(
|
||||||
|
__DIR__ . DS . "TestResources/well_formatted.zip",
|
||||||
|
true
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,6 +454,7 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testLoadOnlineAvailableAndNotValidFile()
|
public function testLoadOnlineAvailableAndNotValidFile()
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
||||||
|
|
||||||
@@ -440,6 +468,13 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
true,
|
true,
|
||||||
FakeFileDownloader::getInstance()
|
FakeFileDownloader::getInstance()
|
||||||
>>>>>>> Define archive builders and formatters
|
>>>>>>> Define archive builders and formatters
|
||||||
|
=======
|
||||||
|
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
||||||
|
|
||||||
|
$this->zip->loadArchive(
|
||||||
|
__DIR__ . DS . "TestResources/bad_formatted.zip",
|
||||||
|
true
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,6 +483,7 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testLoadOnlineNotExistingFile()
|
public function testLoadOnlineNotExistingFile()
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
||||||
|
|
||||||
@@ -461,6 +497,13 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
true,
|
true,
|
||||||
FakeFileDownloader::getInstance()
|
FakeFileDownloader::getInstance()
|
||||||
>>>>>>> Define archive builders and formatters
|
>>>>>>> Define archive builders and formatters
|
||||||
|
=======
|
||||||
|
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
||||||
|
|
||||||
|
$this->zip->loadArchive(
|
||||||
|
__DIR__ . DS . "TestResources/this_file_doesn_t_exist.zip",
|
||||||
|
true
|
||||||
|
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user