Fix FileDownloader test

modifié:         core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php
	modifié:         core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php
	modifié:         core/lib/Thelia/Tools/FileDownload/FileDownloader.php
	modifié:         core/lib/Thelia/Tools/URL.php
This commit is contained in:
Benjamin Perche
2014-07-03 14:20:31 +02:00
parent 9d928c1f53
commit c9b485d3e5
4 changed files with 91 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ use Thelia\Core\Translation\Translator;
use Thelia\Exception\FileNotReadableException; use Thelia\Exception\FileNotReadableException;
======= =======
use Thelia\Core\FileFormat\Archive\ArchiveBuilderInterface; use Thelia\Core\FileFormat\Archive\ArchiveBuilderInterface;
use Thelia\Core\Thelia;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
>>>>>>> Finish implementing and testing zip >>>>>>> Finish implementing and testing zip
use Thelia\Log\Tlog; use Thelia\Log\Tlog;
@@ -259,6 +260,9 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
{ {
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> Fix FileDownloader test
$pathToFile = $this->formatFilePath($pathToFile); $pathToFile = $this->formatFilePath($pathToFile);
if (!$this->hasFile($pathToFile)) { if (!$this->hasFile($pathToFile)) {
@@ -267,11 +271,19 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
/** @var \PharFileInfo $fileInfo*/ /** @var \PharFileInfo $fileInfo*/
$fileInfo = $this->tar[$pathToFile]; $fileInfo = $this->tar[$pathToFile];
<<<<<<< HEAD
/** @var \SplFileObject $file */ /** @var \SplFileObject $file */
$file = $fileInfo->openFile(); $file = $fileInfo->openFile();
$content = ""; $content = "";
=======
/** @var \SplFileObject $file */
$file = $fileInfo->openFile();
$content = "";
>>>>>>> Fix FileDownloader test
while (false !== ($char = $file->fgetc())) { while (false !== ($char = $file->fgetc())) {
$content .= $char; $content .= $char;
} }
@@ -359,6 +371,8 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
======= =======
public function buildArchiveResponse() 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); $instance->setFileDownloader($fileDownloader);
} }
<<<<<<< HEAD
$instance->setCacheFile($instance->getCacheFile()) $instance->setCacheFile($instance->getCacheFile())
->copyFile($pathToArchive, $isOnline); ->copyFile($pathToArchive, $isOnline);
>>>>>>> Finish implementing and testing zip >>>>>>> Finish implementing and testing zip
=======
$instance->setCacheFile($instance->generateCacheFile($environment))
->copyFile($pathToArchive, $instance->getCacheFile(), $isOnline);
>>>>>>> Fix FileDownloader test
/** /**
* This throws TarArchiveBuilderException if * This throws TarArchiveBuilderException if

View File

@@ -33,19 +33,26 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
Tlog::getNewInstance(); Tlog::getNewInstance();
$this->tar = new TarArchiveBuilder(); $this->tar = new TarArchiveBuilder();
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
$this->tar->setEnvironment("dev"); $this->tar->setEnvironment("dev");
======= =======
>>>>>>> Finish implementing and testing zip >>>>>>> Finish implementing and testing zip
=======
$this->tar->setEnvironment("dev");
>>>>>>> Fix FileDownloader test
} }
public function testAddFileAndDirectory() public function testAddFileAndDirectory()
{ {
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
======= =======
$this->tar->setEnvironment("dev"); $this->tar->setEnvironment("dev");
>>>>>>> Finish implementing and testing zip >>>>>>> Finish implementing and testing zip
=======
>>>>>>> Fix FileDownloader test
/** /**
* File * File
*/ */
@@ -97,9 +104,13 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
public function testAddValidFileFromString() public function testAddValidFileFromString()
{ {
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
$this->tar->addFileFromString( $this->tar->addFileFromString(
<<<<<<< HEAD <<<<<<< HEAD
=======
$this->tar->addFileFromString(
>>>>>>> Fix FileDownloader test
"foo", "bar" "foo", "bar"
); );
@@ -111,6 +122,7 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
"foo", "foo",
$this->tar->getFileContent("bar") $this->tar->getFileContent("bar")
); );
<<<<<<< HEAD
$this->tar->addFileFromString( $this->tar->addFileFromString(
"foo", "bar", "baz" "foo", "bar", "baz"
@@ -308,8 +320,60 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
>>>>>>> Finish implementing and testing zip >>>>>>> Finish implementing and testing zip
======= =======
======= =======
>>>>>>> Fix FileDownloader test
=======
>>>>>>> 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 >>>>>>> Complete zip tests

View File

@@ -18,9 +18,13 @@ use Thelia\Exception\FileNotFoundException;
use Thelia\Exception\HttpUrlException; use Thelia\Exception\HttpUrlException;
use Thelia\Log\Tlog; use Thelia\Log\Tlog;
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
use Thelia\Tools\URL; use Thelia\Tools\URL;
======= =======
>>>>>>> Define archive builders and formatters >>>>>>> Define archive builders and formatters
=======
use Thelia\Tools\URL;
>>>>>>> Fix FileDownloader test
/** /**
* Class FileDownloader * Class FileDownloader

View File

@@ -315,11 +315,15 @@ class URL
$clean; $clean;
} }
<<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
public static function checkUrl($url, array $protocols = ["http", "https"]) public static function checkUrl($url, array $protocols = ["http", "https"])
======= =======
public function checkUrl($url, array $protocols = ["http", "https"]) public function checkUrl($url, array $protocols = ["http", "https"])
>>>>>>> Define archive builders and formatters >>>>>>> Define archive builders and formatters
=======
public static function checkUrl($url, array $protocols = ["http", "https"])
>>>>>>> Fix FileDownloader test
{ {
$pattern = sprintf(UrlValidator::PATTERN, implode('|', $protocols)); $pattern = sprintf(UrlValidator::PATTERN, implode('|', $protocols));