Finish Tar archive builder
modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php modifié: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php nouveau fichier: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TestResources/bad_formatted.tar nouveau fichier: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TestResources/well_formatted.tar modifié: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php
This commit is contained in:
@@ -14,6 +14,7 @@ namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder;
|
|||||||
use Thelia\Core\FileFormat\Archive\AbstractArchiveBuilder;
|
use Thelia\Core\FileFormat\Archive\AbstractArchiveBuilder;
|
||||||
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\TarArchiveException;
|
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\TarArchiveException;
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
use Thelia\Core\HttpFoundation\Response;
|
use Thelia\Core\HttpFoundation\Response;
|
||||||
use Thelia\Core\Thelia;
|
use Thelia\Core\Thelia;
|
||||||
use Thelia\Core\Translation\Translator;
|
use Thelia\Core\Translation\Translator;
|
||||||
@@ -23,6 +24,12 @@ use Thelia\Core\FileFormat\Archive\ArchiveBuilderInterface;
|
|||||||
use Thelia\Core\Thelia;
|
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\Core\HttpFoundation\Response;
|
||||||
|
use Thelia\Core\Thelia;
|
||||||
|
use Thelia\Core\Translation\Translator;
|
||||||
|
use Thelia\Exception\FileNotReadableException;
|
||||||
|
>>>>>>> Finish Tar archive builder
|
||||||
use Thelia\Log\Tlog;
|
use Thelia\Log\Tlog;
|
||||||
use Thelia\Tools\FileDownload\FileDownloaderInterface;
|
use Thelia\Tools\FileDownload\FileDownloaderInterface;
|
||||||
|
|
||||||
@@ -77,8 +84,12 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
$this->compression = $compressionType;
|
$this->compression = $compressionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
/**
|
/**
|
||||||
>>>>>>> Finish implementing and testing zip
|
>>>>>>> Finish implementing and testing zip
|
||||||
|
=======
|
||||||
|
|
||||||
|
>>>>>>> Finish Tar archive builder
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
if ($this->tar instanceof \PharData) {
|
if ($this->tar instanceof \PharData) {
|
||||||
@@ -86,6 +97,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
unlink($this->cacheFile);
|
unlink($this->cacheFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,6 +108,9 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
* @param bool $isOnline
|
* @param bool $isOnline
|
||||||
=======
|
=======
|
||||||
}*/
|
}*/
|
||||||
|
=======
|
||||||
|
}
|
||||||
|
>>>>>>> Finish Tar archive builder
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $filePath It is the path to access the file.
|
* @param string $filePath It is the path to access the file.
|
||||||
@@ -147,13 +162,19 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
$this->tar->addFile($filePath, $name);
|
$this->tar->addFile($filePath, $name);
|
||||||
|
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
>>>>>>> Finish Tar archive builder
|
||||||
/**
|
/**
|
||||||
* And clear the download temp file
|
* And clear the download temp file
|
||||||
*/
|
*/
|
||||||
unlink($fileDownloadCache);
|
unlink($fileDownloadCache);
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
=======
|
=======
|
||||||
>>>>>>> Finish implementing and testing zip
|
>>>>>>> Finish implementing and testing zip
|
||||||
|
=======
|
||||||
|
>>>>>>> Finish Tar archive builder
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,9 +392,32 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
=======
|
=======
|
||||||
public function buildArchiveResponse()
|
public function buildArchiveResponse()
|
||||||
{
|
{
|
||||||
$this->tar->setMetadata("comment", "Generated by Thelia v" . Thelia::THELIA_VERSION);
|
$this->tar->setMetadata("Generated by Thelia v" . Thelia::THELIA_VERSION);
|
||||||
|
|
||||||
|
if (!is_file($this->cacheFile)) {
|
||||||
|
$this->throwFileNotFound($this->cacheFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_readable($this->cacheFile)) {
|
||||||
|
throw new FileNotReadableException(
|
||||||
|
$this->translator->trans(
|
||||||
|
"The file %file is not readable",
|
||||||
|
[
|
||||||
|
"%file" => $this->cacheFile
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = file_get_contents($this->cacheFile);
|
||||||
|
|
||||||
|
return new Response(
|
||||||
|
$content,
|
||||||
|
200,
|
||||||
|
[
|
||||||
|
"Content-Type" => $this->getMimeType(),
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -358,7 +358,6 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testDeleteFile()
|
public function testDeleteFile()
|
||||||
{
|
{
|
||||||
$this->tar->addFileFromString(
|
$this->tar->addFileFromString(
|
||||||
@@ -375,5 +374,143 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->tar->hasFile("bar")
|
$this->tar->hasFile("bar")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
}
|
}
|
||||||
>>>>>>> Complete zip tests
|
>>>>>>> Complete zip tests
|
||||||
|
=======
|
||||||
|
|
||||||
|
public function testLoadValidArchive()
|
||||||
|
{
|
||||||
|
$tar = TarArchiveBuilder::loadArchive(
|
||||||
|
__DIR__ . DS . "TestResources/well_formatted.tar",
|
||||||
|
"dev"
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
get_class($this->tar),
|
||||||
|
$tar
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertTrue(
|
||||||
|
$tar->hasFile("LICENSE.txt")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\TarArchiveException
|
||||||
|
*/
|
||||||
|
public function testLoadInvalidArchive()
|
||||||
|
{
|
||||||
|
$tar = TarArchiveBuilder::loadArchive(
|
||||||
|
__DIR__ . DS . "TestResources/bad_formatted.tar",
|
||||||
|
"dev"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFormatDirectoryPath()
|
||||||
|
{
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/",
|
||||||
|
$this->tar->formatDirectoryPath("foo")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/",
|
||||||
|
$this->tar->formatDirectoryPath("/foo")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/",
|
||||||
|
$this->tar->formatDirectoryPath("foo/")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/",
|
||||||
|
$this->tar->formatDirectoryPath("/foo/")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/bar/",
|
||||||
|
$this->tar->formatDirectoryPath("foo/bar")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/bar/",
|
||||||
|
$this->tar->formatDirectoryPath("/foo/bar")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/bar/",
|
||||||
|
$this->tar->formatDirectoryPath("/foo//bar/")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/bar/",
|
||||||
|
$this->tar->formatDirectoryPath("/foo/bar/")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/bar/baz/",
|
||||||
|
$this->tar->formatDirectoryPath("foo/bar/baz")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/bar/baz/",
|
||||||
|
$this->tar->formatDirectoryPath("//foo/bar///baz/")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFormatFilePath()
|
||||||
|
{
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo",
|
||||||
|
$this->tar->formatFilePath("foo")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo",
|
||||||
|
$this->tar->formatFilePath("/foo")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo",
|
||||||
|
$this->tar->formatFilePath("foo/")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo",
|
||||||
|
$this->tar->formatFilePath("/foo/")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/bar",
|
||||||
|
$this->tar->formatFilePath("foo/bar")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/bar",
|
||||||
|
$this->tar->formatFilePath("/foo/bar")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/bar",
|
||||||
|
$this->tar->formatFilePath("/foo//bar/")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/bar",
|
||||||
|
$this->tar->formatFilePath("/foo/bar/")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/bar/baz",
|
||||||
|
$this->tar->formatFilePath("foo/bar/baz")
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
"foo/bar/baz",
|
||||||
|
$this->tar->formatFilePath("//foo/bar///baz/")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>>>>>>> Finish Tar archive builder
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
=======
|
=======
|
||||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||||
*/
|
*/
|
||||||
public function testGetFilePath()
|
public function testFormatFilePath()
|
||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
"foo",
|
"foo",
|
||||||
@@ -194,6 +194,7 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testFormatDirectoryPath()
|
public function testFormatDirectoryPath()
|
||||||
|
<<<<<<< HEAD
|
||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
"/foo/",
|
"/foo/",
|
||||||
@@ -207,6 +208,8 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testGetDirectoryPath()
|
public function testGetDirectoryPath()
|
||||||
|
=======
|
||||||
|
>>>>>>> Finish Tar archive builder
|
||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
"/foo/",
|
"/foo/",
|
||||||
|
|||||||
Reference in New Issue
Block a user