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\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

View File

@@ -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

View File

@@ -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

View File

@@ -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));