diff --git a/core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiveBuilder.php index 9bfc56cc1..d709e5525 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiveBuilder.php @@ -46,7 +46,13 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder const TEMP_DIRECTORY_NAME = "archive_builder"; +<<<<<<< HEAD >>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources +======= + /** @var string */ + protected $cacheFile; + +>>>>>>> Finish implementing and testing zip /** @var \Thelia\Core\Translation\Translator */ protected $translator; @@ -84,11 +90,15 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder ); } +<<<<<<< HEAD <<<<<<< HEAD $archiveBuilderCacheDir = $this->cacheDir = $theliaCacheDir . static::TEMP_DIRECTORY_NAME; ======= $archiveBuilderCacheDir = $this->cache_dir = $theliaCacheDir . static::TEMP_DIRECTORY_NAME; >>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources +======= + $archiveBuilderCacheDir = $this->cacheDir = $theliaCacheDir . static::TEMP_DIRECTORY_NAME; +>>>>>>> Finish implementing and testing zip if (!is_dir($archiveBuilderCacheDir) && !mkdir($archiveBuilderCacheDir, 0755)) { throw new \ErrorException( @@ -105,6 +115,9 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder } <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> Finish implementing and testing zip /** * @param $pathToFile * @param $destination @@ -196,8 +209,11 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder return $this; } +<<<<<<< HEAD ======= >>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources +======= +>>>>>>> Finish implementing and testing zip public function getCacheDir() { @@ -220,11 +236,15 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder return $this->translator; } <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> Finish implementing and testing zip public function getCacheFile() { return $this->cacheFile; } +<<<<<<< HEAD /** * @param string $environment @@ -244,3 +264,6 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder ======= } >>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources +======= +} +>>>>>>> Finish implementing and testing zip diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/TarArchiveException.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/TarArchiveException.php index 3e2d583d6..9566c4eaa 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/TarArchiveException.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/TarArchiveException.php @@ -20,4 +20,8 @@ namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception; class TarArchiveException extends \Exception { +<<<<<<< HEAD } +======= +} +>>>>>>> Finish implementing and testing zip diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/ZipArchiveException.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/ZipArchiveException.php index f69375dec..24f9ddb37 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/ZipArchiveException.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/ZipArchiveException.php @@ -20,4 +20,4 @@ namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception; class ZipArchiveException extends \ErrorException { -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveException.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/ZipArchiveException.php~HEAD similarity index 94% rename from core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveException.php rename to core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/ZipArchiveException.php~HEAD index c85fce339..f69375dec 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveException.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/ZipArchiveException.php~HEAD @@ -10,7 +10,7 @@ /* file that was distributed with this source code. */ /*************************************************************************************/ -namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder; +namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception; /** * Class ZipArchiveException @@ -20,4 +20,4 @@ namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder; class ZipArchiveException extends \ErrorException { -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php index 35f9a5d55..e00a3fe93 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php @@ -13,10 +13,15 @@ namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder; use Thelia\Core\FileFormat\Archive\AbstractArchiveBuilder; use Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\TarArchiveException; +<<<<<<< HEAD use Thelia\Core\HttpFoundation\Response; use Thelia\Core\Thelia; use Thelia\Core\Translation\Translator; use Thelia\Exception\FileNotReadableException; +======= +use Thelia\Core\FileFormat\Archive\ArchiveBuilderInterface; +use Thelia\Core\Translation\Translator; +>>>>>>> Finish implementing and testing zip use Thelia\Log\Tlog; use Thelia\Tools\FileDownload\FileDownloaderInterface; @@ -47,6 +52,32 @@ class TarArchiveBuilder extends AbstractArchiveBuilder /** @var \Thelia\Log\Tlog */ protected $logger; +<<<<<<< HEAD +======= + function __construct($compressionType = null) + { + $this->translator = Translator::getInstance(); + $this->logger = Tlog::getNewInstance(); + + $supportedCompression = [ + "gz", + "bz2", + null + ]; + + if (!in_array($compressionType, $supportedCompression)) { + throw new TarArchiveException( + $this->translator->trans( + "The compression %type is not supported" + ) + ); + } + + $this->compression = $compressionType; + } + + /** +>>>>>>> Finish implementing and testing zip public function __destruct() { if ($this->tar instanceof \PharData) { @@ -54,6 +85,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder unlink($this->cacheFile); } } +<<<<<<< HEAD } /** @@ -61,6 +93,15 @@ class TarArchiveBuilder extends AbstractArchiveBuilder * @param string $directoryInArchive This is the directory where it will be stored in the archive * @param null|string $name The name of the file in the archive. if it null or empty, it keeps the same name * @param bool $isOnline +======= + }*/ + + /** + * @param string $filePath It is the path to access the file. + * @param string $directoryInArchive This is the directory where it will be stored in the archive + * @param null|string $name The name of the file in the archive. if it null or empty, it keeps the same name + * @param bool $isOnline +>>>>>>> Finish implementing and testing zip * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -80,7 +121,11 @@ class TarArchiveBuilder extends AbstractArchiveBuilder * Download the file if it is online * If it's local check if the file exists and if it is redable */ +<<<<<<< HEAD $fileDownloadCache = $this->cacheDir . DS . md5(uniqid()) . ".tmp"; +======= + $fileDownloadCache = $this->cacheDir . DS . "download.tmp"; +>>>>>>> Finish implementing and testing zip $this->copyFile($filePath, $fileDownloadCache, $isOnline); /** @@ -96,18 +141,25 @@ class TarArchiveBuilder extends AbstractArchiveBuilder $this->tar->addFile($filePath, $name); +<<<<<<< HEAD /** * And clear the download temp file */ unlink($fileDownloadCache); +======= +>>>>>>> Finish implementing and testing zip return $this; } /** * @param $content * @param $name +<<<<<<< HEAD * @param string $directoryInArchive +======= + * @param string $directoryInArchive +>>>>>>> Finish implementing and testing zip * @return mixed * @throws \ErrorException * @@ -132,7 +184,11 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } try { $this->tar->addFromString($name, $content); +<<<<<<< HEAD } catch (\Exception $e) { +======= + } catch(\Exception $e) { +>>>>>>> Finish implementing and testing zip throw new \ErrorException( $this->translator->trans( "Error while writing the file into the archive, error message: %errmes", @@ -144,6 +200,10 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } } +<<<<<<< HEAD +======= + +>>>>>>> Finish implementing and testing zip /** * @param $directoryPath * @return $this @@ -159,7 +219,11 @@ class TarArchiveBuilder extends AbstractArchiveBuilder try { $this->tar->addEmptyDir($directoryInArchive); +<<<<<<< HEAD } catch (\Exception $e) { +======= + } catch(\Exception $e) { +>>>>>>> Finish implementing and testing zip throw new \ErrorException( $this->translator->trans( "The directory %dir has not been created in the archive", @@ -175,7 +239,11 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } /** +<<<<<<< HEAD * @param string $pathToFile +======= + * @param string $pathToFile +>>>>>>> Finish implementing and testing zip * @return null|string * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -185,6 +253,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder */ public function getFileContent($pathToFile) { +<<<<<<< HEAD $pathToFile = $this->formatFilePath($pathToFile); if (!$this->hasFile($pathToFile)) { @@ -205,6 +274,12 @@ class TarArchiveBuilder extends AbstractArchiveBuilder return $content; } +======= + + } + + +>>>>>>> Finish implementing and testing zip /** * @param $pathInArchive * @return $this @@ -236,6 +311,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder * * This method return an instance of a Response with the archive as content. */ +<<<<<<< HEAD public function buildArchiveResponse($filename) { $this->tar->setMetadata("Generated by Thelia v" . Thelia::THELIA_VERSION); @@ -272,6 +348,18 @@ class TarArchiveBuilder extends AbstractArchiveBuilder * @param string $environment * @param bool $isOnline * @param FileDownloaderInterface $fileDownloader +======= + public function buildArchiveResponse() + { + + } + + /** + * @param string $pathToArchive + * @param string $environment + * @param bool $isOnline + * @param FileDownloaderInterface $fileDownloader +>>>>>>> Finish implementing and testing zip * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\HttpUrlException @@ -279,6 +367,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder * * Loads an archive */ +<<<<<<< HEAD public function loadArchive($pathToArchive, $isOnline = false) { $tar = clone $this; @@ -286,13 +375,36 @@ class TarArchiveBuilder extends AbstractArchiveBuilder $tar ->setCacheFile($tar->generateCacheFile($this->environment)) ->copyFile($pathToArchive, $tar->getCacheFile(), $isOnline); +======= + public static function loadArchive( + $pathToArchive, + $environment, + $isOnline = false, + FileDownloaderInterface $fileDownloader = null + ) { + /** @var TarArchiveBuilder $instance */ + $instance = new static(); + + if ($fileDownloader !== null) { + $instance->setFileDownloader($fileDownloader); + } + + $instance->setCacheFile($instance->getCacheFile()) + ->copyFile($pathToArchive, $isOnline); +>>>>>>> Finish implementing and testing zip /** * This throws TarArchiveBuilderException if * the archive is not valid. */ +<<<<<<< HEAD return $tar->setEnvironment($tar->environment); +======= + $instance->setEnvironment($environment); + + return $instance; +>>>>>>> Finish implementing and testing zip } /** @@ -312,19 +424,31 @@ class TarArchiveBuilder extends AbstractArchiveBuilder /** @var \PharFileInfo $fileInfo */ $fileInfo = $this->tar[$pathToFile]; +<<<<<<< HEAD if ($fileInfo->isFile()) { +======= + if($fileInfo->isFile()) { +>>>>>>> Finish implementing and testing zip $isFile = true; } /** * Catch the exception to avoid its displaying. */ +<<<<<<< HEAD } catch (\BadMethodCallException $e) {} +======= + } catch(\BadMethodCallException $e) {} +>>>>>>> Finish implementing and testing zip return $isFile; } /** +<<<<<<< HEAD * @param string $directory +======= + * @param string $directory +>>>>>>> Finish implementing and testing zip * @return bool * * Check if the archive has a directory @@ -338,19 +462,31 @@ class TarArchiveBuilder extends AbstractArchiveBuilder /** @var \PharFileInfo $fileInfo */ $fileInfo = $this->tar[$pathToDir]; +<<<<<<< HEAD if ($fileInfo->isDir()) { +======= + if($fileInfo->isDir()) { +>>>>>>> Finish implementing and testing zip $isDir = true; } /** * Catch the exception to avoid its displaying. */ +<<<<<<< HEAD } catch (\BadMethodCallException $e) {} +======= + } catch(\BadMethodCallException $e) {} +>>>>>>> Finish implementing and testing zip return $isDir; } /** +<<<<<<< HEAD * @param string $environment +======= + * @param string $environment +>>>>>>> Finish implementing and testing zip * @return $this * * Sets the execution environment of the Kernel, @@ -358,6 +494,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder */ public function setEnvironment($environment) { +<<<<<<< HEAD if (empty($environment)) { throw new \ErrorException( $this->translator->trans( @@ -366,6 +503,8 @@ class TarArchiveBuilder extends AbstractArchiveBuilder ); } +======= +>>>>>>> Finish implementing and testing zip if ($this->cacheFile === null) { $cacheFile = $this->generateCacheFile($environment); @@ -381,14 +520,33 @@ class TarArchiveBuilder extends AbstractArchiveBuilder try { $this->tar = new \PharData($cacheFile, null, null, static::PHAR_FORMAT); +<<<<<<< HEAD $this->compressionEntryPoint(); } catch (\BadMethodCallException $e) { +======= + switch ($this->compression) { + case "gz": + $this->tar = $this->tar->compress(\Phar::GZ); + $cacheFile .= ".gz"; + break; + case "bz2": + $this->tar = $this->tar->compress(\Phar::BZ2); + $cacheFile .= ".bz2"; + break; + } + + } catch(\BadMethodCallException $e) { +>>>>>>> Finish implementing and testing zip /** * This should not happen */ $errorMessage = "You have badly called the method setEnvironment twice for %file"; +<<<<<<< HEAD } catch (\UnexpectedValueException $e) { +======= + } catch(\UnexpectedValueException $e) { +>>>>>>> Finish implementing and testing zip $errorMessage = "The file %file is corrupted"; } @@ -404,13 +562,20 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } $this->cacheFile = $cacheFile; +<<<<<<< HEAD $this->environment = $environment; +======= +>>>>>>> Finish implementing and testing zip return $this; } /** +<<<<<<< HEAD * @param string $initialString +======= + * @param string $initialString +>>>>>>> Finish implementing and testing zip * @return string * * Gives a valid file path for \ZipArchive @@ -431,7 +596,11 @@ class TarArchiveBuilder extends AbstractArchiveBuilder } /** +<<<<<<< HEAD * @param string $initialString +======= + * @param string $initialString +>>>>>>> Finish implementing and testing zip * @return string * * Gives a valid directory path for \ZipArchive @@ -453,7 +622,17 @@ class TarArchiveBuilder extends AbstractArchiveBuilder */ public function getName() { +<<<<<<< HEAD return "tar"; +======= + $name = "tar"; + + if ($this->compression !== null) { + $name .= "." . $this->compression; + } + + return $name; +>>>>>>> Finish implementing and testing zip } /** @@ -467,7 +646,11 @@ class TarArchiveBuilder extends AbstractArchiveBuilder */ public function getExtension() { +<<<<<<< HEAD return "tar"; +======= + return $this->getName(); +>>>>>>> Finish implementing and testing zip } /** @@ -480,6 +663,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder */ public function getMimeType() { +<<<<<<< HEAD return "application/x-tar"; } @@ -496,3 +680,12 @@ class TarArchiveBuilder extends AbstractArchiveBuilder return $this->compression; } } +======= + return $this->compression === null ? + "application/x-tar" : + "application/x-gtar" + ; + } + +} +>>>>>>> Finish implementing and testing zip diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php index 6cf52a23d..4cee2676b 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php @@ -13,18 +13,23 @@ namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder; use Thelia\Core\FileFormat\Archive\AbstractArchiveBuilder; <<<<<<< HEAD +<<<<<<< HEAD use Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\ZipArchiveException; use Thelia\Core\HttpFoundation\Response; use Thelia\Core\Thelia; use Thelia\Exception\FileNotReadableException; ======= +======= +use Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\ZipArchiveException; +>>>>>>> Finish implementing and testing zip use Thelia\Core\HttpFoundation\Response; use Thelia\Core\Thelia; -use Thelia\Core\Translation\Translator; -use Thelia\Exception\FileNotFoundException; use Thelia\Exception\FileNotReadableException; +<<<<<<< HEAD use Thelia\Log\Tlog; >>>>>>> Define archive builders and formatters +======= +>>>>>>> Finish implementing and testing zip use Thelia\Tools\FileDownload\FileDownloaderInterface; /** @@ -53,6 +58,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder */ protected $zip; +<<<<<<< HEAD <<<<<<< HEAD public function __construct() { @@ -70,6 +76,8 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder */ protected $cacheDir; +======= +>>>>>>> Finish implementing and testing zip public function __construct() { parent::__construct(); @@ -95,6 +103,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder if ($this->zip instanceof \ZipArchive) { @$this->zip->close(); +<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD if (file_exists($this->cacheFile)) { @@ -107,6 +116,10 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder if (file_exists($this->zipCacheFile)) { unlink($this->zipCacheFile); >>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources +======= + if (file_exists($this->cacheFile)) { + unlink($this->cacheFile); +>>>>>>> Finish implementing and testing zip } } } @@ -129,7 +142,11 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException +<<<<<<< HEAD >>>>>>> Define archive builders and formatters +======= + * @throws \ErrorException +>>>>>>> Finish implementing and testing zip * * This methods adds a file in the archive. * If the file is local, $isOnline must be false, @@ -137,6 +154,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder */ public function addFile($filePath, $directoryInArchive = null, $name = null, $isOnline = false) { +<<<<<<< HEAD <<<<<<< HEAD $directoryInArchive = $this->formatDirectoryPath($directoryInArchive); @@ -243,16 +261,19 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder if (!empty($directoryInArchive)) { ======= +======= + $directoryInArchive = $this->formatDirectoryPath($directoryInArchive); + +>>>>>>> Finish implementing and testing zip /** * Add empty directory if it doesn't exist */ - if (empty($directoryInArchive) || preg_match("#^\/+$#", $directoryInArchive)) { - $directoryInArchive = ""; - } if(!empty($directoryInArchive)) { - $directoryInArchive = $this->getDirectoryPath($directoryInArchive); + $this->addDirectory($directoryInArchive); + } +<<<<<<< HEAD >>>>>>> Define archive builders and formatters if (!$this->zip->addEmptyDir($directoryInArchive)) { throw new \ErrorException( @@ -264,6 +285,10 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder ) ); } +======= + if (empty($name) || !is_scalar($name)) { + $name = basename($filePath); +>>>>>>> Finish implementing and testing zip } <<<<<<< HEAD @@ -347,6 +372,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder * Download the file if it is online * If it's local check if the file exists and if it is redable */ +<<<<<<< HEAD >>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources if ($isOnline) { $fileDownloadCache = $this->cacheDir . DS . "download"; @@ -375,18 +401,21 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder if (empty($name)) { $name = basename($filePath); } +======= + $fileDownloadCache = $this->cacheDir . DS . "download.tmp"; + $this->copyFile($filePath, $fileDownloadCache, $isOnline); +>>>>>>> Finish implementing and testing zip /** * Then write the file in the archive and commit the changes */ - $destination = $directoryInArchive . $name; - if (!$this->zip->addFile($filePath,$destination)) { + if (!$this->zip->addFile($fileDownloadCache, $destination)) { $translatedErrorMessage = $this->translator->trans( "An error occurred while adding this file to the archive: %file", [ - "%file" => $filePath + "%file" => $fileDownloadCache ] ); @@ -401,6 +430,146 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder >>>>>>> Define archive builders and formatters } + /** + * @param $content + * @param $name + * @param string $directoryInArchive + * @return mixed + * @throws \ErrorException + * + * This method creates a file in the archive with its content + */ + public function addFileFromString($content, $name, $directoryInArchive = "/") + { + $directoryInArchive = $this->formatDirectoryPath($directoryInArchive); + + if (!empty($directoryInArchive) && $directoryInArchive !== "/") { + $this->addDirectory($directoryInArchive); + } + + if (empty($name) || !is_scalar($name)) { + throw new \ErrorException( + $this->translator->trans( + "The filename is not correct" + ) + ); + } + + $filePath = $this->getFilePath($directoryInArchive . DS . $name); + + if (!$this->zip->addFromString($filePath, $content)) { + throw new \ErrorException( + $this->translator->trans( + "Unable to write the file %file into the archive", + [ + "%file" => $filePath, + ] + ) + ); + } + + $this->commit(); + } + + + /** + * @param $directoryPath + * @return $this + * @throws \ErrorException + * + * This method creates an empty directory + */ + public function addDirectory($directoryPath) + { + $directoryInArchive = $this->formatDirectoryPath($directoryPath); + + if (!empty($directoryInArchive)) { + if (!$this->zip->addEmptyDir($directoryInArchive)) { + throw new \ErrorException( + $this->translator->trans( + "The directory %dir has not been created in the archive", + [ + "%dir" => $directoryInArchive + ] + ) + ); + } + } + + return $this; + } + + /** + * @param string $pathToFile + * @return null|string + * @throws \Thelia\Exception\FileNotFoundException + * @throws \Thelia\Exception\FileNotReadableException + * @throws \ErrorException + * + * This method returns a file content + */ + public function getFileContent($pathToFile) + { + $pathToFile = $this->formatFilePath($pathToFile); + + if (!$this->hasFile($pathToFile)) { + $this->throwFileNotFound($pathToFile); + } + + $stream = $this->zip->getStream($pathToFile); + $content = ""; + + while (!feof($stream)) { + $content .= fread($stream, 2); + } + + fclose($stream); + + return $content; + } + + + /** + * @param string $initialString + * @return string + * + * Gives a valid file path for \ZipArchive + */ + public function getFilePath($initialString) + { + /** + * Remove the / at the beginning and the end. + */ + $initialString = trim($initialString, "/"); + + /** + * Remove the double, triple, ... slashes + */ + $initialString = preg_replace("#\/{2,}#", "/", $initialString); + + if (preg_match("#\/?[^\/]+\/[^/]+\/?#", $initialString)) { + $initialString = "/" . $initialString; + } + return $initialString; + } + + /** + * @param string $initialString + * @return string + * + * Gives a valid directory path for \ZipArchive + */ + public function getDirectoryPath($initialString) + { + $initialString = $this->getFilePath($initialString); + + if ($initialString[0] !== "/") { + $initialString = "/" . $initialString; + } + + return $initialString . "/"; + } + /** * @param $pathInArchive * @return $this @@ -411,11 +580,15 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder */ public function deleteFile($pathInArchive) { +<<<<<<< HEAD <<<<<<< HEAD $pathInArchive = $this->formatFilePath($pathInArchive); ======= $pathInArchive = $this->getFilePath($pathInArchive); >>>>>>> Define archive builders and formatters +======= + $pathInArchive = $this->formatFilePath($pathInArchive); +>>>>>>> Finish implementing and testing zip if (!$this->hasFile($pathInArchive)) { $this->throwFileNotFound($pathInArchive); @@ -452,6 +625,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder $this->commit(); +<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD if (!file_exists($this->cacheFile)) { @@ -473,11 +647,19 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder if (!is_readable($this->zipCacheFile)) { >>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources +======= + if (!file_exists($this->cacheFile)) { + $this->throwFileNotFound($this->cacheFile); + } + + if (!is_readable($this->cacheFile)) { +>>>>>>> Finish implementing and testing zip throw new FileNotReadableException( $this->translator->trans( "The cache file %file is not readable", [ <<<<<<< HEAD +<<<<<<< HEAD <<<<<<< HEAD "%file" => $this->cacheFile ======= @@ -486,11 +668,15 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder ======= "%file" => $this->zipCacheFile >>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources +======= + "%file" => $this->cacheFile +>>>>>>> Finish implementing and testing zip ] ) ); } +<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD $content = file_get_contents($this->cacheFile); @@ -500,6 +686,9 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder ======= $content = file_get_contents($this->zipCacheFile); >>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources +======= + $content = file_get_contents($this->cacheFile); +>>>>>>> Finish implementing and testing zip $this->zip->close(); @@ -576,39 +765,9 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder $instance->setFileDownloader($fileDownloader); } - if ($isOnline) { - /** - * It's an online file - */ - $instance->getFileDownloader() - ->download($pathToArchive, $instance->getZipCacheFile()) - ; - } else { - /** - * It's a local file - */ - if (!is_file($pathToArchive) || !is_readable($pathToArchive)) { - $instance->throwFileNotFound($pathToArchive); - } + $instance->copyFile($pathToArchive, $instance->getCacheFile(), $isOnline); - if (!copy($pathToArchive, $instance->getZipCacheFile())) { - $translatedErrorMessage = $instance->getTranslator()->trans( - "An unknown error happend while copying %prev to %dest", - [ - "%prev" => $pathToArchive, - "%dest" => $instance->getZipCacheFile(), - ] - ); - - $instance->getLogger() - ->error($translatedErrorMessage) - ; - - throw new \ErrorException($translatedErrorMessage); - } - } - - if (true !== $return = $zip->open($instance->getZipCacheFile())) { + if (true !== $return = $zip->open($instance->getCacheFile())) { throw new ZipArchiveException( $instance->getZipErrorMessage($return) ); @@ -627,11 +786,15 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder public function hasFile($pathToFile) { return $this->zip +<<<<<<< HEAD <<<<<<< HEAD ->locateName($this->formatFilePath($pathToFile)) !== false ======= ->locateName($this->getFilePath($pathToFile)) !== false >>>>>>> Define archive builders and formatters +======= + ->locateName($this->formatFilePath($pathToFile)) !== false +>>>>>>> Finish implementing and testing zip ; } @@ -647,11 +810,15 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder */ public function hasDirectory($directory) { +<<<<<<< HEAD <<<<<<< HEAD $link = $this->zip->locateName($this->formatDirectoryPath($directory)); ======= $link = $this->zip->locateName($this->getDirectoryPath($directory)); >>>>>>> Define archive builders and formatters +======= + $link = $this->zip->locateName($this->formatDirectoryPath($directory)); +>>>>>>> Finish implementing and testing zip return $link !== false; } @@ -708,11 +875,15 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder >>>>>>> Define archive builders and formatters ======= +<<<<<<< HEAD $cacheFileName = md5 (uniqid()); $cacheFile = $this->getArchiveBuilderCacheDirectory($environment) . DS; $cacheFile .= $cacheFileName . "." . $this->getExtension(); >>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources +======= + $cacheFile = $this->generateCacheFile($environment); +>>>>>>> Finish implementing and testing zip if (file_exists($cacheFile)) { unlink($cacheFile); @@ -742,6 +913,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder ); } +<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD $this->cacheFile = $cacheFile; @@ -751,6 +923,9 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder ======= $this->zipCacheFile = $cacheFile; >>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources +======= + $this->cacheFile = $cacheFile; +>>>>>>> Finish implementing and testing zip return $this; } @@ -822,11 +997,15 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder public function commit() { $this->zip->close(); +<<<<<<< HEAD <<<<<<< HEAD $result = $this->zip->open($this->getCacheFile()); ======= $result = $this->zip->open($this->getZipCacheFile()); >>>>>>> Define archive builders and formatters +======= + $result = $this->zip->open($this->getCacheFile()); +>>>>>>> Finish implementing and testing zip if ($result !== true) { throw new \ErrorException( @@ -849,11 +1028,15 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder * * Gives a valid file path for \ZipArchive */ +<<<<<<< HEAD <<<<<<< HEAD public function formatFilePath($initialString) ======= public function getFilePath($initialString) >>>>>>> Define archive builders and formatters +======= + public function formatFilePath($initialString) +>>>>>>> Finish implementing and testing zip { /** * Remove the / at the beginning and the end. @@ -885,6 +1068,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder * * Gives a valid directory path for \ZipArchive */ +<<<<<<< HEAD <<<<<<< HEAD public function formatDirectoryPath($initialString) { @@ -893,17 +1077,25 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder if ($initialString !== "" && $initialString[0] !== "/") { ======= public function getDirectoryPath($initialString) +======= + public function formatDirectoryPath($initialString) +>>>>>>> Finish implementing and testing zip { - $initialString = $this->getFilePath($initialString); + $initialString = $this->formatFilePath($initialString); +<<<<<<< HEAD if ($initialString[0] !== "/") { >>>>>>> Define archive builders and formatters +======= + if ($initialString !== "" && $initialString[0] !== "/") { +>>>>>>> Finish implementing and testing zip $initialString = "/" . $initialString; } return $initialString . "/"; } +<<<<<<< HEAD <<<<<<< HEAD ======= public function throwFileNotFound($file) @@ -921,6 +1113,8 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder } >>>>>>> Define archive builders and formatters +======= +>>>>>>> Finish implementing and testing zip /** * @return string * @@ -991,6 +1185,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder return $this->zip; } <<<<<<< HEAD +<<<<<<< HEAD } ======= @@ -1009,3 +1204,6 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder ======= } >>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources +======= +} +>>>>>>> Finish implementing and testing zip diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php index 96de43666..56d49de3c 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php @@ -11,6 +11,7 @@ /*************************************************************************************/ namespace Thelia\Core\FileFormat\Archive; +use Thelia\Tools\FileDownload\FileDownloaderInterface; /** * Interface ArchiveBuilderInterface @@ -43,7 +44,11 @@ interface ArchiveBuilderInterface * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException +<<<<<<< HEAD >>>>>>> Define archive builders and formatters +======= + * @throws \ErrorException +>>>>>>> Finish implementing and testing zip * * This methods adds a file in the archive. * If the file is local, $isOnline must be false, @@ -52,10 +57,16 @@ interface ArchiveBuilderInterface public function addFile($filePath, $directoryInArchive = "/", $name = null, $isOnline = false); /** +<<<<<<< HEAD <<<<<<< HEAD * @param $content * @param $name * @param string $directoryInArchive +======= + * @param $content + * @param $name + * @param string $directoryInArchive +>>>>>>> Finish implementing and testing zip * @return mixed * @throws \ErrorException * @@ -64,7 +75,11 @@ interface ArchiveBuilderInterface public function addFileFromString($content, $name, $directoryInArchive = "/"); /** +<<<<<<< HEAD * @param string $pathToFile +======= + * @param string $pathToFile +>>>>>>> Finish implementing and testing zip * @return null|string * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\FileNotReadableException @@ -74,6 +89,7 @@ interface ArchiveBuilderInterface */ public function getFileContent($pathToFile); /** +<<<<<<< HEAD * @param $pathInArchive * @return $this * @throws \Thelia\Exception\FileNotFoundException @@ -83,6 +99,12 @@ interface ArchiveBuilderInterface * @return $this * @throws \Thelia\Exception\FileNotFoundException >>>>>>> Define archive builders and formatters +======= + * @param $pathInArchive + * @return $this + * @throws \Thelia\Exception\FileNotFoundException + * @throws \ErrorException +>>>>>>> Finish implementing and testing zip * * This method deletes a file in the archive */ @@ -90,6 +112,9 @@ interface ArchiveBuilderInterface /** <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> Finish implementing and testing zip * @param $directoryPath * @return $this * @throws \ErrorException @@ -97,11 +122,15 @@ interface ArchiveBuilderInterface * This method creates an empty directory */ public function addDirectory($directoryPath); +<<<<<<< HEAD /** * @params string $filename ======= >>>>>>> Define archive builders and formatters +======= + /** +>>>>>>> Finish implementing and testing zip * @return \Thelia\Core\HttpFoundation\Response * * This method return an instance of a Response with the archive as content. @@ -117,19 +146,28 @@ interface ArchiveBuilderInterface /** * @param string $pathToArchive + * @param string $environment * @param bool $isOnline +<<<<<<< HEAD >>>>>>> Define archive builders and formatters +======= + * @param FileDownloaderInterface $fileDownloader +>>>>>>> Finish implementing and testing zip * @return $this * @throws \Thelia\Exception\FileNotFoundException * @throws \Thelia\Exception\HttpUrlException * * Loads an archive */ +<<<<<<< HEAD <<<<<<< HEAD public function loadArchive($pathToArchive, $isOnline = false); ======= public static function loadArchive($pathToArchive, $environment, $isOnline = false); >>>>>>> Define archive builders and formatters +======= + public static function loadArchive($pathToArchive, $environment, $isOnline = false, FileDownloaderInterface $fileDownloader = null); +>>>>>>> Finish implementing and testing zip /** * @param $pathToFile diff --git a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php index e34acdf76..74605ac01 100644 --- a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php @@ -33,11 +33,19 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase Tlog::getNewInstance(); $this->tar = new TarArchiveBuilder(); +<<<<<<< HEAD $this->tar->setEnvironment("dev"); +======= +>>>>>>> Finish implementing and testing zip } public function testAddFileAndDirectory() { +<<<<<<< HEAD +======= + $this->tar->setEnvironment("dev"); + +>>>>>>> Finish implementing and testing zip /** * File */ @@ -82,6 +90,7 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->tar->hasDirectory("bar")); } +<<<<<<< HEAD public function testAddValidFileFromString() { @@ -289,3 +298,6 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase ); } } +======= +} +>>>>>>> Finish implementing and testing zip diff --git a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php index 12b263f07..bbb692b37 100644 --- a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php @@ -73,84 +73,121 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( "foo", +<<<<<<< HEAD $this->zip->getFilePath("foo") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatFilePath("foo") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "foo", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatFilePath("/foo") ======= $this->zip->getFilePath("/foo") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatFilePath("/foo") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "foo", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatFilePath("foo/") ======= $this->zip->getFilePath("foo/") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatFilePath("foo/") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "foo", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatFilePath("/foo/") ======= $this->zip->getFilePath("/foo/") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatFilePath("/foo/") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/bar", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatFilePath("foo/bar") ======= $this->zip->getFilePath("foo/bar") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatFilePath("foo/bar") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/bar", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatFilePath("/foo/bar") ======= $this->zip->getFilePath("/foo/bar") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatFilePath("/foo/bar") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/bar", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatFilePath("/foo//bar/") ======= $this->zip->getFilePath("/foo//bar/") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatFilePath("/foo//bar/") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/bar", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatFilePath("/foo/bar/") ======= $this->zip->getFilePath("/foo/bar/") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatFilePath("/foo/bar/") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/bar/baz", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatFilePath("foo/bar/baz") ======= $this->zip->getFilePath("foo/bar/baz") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatFilePath("foo/bar/baz") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/bar/baz", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatFilePath("//foo/bar///baz/") ); @@ -163,6 +200,9 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase $this->zip->formatDirectoryPath("foo") ======= $this->zip->getFilePath("//foo/bar///baz/") +======= + $this->zip->formatFilePath("//foo/bar///baz/") +>>>>>>> Finish implementing and testing zip ); } @@ -170,89 +210,129 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( "/foo/", +<<<<<<< HEAD $this->zip->getDirectoryPath("foo") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatDirectoryPath("foo") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatDirectoryPath("/foo") ======= $this->zip->getDirectoryPath("/foo") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatDirectoryPath("/foo") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatDirectoryPath("foo/") ======= $this->zip->getDirectoryPath("foo/") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatDirectoryPath("foo/") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatDirectoryPath("/foo/") ======= $this->zip->getDirectoryPath("/foo/") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatDirectoryPath("/foo/") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/bar/", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatDirectoryPath("foo/bar") ======= $this->zip->getDirectoryPath("foo/bar") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatDirectoryPath("foo/bar") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/bar/", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatDirectoryPath("/foo/bar") ======= $this->zip->getDirectoryPath("/foo/bar") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatDirectoryPath("/foo/bar") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/bar/", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatDirectoryPath("/foo//bar/") ======= $this->zip->getDirectoryPath("/foo//bar/") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatDirectoryPath("/foo//bar/") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/bar/", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatDirectoryPath("/foo/bar/") ======= $this->zip->getDirectoryPath("/foo/bar/") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatDirectoryPath("/foo/bar/") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/bar/baz/", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatDirectoryPath("foo/bar/baz") ======= $this->zip->getDirectoryPath("foo/bar/baz") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatDirectoryPath("foo/bar/baz") +>>>>>>> Finish implementing and testing zip ); $this->assertEquals( "/foo/bar/baz/", +<<<<<<< HEAD <<<<<<< HEAD $this->zip->formatDirectoryPath("//foo/bar///baz/") ======= $this->zip->getDirectoryPath("//foo/bar///baz/") >>>>>>> Define archive builders and formatters +======= + $this->zip->formatDirectoryPath("//foo/bar///baz/") +>>>>>>> Finish implementing and testing zip ); } @@ -274,11 +354,15 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase } /** +<<<<<<< HEAD <<<<<<< HEAD * @expectedException \Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\ZipArchiveException ======= * @expectedException \Thelia\Core\FileFormat\Archive\ArchiveBuilder\ZipArchiveException >>>>>>> Define archive builders and formatters +======= + * @expectedException \Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\ZipArchiveException +>>>>>>> Finish implementing and testing zip * @expectedExceptionMessage [Zip Error] The file is not a zip archive */ public function testLoadNotValidZip() @@ -327,11 +411,15 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase } /** +<<<<<<< HEAD <<<<<<< HEAD * @expectedException \Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\ZipArchiveException ======= * @expectedException \Thelia\Core\FileFormat\Archive\ArchiveBuilder\ZipArchiveException >>>>>>> Define archive builders and formatters +======= + * @expectedException \Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\ZipArchiveException +>>>>>>> Finish implementing and testing zip * @expectedExceptionMessage [Zip Error] The file is not a zip archive */ public function testLoadOnlineAvailableAndNotValidFile() @@ -489,6 +577,9 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase ); } <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> Finish implementing and testing zip public function testAddValidFileFromString() { @@ -504,6 +595,7 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase "foo", $this->loadedZip->getFileContent("bar") ); +<<<<<<< HEAD $this->loadedZip->addFileFromString( "foo", "bar", "baz" @@ -517,6 +609,8 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase "foo", $this->loadedZip->getFileContent("baz/bar") ); +======= +>>>>>>> Finish implementing and testing zip } /** @@ -547,7 +641,11 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase ); } +<<<<<<< HEAD } ======= } >>>>>>> Define archive builders and formatters +======= +} +>>>>>>> Finish implementing and testing zip