diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php index 7d633db87..d51251499 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php @@ -20,6 +20,7 @@ use Thelia\Core\Translation\Translator; use Thelia\Exception\FileNotReadableException; ======= use Thelia\Core\FileFormat\Archive\ArchiveBuilderInterface; +use Thelia\Core\Thelia; use Thelia\Core\Translation\Translator; >>>>>>> Finish implementing and testing zip use Thelia\Log\Tlog; @@ -259,6 +260,9 @@ class TarArchiveBuilder extends AbstractArchiveBuilder { <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> Fix FileDownloader test $pathToFile = $this->formatFilePath($pathToFile); if (!$this->hasFile($pathToFile)) { @@ -267,11 +271,19 @@ class TarArchiveBuilder extends AbstractArchiveBuilder /** @var \PharFileInfo $fileInfo*/ $fileInfo = $this->tar[$pathToFile]; +<<<<<<< HEAD /** @var \SplFileObject $file */ $file = $fileInfo->openFile(); $content = ""; +======= + + /** @var \SplFileObject $file */ + $file = $fileInfo->openFile(); + $content = ""; + +>>>>>>> Fix FileDownloader test while (false !== ($char = $file->fgetc())) { $content .= $char; } @@ -359,6 +371,8 @@ class TarArchiveBuilder extends AbstractArchiveBuilder ======= public function buildArchiveResponse() { + $this->tar->setMetadata("comment", "Generated by Thelia v" . Thelia::THELIA_VERSION); + } @@ -397,9 +411,14 @@ class TarArchiveBuilder extends AbstractArchiveBuilder $instance->setFileDownloader($fileDownloader); } +<<<<<<< HEAD $instance->setCacheFile($instance->getCacheFile()) ->copyFile($pathToArchive, $isOnline); >>>>>>> Finish implementing and testing zip +======= + $instance->setCacheFile($instance->generateCacheFile($environment)) + ->copyFile($pathToArchive, $instance->getCacheFile(), $isOnline); +>>>>>>> Fix FileDownloader test /** * This throws TarArchiveBuilderException if diff --git a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php index cf65ea3d1..1c9bfba8a 100644 --- a/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php +++ b/core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php @@ -33,19 +33,26 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase Tlog::getNewInstance(); $this->tar = new TarArchiveBuilder(); +<<<<<<< HEAD <<<<<<< HEAD $this->tar->setEnvironment("dev"); ======= >>>>>>> Finish implementing and testing zip +======= + $this->tar->setEnvironment("dev"); +>>>>>>> Fix FileDownloader test } public function testAddFileAndDirectory() { <<<<<<< HEAD +<<<<<<< HEAD ======= $this->tar->setEnvironment("dev"); >>>>>>> Finish implementing and testing zip +======= +>>>>>>> Fix FileDownloader test /** * File */ @@ -97,9 +104,13 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase public function testAddValidFileFromString() { +<<<<<<< HEAD <<<<<<< HEAD $this->tar->addFileFromString( <<<<<<< HEAD +======= + $this->tar->addFileFromString( +>>>>>>> Fix FileDownloader test "foo", "bar" ); @@ -111,6 +122,7 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase "foo", $this->tar->getFileContent("bar") ); +<<<<<<< HEAD $this->tar->addFileFromString( "foo", "bar", "baz" @@ -308,8 +320,60 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase >>>>>>> Finish implementing and testing zip ======= ======= +>>>>>>> Fix FileDownloader test +======= >>>>>>> Fix FileDownloader test + $this->tar->addFileFromString( + "foo", "bar", "baz" + ); + + $this->assertTrue( + $this->tar->hasFile("baz/bar") + ); + + $this->assertEquals( + "foo", + $this->tar->getFileContent("baz/bar") + ); + } + + /** + * @expectedException \ErrorException + */ + public function testAddNotValidFileFromString() + { + $this->tar->addFileFromString( + "foo", $this + ); + } + + /** + * @expectedException \ErrorException + */ + public function testAddNotValidFileValueFromString() + { + $this->tar->addFileFromString( + $this, "foo" + ); + } + + + public function testDeleteFile() + { + $this->tar->addFileFromString( + "foo", "bar" + ); + + $this->assertTrue( + $this->tar->hasFile("bar") + ); + + $this->tar->deleteFile("bar"); + + $this->assertFalse( + $this->tar->hasFile("bar") + ); } } >>>>>>> Complete zip tests diff --git a/core/lib/Thelia/Tools/FileDownload/FileDownloader.php b/core/lib/Thelia/Tools/FileDownload/FileDownloader.php index 94e7170ca..ac0ae7eca 100644 --- a/core/lib/Thelia/Tools/FileDownload/FileDownloader.php +++ b/core/lib/Thelia/Tools/FileDownload/FileDownloader.php @@ -18,9 +18,13 @@ use Thelia\Exception\FileNotFoundException; use Thelia\Exception\HttpUrlException; use Thelia\Log\Tlog; <<<<<<< HEAD +<<<<<<< HEAD use Thelia\Tools\URL; ======= >>>>>>> Define archive builders and formatters +======= +use Thelia\Tools\URL; +>>>>>>> Fix FileDownloader test /** * Class FileDownloader diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index 9351bcac4..8ef2b4b31 100644 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -315,11 +315,15 @@ class URL $clean; } +<<<<<<< HEAD <<<<<<< HEAD public static function checkUrl($url, array $protocols = ["http", "https"]) ======= public function checkUrl($url, array $protocols = ["http", "https"]) >>>>>>> Define archive builders and formatters +======= + public static function checkUrl($url, array $protocols = ["http", "https"]) +>>>>>>> Fix FileDownloader test { $pattern = sprintf(UrlValidator::PATTERN, implode('|', $protocols));