Define archive builders and formatters
nouveau fichier: core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiveBuilder.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveException.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php nouveau fichier: core/lib/Thelia/Core/FileFormat/FormatInterface.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Formatter/AbstractFormatter.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Formatter/Exception/BadFormattedStringException.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Formatter/FormatterManager.php nouveau fichier: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TestResources/bad_formatted.zip nouveau fichier: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TestResources/test_file nouveau fichier: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TestResources/well_formatted.zip nouveau fichier: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php nouveau fichier: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php nouveau fichier: core/lib/Thelia/Tests/FileFormat/Formatter/FormatterManagerTest.php nouveau fichier: core/lib/Thelia/Tests/Tools/FakeFileDownloader.php nouveau fichier: core/lib/Thelia/Tests/Tools/FileDownloaderTest.php nouveau fichier: core/lib/Thelia/Tools/FileDownload/FileDownloader.php nouveau fichier: core/lib/Thelia/Tools/FileDownload/FileDownloaderAwareTrait.php nouveau fichier: core/lib/Thelia/Tools/FileDownload/FileDownloaderInterface.php modifié: core/lib/Thelia/Tools/URL.php
This commit is contained in:
44
core/lib/Thelia/Tests/Tools/FakeFileDownloader.php
Normal file
44
core/lib/Thelia/Tests/Tools/FakeFileDownloader.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Tools;
|
||||
use Thelia\Exception\FileNotFoundException;
|
||||
use Thelia\Tools\FileDownload\FileDownloader;
|
||||
|
||||
/**
|
||||
* Class FakeFileDownloader
|
||||
* @package Thelia\Tests\Type
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class FakeFileDownloader extends FileDownloader
|
||||
{
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $pathToStore
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \ErrorException
|
||||
* @throws \HttpUrlException
|
||||
*
|
||||
* Downloads the file $url in $pathToStore
|
||||
*/
|
||||
public function download($url, $pathToStore)
|
||||
{
|
||||
if (!file_exists($url) || !is_readable($url)) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
|
||||
if (!copy($url, $pathToStore)) {
|
||||
throw new \ErrorException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
63
core/lib/Thelia/Tests/Tools/FileDownloaderTest.php
Normal file
63
core/lib/Thelia/Tests/Tools/FileDownloaderTest.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Type;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Tools\FileDownloader;
|
||||
|
||||
/**
|
||||
* Class FileDownloaderTest
|
||||
* @package Thelia\Tests\Type
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class FileDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/** @var FileDownloader */
|
||||
protected $downloader;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$logger = Tlog::getNewInstance();
|
||||
$translator = new Translator(
|
||||
new Container()
|
||||
);
|
||||
|
||||
$this->downloader = new FileDownloader(
|
||||
$logger,
|
||||
$translator
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Thelia\Exception\HttpUrlException
|
||||
* @expectedExceptionMessage Tried to download a file, but the URL was not valid: foo
|
||||
*/
|
||||
public function testFileDownloadInvalidURL()
|
||||
{
|
||||
$this->downloader->download("foo", "bar");
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Thelia\Exception\FileNotFoundException
|
||||
*/
|
||||
public function testFileDownloadNonExistingFile()
|
||||
{
|
||||
$this->downloader->download("https://github.com/foo/bar/baz", "baz");
|
||||
}
|
||||
|
||||
public function testFileDownloadSuccess()
|
||||
{
|
||||
$this->downloader->download("https://github.com/thelia/thelia", "php://temp");
|
||||
}
|
||||
}
|
||||
900
core/lib/Thelia/Tests/Tools/FileManagerTest.php
Normal file
900
core/lib/Thelia/Tests/Tools/FileManagerTest.php
Normal file
@@ -0,0 +1,900 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Tools;
|
||||
|
||||
use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent;
|
||||
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\ContentQuery;
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Tools\FileManager;
|
||||
|
||||
/**
|
||||
* Class FileManagerTest
|
||||
*
|
||||
* @package Thelia\Tests\Tools
|
||||
*/
|
||||
class FileManagerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::copyUploadedFile
|
||||
*/
|
||||
/* public function testCopyUploadedFile()
|
||||
{
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet : Mock issue'
|
||||
);
|
||||
|
||||
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubTranslator->expects($this->any())
|
||||
->method('trans')
|
||||
->will($this->returnValue('translated'));
|
||||
|
||||
$stubRequest = $this->getMockBuilder('\Thelia\Core\HttpFoundation\Request')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubSecurity = $this->getMockBuilder('\Thelia\Core\Security\SecurityContext')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubSecurity->expects($this->any())
|
||||
->method('getAdminUser')
|
||||
->will($this->returnValue(new Admin()));
|
||||
|
||||
// Create a map of arguments to return values.
|
||||
$map = array(
|
||||
array('thelia.translator', $stubTranslator),
|
||||
array('request', $stubRequest),
|
||||
array('thelia.securityContext', $stubSecurity)
|
||||
);
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubContainer->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValueMap($map));
|
||||
|
||||
$stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubProductImage->expects($this->any())
|
||||
->method('getUploadDir')
|
||||
->will($this->returnValue(THELIA_LOCAL_DIR . 'media/images/product'));
|
||||
$stubProductImage->expects($this->any())
|
||||
->method('getId')
|
||||
->will($this->returnValue(42));
|
||||
$stubProductImage->expects($this->any())
|
||||
->method('setFile')
|
||||
->will($this->returnValue(true));
|
||||
$stubProductImage->expects($this->any())
|
||||
->method('save')
|
||||
->will($this->returnValue(0));
|
||||
|
||||
$stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubUploadedFile->expects($this->any())
|
||||
->method('getClientOriginalName')
|
||||
->will($this->returnValue('goodName'));
|
||||
$stubUploadedFile->expects($this->any())
|
||||
->method('getClientOriginalExtension')
|
||||
->will($this->returnValue('png'));
|
||||
$stubUploadedFile->expects($this->any())
|
||||
->method('move')
|
||||
->will($this->returnValue($stubUploadedFile));
|
||||
|
||||
$fileManager = new FileManager($stubContainer);
|
||||
|
||||
$newUploadedFiles = array();
|
||||
|
||||
$actual = $fileManager->copyUploadedFile(24, FileManager::TYPE_PRODUCT, $stubProductImage, $stubUploadedFile, $newUploadedFiles, FileManager::FILE_TYPE_IMAGES);
|
||||
|
||||
$this->assertCount(1, $actual);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::copyUploadedFile
|
||||
* @expectedException \Thelia\Exception\ImageException
|
||||
*/
|
||||
/*public function testCopyUploadedFileExceptionImageException()
|
||||
{
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet : Mock issue'
|
||||
);
|
||||
|
||||
$stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubTranslator->expects($this->any())
|
||||
->method('trans')
|
||||
->will($this->returnValue('translated'));
|
||||
|
||||
$stubRequest = $this->getMockBuilder('\Thelia\Core\HttpFoundation\Request')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubSecurity = $this->getMockBuilder('\Thelia\Core\Security\SecurityContext')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubSecurity->expects($this->any())
|
||||
->method('getAdminUser')
|
||||
->will($this->returnValue(new Admin()));
|
||||
|
||||
// Create a map of arguments to return values.
|
||||
$map = array(
|
||||
array('thelia.translator', $stubTranslator),
|
||||
array('request', $stubRequest),
|
||||
array('thelia.securityContext', $stubSecurity)
|
||||
);
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubContainer->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValueMap($map));
|
||||
|
||||
$stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubProductImage->expects($this->any())
|
||||
->method('getUploadDir')
|
||||
->will($this->returnValue(THELIA_LOCAL_DIR . 'media/images/product'));
|
||||
$stubProductImage->expects($this->any())
|
||||
->method('getId')
|
||||
->will($this->returnValue(42));
|
||||
$stubProductImage->expects($this->any())
|
||||
->method('setFile')
|
||||
->will($this->returnValue(true));
|
||||
$stubProductImage->expects($this->any())
|
||||
->method('save')
|
||||
->will($this->returnValue(0));
|
||||
|
||||
$stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubUploadedFile->expects($this->any())
|
||||
->method('getClientOriginalName')
|
||||
->will($this->returnValue('goodName'));
|
||||
$stubUploadedFile->expects($this->any())
|
||||
->method('getClientOriginalExtension')
|
||||
->will($this->returnValue('png'));
|
||||
$stubUploadedFile->expects($this->any())
|
||||
->method('move')
|
||||
->will($this->returnValue($stubUploadedFile));
|
||||
|
||||
$fileManager = new FileManager($stubContainer);
|
||||
|
||||
$newUploadedFiles = array();
|
||||
|
||||
$actual = $fileManager->copyUploadedFile(24, FileManager::TYPE_PRODUCT, $stubProductImage, $stubUploadedFile, $newUploadedFiles, FileManager::FILE_TYPE_DOCUMENTS);
|
||||
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::saveImage
|
||||
*/
|
||||
public function testSaveImageProductImage()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubProductImage->expects($this->any())
|
||||
->method('save')
|
||||
->will($this->returnValue(10));
|
||||
$stubProductImage->expects($this->any())
|
||||
->method('getFile')
|
||||
->will($this->returnValue('file'));
|
||||
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$event = new ImageCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24);
|
||||
|
||||
$expected = 10;
|
||||
$actual = $fileManager->saveImage($event, $stubProductImage);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::saveDocument
|
||||
*/
|
||||
public function testSaveDocumentProductDocument()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubProductDocument = $this->getMockBuilder('\Thelia\Model\ProductDocument')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubProductDocument->expects($this->any())
|
||||
->method('save')
|
||||
->will($this->returnValue(10));
|
||||
$stubProductDocument->expects($this->any())
|
||||
->method('getFile')
|
||||
->will($this->returnValue('file'));
|
||||
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24);
|
||||
|
||||
$expected = 10;
|
||||
$actual = $fileManager->saveDocument($event, $stubProductDocument);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::saveImage
|
||||
*/
|
||||
public function testSaveImageCategoryImage()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubCategoryImage = $this->getMockBuilder('\Thelia\Model\CategoryImage')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubCategoryImage->expects($this->any())
|
||||
->method('save')
|
||||
->will($this->returnValue(10));
|
||||
$stubCategoryImage->expects($this->any())
|
||||
->method('getFile')
|
||||
->will($this->returnValue('file'));
|
||||
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$event = new ImageCreateOrUpdateEvent(FileManager::TYPE_CATEGORY, 24);
|
||||
|
||||
$expected = 10;
|
||||
$actual = $fileManager->saveImage($event, $stubCategoryImage);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::saveDocument
|
||||
*/
|
||||
public function testSaveDocumentCategoryDocument()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubCategoryDocument = $this->getMockBuilder('\Thelia\Model\CategoryDocument')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubCategoryDocument->expects($this->any())
|
||||
->method('save')
|
||||
->will($this->returnValue(10));
|
||||
$stubCategoryDocument->expects($this->any())
|
||||
->method('getFile')
|
||||
->will($this->returnValue('file'));
|
||||
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_CATEGORY, 24);
|
||||
|
||||
$expected = 10;
|
||||
$actual = $fileManager->saveDocument($event, $stubCategoryDocument);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::saveImage
|
||||
*/
|
||||
public function testSaveImageFolderImage()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubFolderImage = $this->getMockBuilder('\Thelia\Model\FolderImage')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubFolderImage->expects($this->any())
|
||||
->method('save')
|
||||
->will($this->returnValue(10));
|
||||
$stubFolderImage->expects($this->any())
|
||||
->method('getFile')
|
||||
->will($this->returnValue('file'));
|
||||
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$event = new ImageCreateOrUpdateEvent(FileManager::TYPE_FOLDER, 24);
|
||||
|
||||
$expected = 10;
|
||||
$actual = $fileManager->saveImage($event, $stubFolderImage);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::saveDocument
|
||||
*/
|
||||
public function testSaveDocumentFolderDocument()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubFolderDocument = $this->getMockBuilder('\Thelia\Model\FolderDocument')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubFolderDocument->expects($this->any())
|
||||
->method('save')
|
||||
->will($this->returnValue(10));
|
||||
$stubFolderDocument->expects($this->any())
|
||||
->method('getFile')
|
||||
->will($this->returnValue('file'));
|
||||
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_FOLDER, 24);
|
||||
|
||||
$expected = 10;
|
||||
$actual = $fileManager->saveDocument($event, $stubFolderDocument);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::saveImage
|
||||
*/
|
||||
public function testSaveImageContentImage()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubContentImage = $this->getMockBuilder('\Thelia\Model\ContentImage')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubContentImage->expects($this->any())
|
||||
->method('save')
|
||||
->will($this->returnValue(10));
|
||||
$stubContentImage->expects($this->any())
|
||||
->method('getFile')
|
||||
->will($this->returnValue('file'));
|
||||
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$event = new ImageCreateOrUpdateEvent(FileManager::TYPE_CONTENT, 24);
|
||||
|
||||
$expected = 10;
|
||||
$actual = $fileManager->saveImage($event, $stubContentImage);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::saveDocument
|
||||
*/
|
||||
public function testSaveDocumentContentDocument()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubContentDocument = $this->getMockBuilder('\Thelia\Model\ContentDocument')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubContentDocument->expects($this->any())
|
||||
->method('save')
|
||||
->will($this->returnValue(10));
|
||||
$stubContentDocument->expects($this->any())
|
||||
->method('getFile')
|
||||
->will($this->returnValue('file'));
|
||||
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_CONTENT, 24);
|
||||
|
||||
$expected = 10;
|
||||
$actual = $fileManager->saveDocument($event, $stubContentDocument);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::saveImage
|
||||
* @expectedException \Thelia\Exception\ImageException
|
||||
*/
|
||||
public function testSaveImageExceptionImageException()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubProductImage->expects($this->any())
|
||||
->method('save')
|
||||
->will($this->returnValue(10));
|
||||
$stubProductImage->expects($this->any())
|
||||
->method('getFile')
|
||||
->will($this->returnValue('file'));
|
||||
|
||||
$event = new ImageCreateOrUpdateEvent('bad', 24);
|
||||
|
||||
$fileManager->saveImage($event, $stubProductImage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::saveDocument
|
||||
* @expectedException \Thelia\Model\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testSaveDocumentExceptionDocumentException()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$stubProductDocument = $this->getMockBuilder('\Thelia\Model\ProductDocument')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubProductDocument->expects($this->any())
|
||||
->method('save')
|
||||
->will($this->returnValue(10));
|
||||
$stubProductDocument->expects($this->any())
|
||||
->method('getFile')
|
||||
->will($this->returnValue('file'));
|
||||
|
||||
$event = new DocumentCreateOrUpdateEvent('bad', 24);
|
||||
|
||||
$fileManager->saveDocument($event, $stubProductDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::saveImage
|
||||
* @expectedException \Thelia\Exception\ImageException
|
||||
*/
|
||||
public function testSaveImageExceptionImageException2()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubProductImage->expects($this->any())
|
||||
->method('save')
|
||||
->will($this->returnValue(0));
|
||||
$stubProductImage->expects($this->any())
|
||||
->method('getFile')
|
||||
->will($this->returnValue('file'));
|
||||
|
||||
$event = new ImageCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24);
|
||||
|
||||
$fileManager->saveImage($event, $stubProductImage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::saveDocument
|
||||
* @expectedException \Thelia\Model\Exception\InvalidArgumentException
|
||||
*/
|
||||
public function testSaveDocumentExceptionDocumentException2()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$stubProductDocument = $this->getMockBuilder('\Thelia\Model\ProductDocument')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubProductDocument->expects($this->any())
|
||||
->method('save')
|
||||
->will($this->returnValue(0));
|
||||
$stubProductDocument->expects($this->any())
|
||||
->method('getFile')
|
||||
->will($this->returnValue('file'));
|
||||
|
||||
$event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24);
|
||||
|
||||
$fileManager->saveDocument($event, $stubProductDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::sanitizeFileName
|
||||
*/
|
||||
public function testSanitizeFileName()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$fileManager = new FileManager();
|
||||
$badFileName = 'a/ze\érà~çè§^"$*+-_°)(&é<>@#ty2/[\/:*?"<>|]/fi?.fUPPERile.exel../e*';
|
||||
|
||||
$expected = 'azer-_ty2fi.fupperile.exel..e';
|
||||
$actual = $fileManager->sanitizeFileName($badFileName);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::getImageModel
|
||||
*/
|
||||
public function testGetImageModel()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$fileManager = new FileManager();
|
||||
$actual = $fileManager->getImageModel(FileManager::TYPE_PRODUCT);
|
||||
$this->assertInstanceOf('\Thelia\Model\ProductImage', $actual);
|
||||
$actual = $fileManager->getImageModel(FileManager::TYPE_CATEGORY);
|
||||
$this->assertInstanceOf('\Thelia\Model\CategoryImage', $actual);
|
||||
$actual = $fileManager->getImageModel(FileManager::TYPE_CONTENT);
|
||||
$this->assertInstanceOf('\Thelia\Model\ContentImage', $actual);
|
||||
$actual = $fileManager->getImageModel(FileManager::TYPE_FOLDER);
|
||||
$this->assertInstanceOf('\Thelia\Model\FolderImage', $actual);
|
||||
$actual = $fileManager->getImageModel('bad');
|
||||
$this->assertNull($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::getDocumentModel
|
||||
*/
|
||||
public function testGetDocumentModel()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$fileManager = new FileManager();
|
||||
$actual = $fileManager->getDocumentModel(FileManager::TYPE_PRODUCT);
|
||||
$this->assertInstanceOf('\Thelia\Model\ProductDocument', $actual);
|
||||
$actual = $fileManager->getDocumentModel(FileManager::TYPE_CATEGORY);
|
||||
$this->assertInstanceOf('\Thelia\Model\CategoryDocument', $actual);
|
||||
$actual = $fileManager->getDocumentModel(FileManager::TYPE_CONTENT);
|
||||
$this->assertInstanceOf('\Thelia\Model\ContentDocument', $actual);
|
||||
$actual = $fileManager->getDocumentModel(FileManager::TYPE_FOLDER);
|
||||
$this->assertInstanceOf('\Thelia\Model\FolderDocument', $actual);
|
||||
$actual = $fileManager->getDocumentModel('bad');
|
||||
$this->assertNull($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::getImageModelQuery
|
||||
*/
|
||||
public function testGetImageModelQuery()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$fileManager = new FileManager();
|
||||
$actual = $fileManager->getImageModelQuery(FileManager::TYPE_PRODUCT);
|
||||
$this->assertInstanceOf('\Thelia\Model\ProductImageQuery', $actual);
|
||||
$actual = $fileManager->getImageModelQuery(FileManager::TYPE_CATEGORY);
|
||||
$this->assertInstanceOf('\Thelia\Model\CategoryImageQuery', $actual);
|
||||
$actual = $fileManager->getImageModelQuery(FileManager::TYPE_CONTENT);
|
||||
$this->assertInstanceOf('\Thelia\Model\ContentImageQuery', $actual);
|
||||
$actual = $fileManager->getImageModelQuery(FileManager::TYPE_FOLDER);
|
||||
$this->assertInstanceOf('\Thelia\Model\FolderImageQuery', $actual);
|
||||
$actual = $fileManager->getImageModelQuery('bad');
|
||||
$this->assertNull($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::getDocumentModelQuery
|
||||
*/
|
||||
public function testGetDocumentModelQuery()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$fileManager = new FileManager();
|
||||
$actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_PRODUCT);
|
||||
$this->assertInstanceOf('\Thelia\Model\ProductDocumentQuery', $actual);
|
||||
$actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_CATEGORY);
|
||||
$this->assertInstanceOf('\Thelia\Model\CategoryDocumentQuery', $actual);
|
||||
$actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_CONTENT);
|
||||
$this->assertInstanceOf('\Thelia\Model\ContentDocumentQuery', $actual);
|
||||
$actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_FOLDER);
|
||||
$this->assertInstanceOf('\Thelia\Model\FolderDocumentQuery', $actual);
|
||||
$actual = $fileManager->getDocumentModelQuery('bad');
|
||||
$this->assertNull($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::getParentFileModel
|
||||
*/
|
||||
public function testGetParentFileModel()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$fileManager = new FileManager();
|
||||
$actual = $fileManager->getParentFileModel(FileManager::TYPE_PRODUCT, ProductQuery::create()->findOne()->getId());
|
||||
$this->assertInstanceOf('\Thelia\Model\Product', $actual);
|
||||
$actual = $fileManager->getParentFileModel(FileManager::TYPE_CATEGORY, CategoryQuery::create()->findOne()->getId());
|
||||
$this->assertInstanceOf('\Thelia\Model\Category', $actual);
|
||||
$actual = $fileManager->getParentFileModel(FileManager::TYPE_CONTENT, ContentQuery::create()->findOne()->getId());
|
||||
$this->assertInstanceOf('\Thelia\Model\Content', $actual);
|
||||
$actual = $fileManager->getParentFileModel(FileManager::TYPE_FOLDER, FolderQuery::create()->findOne()->getId());
|
||||
$this->assertInstanceOf('\Thelia\Model\Folder', $actual, 1);
|
||||
$actual = $fileManager->getParentFileModel('bad', 1);
|
||||
$this->assertNull($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::getImageForm
|
||||
*/
|
||||
/* public function testGetImageForm()
|
||||
{
|
||||
// Mock issue
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}*/
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::getDocumentForm
|
||||
*/
|
||||
/* public function testGetDocumentForm()
|
||||
{
|
||||
// Mock issue
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::getUploadDir
|
||||
*/
|
||||
public function testGetUploadDir()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$actual = $fileManager->getUploadDir(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals(THELIA_LOCAL_DIR . 'media/images/product', $actual);
|
||||
$actual = $fileManager->getUploadDir(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals(THELIA_LOCAL_DIR . 'media/images/category', $actual);
|
||||
$actual = $fileManager->getUploadDir(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals(THELIA_LOCAL_DIR . 'media/images/content', $actual);
|
||||
$actual = $fileManager->getUploadDir(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals(THELIA_LOCAL_DIR . 'media/images/folder', $actual);
|
||||
$actual = $fileManager->getUploadDir('bad', FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals(false, $actual);
|
||||
|
||||
$actual = $fileManager->getUploadDir(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/product', $actual);
|
||||
$actual = $fileManager->getUploadDir(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/category', $actual);
|
||||
$actual = $fileManager->getUploadDir(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/content', $actual);
|
||||
$actual = $fileManager->getUploadDir(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/folder', $actual);
|
||||
$actual = $fileManager->getUploadDir('bad', FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals(false, $actual);
|
||||
|
||||
$actual = $fileManager->getUploadDir(FileManager::TYPE_FOLDER, 'bad');
|
||||
$this->assertEquals(false, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::getRedirectionUrl
|
||||
*/
|
||||
public function testGetRedirectionUrl()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$actual = $fileManager->getRedirectionUrl(FileManager::TYPE_PRODUCT, 1, FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals('/admin/products/update?product_id=1¤t_tab=images', $actual);
|
||||
$actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CATEGORY, 1, FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals('/admin/categories/update?category_id=1¤t_tab=images', $actual);
|
||||
$actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CONTENT, 1, FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals('/admin/content/update/1?current_tab=images', $actual);
|
||||
$actual = $fileManager->getRedirectionUrl(FileManager::TYPE_FOLDER, 1, FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals('/admin/folders/update/1?current_tab=images', $actual);
|
||||
$actual = $fileManager->getRedirectionUrl('bad', 1, FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals(false, $actual);
|
||||
|
||||
$actual = $fileManager->getRedirectionUrl(FileManager::TYPE_PRODUCT, 1, FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals('/admin/products/update?product_id=1¤t_tab=documents', $actual);
|
||||
$actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CATEGORY, 1, FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals('/admin/categories/update?category_id=1¤t_tab=documents', $actual);
|
||||
$actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CONTENT, 1, FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals('/admin/content/update/1?current_tab=documents', $actual);
|
||||
$actual = $fileManager->getRedirectionUrl(FileManager::TYPE_FOLDER, 1, FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals('/admin/folders/update/1?current_tab=documents', $actual);
|
||||
$actual = $fileManager->getRedirectionUrl('bad', 1, FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals(false, $actual);
|
||||
|
||||
$actual = $fileManager->getRedirectionUrl(FileManager::TYPE_FOLDER, 1, 'bad');
|
||||
$this->assertEquals(false, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::getFormId
|
||||
*/
|
||||
public function testGetFormId()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$actual = $fileManager->getFormId(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals('thelia.admin.product.image.modification', $actual);
|
||||
$actual = $fileManager->getFormId(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals('thelia.admin.category.image.modification', $actual);
|
||||
$actual = $fileManager->getFormId(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals('thelia.admin.content.image.modification', $actual);
|
||||
$actual = $fileManager->getFormId(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals('thelia.admin.folder.image.modification', $actual);
|
||||
$actual = $fileManager->getFormId('bad', FileManager::FILE_TYPE_IMAGES);
|
||||
$this->assertEquals(false, $actual);
|
||||
|
||||
$actual = $fileManager->getFormId(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals('thelia.admin.product.document.modification', $actual);
|
||||
$actual = $fileManager->getFormId(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals('thelia.admin.category.document.modification', $actual);
|
||||
$actual = $fileManager->getFormId(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals('thelia.admin.content.document.modification', $actual);
|
||||
$actual = $fileManager->getFormId(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals('thelia.admin.folder.document.modification', $actual);
|
||||
$actual = $fileManager->getFormId('bad', FileManager::FILE_TYPE_DOCUMENTS);
|
||||
$this->assertEquals(false, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::renameFile
|
||||
*/
|
||||
public function testRenameFile()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubUploadedFile->expects($this->any())
|
||||
->method('getClientOriginalExtension')
|
||||
->will($this->returnValue('yml'));
|
||||
$stubUploadedFile->expects($this->any())
|
||||
->method('getClientOriginalName')
|
||||
->will($this->returnValue('or1-g_n?al*/&é"filen@me#'));
|
||||
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$expected = 'or1-g_nalfilenme-1.yml';
|
||||
$actual = $fileManager->renameFile(1, $stubUploadedFile);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::renameFile
|
||||
*/
|
||||
public function testRenameFileWithoutExtension()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$stubUploadedFile->expects($this->any())
|
||||
->method('getClientOriginalExtension')
|
||||
->will($this->returnValue(''));
|
||||
$stubUploadedFile->expects($this->any())
|
||||
->method('getClientOriginalName')
|
||||
->will($this->returnValue('or1-g_n?al*/&é"filen@me#'));
|
||||
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$expected = 'or1-g_nalfilenme-1';
|
||||
$actual = $fileManager->renameFile(1, $stubUploadedFile);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::isImage
|
||||
*/
|
||||
public function testIsImage()
|
||||
{
|
||||
$stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$actual = $fileManager->isImage('image/jpeg');
|
||||
$this->assertTrue($actual);
|
||||
$actual = $fileManager->isImage('image/png');
|
||||
$this->assertTrue($actual);
|
||||
$actual = $fileManager->isImage('image/gif');
|
||||
$this->assertTrue($actual);
|
||||
|
||||
$actual = $fileManager->isImage('bad');
|
||||
$this->assertFalse($actual);
|
||||
$actual = $fileManager->isImage('image/jpg');
|
||||
$this->assertFalse($actual);
|
||||
$actual = $fileManager->isImage('application/x-msdownload');
|
||||
$this->assertFalse($actual);
|
||||
$actual = $fileManager->isImage('application/x-sh');
|
||||
$this->assertFalse($actual);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::getAvailableTypes
|
||||
*/
|
||||
public function testGetAvailableTypes()
|
||||
{
|
||||
$expected = array(
|
||||
FileManager::TYPE_CATEGORY,
|
||||
FileManager::TYPE_CONTENT,
|
||||
FileManager::TYPE_FOLDER,
|
||||
FileManager::TYPE_PRODUCT,
|
||||
FileManager::TYPE_MODULE,
|
||||
);
|
||||
$actual = FileManager::getAvailableTypes();
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::adminLogAppend
|
||||
*/
|
||||
/* public function testAdminLogAppend()
|
||||
{
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @covers Thelia\Tools\FileManager::deleteFile
|
||||
*/
|
||||
/* public function testDeleteFile()
|
||||
{
|
||||
// @todo see http://tech.vg.no/2011/03/09/mocking-the-file-system-using-phpunit-and-vfsstream/
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}*/
|
||||
}
|
||||
Reference in New Issue
Block a user