Working : Fix : Unit test
This commit is contained in:
@@ -740,9 +740,46 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase {
|
|||||||
$this->assertEquals('/admin/folders/update/1?current_tab=documents', $actual);
|
$this->assertEquals('/admin/folders/update/1?current_tab=documents', $actual);
|
||||||
$actual = $fileManager->getRedirectionUrl('bad', 1, FileManager::FILE_TYPE_DOCUMENTS);
|
$actual = $fileManager->getRedirectionUrl('bad', 1, FileManager::FILE_TYPE_DOCUMENTS);
|
||||||
$this->assertEquals(false, $actual);
|
$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($stubContainer);
|
||||||
|
|
||||||
|
$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
|
* @covers Thelia\Tools\FileManager::renameFile
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ class FileManager
|
|||||||
* Delete image from file storage and database
|
* Delete image from file storage and database
|
||||||
*
|
*
|
||||||
* @param CategoryImage|ProductImage|ContentImage|FolderImage|CategoryDocument|ProductDocument|ContentDocument|FolderDocument $model File being deleted
|
* @param CategoryImage|ProductImage|ContentImage|FolderImage|CategoryDocument|ProductDocument|ContentDocument|FolderDocument $model File being deleted
|
||||||
* @param string $parentType Parent type
|
* @param string $parentType Parent type ex : self::TYPE_PRODUCT
|
||||||
* @param string $fileType File type ex FileManager::FILE_TYPE_DOCUMENTS
|
* @param string $fileType File type ex FileManager::FILE_TYPE_DOCUMENTS
|
||||||
*
|
*
|
||||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||||
@@ -322,7 +322,7 @@ class FileManager
|
|||||||
/**
|
/**
|
||||||
* Get image model from type
|
* Get image model from type
|
||||||
*
|
*
|
||||||
* @param string $parentType Parent type
|
* @param string $parentType Parent type ex : self::TYPE_PRODUCT
|
||||||
*
|
*
|
||||||
* @return null|\Thelia\Model\CategoryImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage|\Thelia\Model\ProductImage
|
* @return null|\Thelia\Model\CategoryImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage|\Thelia\Model\ProductImage
|
||||||
*
|
*
|
||||||
@@ -353,7 +353,7 @@ class FileManager
|
|||||||
/**
|
/**
|
||||||
* Get document model from type
|
* Get document model from type
|
||||||
*
|
*
|
||||||
* @param string $parentType Parent type
|
* @param string $parentType Parent type ex : self::TYPE_PRODUCT
|
||||||
*
|
*
|
||||||
* @return null|ProductDocument|CategoryDocument|ContentDocument|FolderDocument
|
* @return null|ProductDocument|CategoryDocument|ContentDocument|FolderDocument
|
||||||
*
|
*
|
||||||
@@ -384,7 +384,7 @@ class FileManager
|
|||||||
/**
|
/**
|
||||||
* Get image model query from type
|
* Get image model query from type
|
||||||
*
|
*
|
||||||
* @param string $parentType
|
* @param string $parentType Parent type ex : self::TYPE_PRODUCT
|
||||||
*
|
*
|
||||||
* @return null|\Thelia\Model\CategoryImageQuery|\Thelia\Model\ContentImageQuery|\Thelia\Model\FolderImageQuery|\Thelia\Model\ProductImageQuery
|
* @return null|\Thelia\Model\CategoryImageQuery|\Thelia\Model\ContentImageQuery|\Thelia\Model\FolderImageQuery|\Thelia\Model\ProductImageQuery
|
||||||
*
|
*
|
||||||
@@ -415,7 +415,7 @@ class FileManager
|
|||||||
/**
|
/**
|
||||||
* Get document model query from type
|
* Get document model query from type
|
||||||
*
|
*
|
||||||
* @param string $parentType
|
* @param string $parentType Parent type ex : self::TYPE_PRODUCT
|
||||||
*
|
*
|
||||||
* @return null|ProductDocumentQuery|CategoryDocumentQuery|ContentDocumentQuery|FolderDocumentQuery
|
* @return null|ProductDocumentQuery|CategoryDocumentQuery|ContentDocumentQuery|FolderDocumentQuery
|
||||||
*
|
*
|
||||||
@@ -446,7 +446,8 @@ class FileManager
|
|||||||
/**
|
/**
|
||||||
* Get form service id from type
|
* Get form service id from type
|
||||||
*
|
*
|
||||||
* @param string $parentType
|
* @param string $parentType Parent type ex : self::TYPE_PRODUCT
|
||||||
|
* @param string $fileType Parent id
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
@@ -488,8 +489,8 @@ class FileManager
|
|||||||
/**
|
/**
|
||||||
* Get image parent model from type
|
* Get image parent model from type
|
||||||
*
|
*
|
||||||
* @param string $parentType
|
* @param string $parentType Parent type ex : self::TYPE_PRODUCT
|
||||||
* @param int $parentId
|
* @param int $parentId Parent Id
|
||||||
*
|
*
|
||||||
* @return null|\Thelia\Model\Category|\Thelia\Model\Content|\Thelia\Model\Folder|\Thelia\Model\Product
|
* @return null|\Thelia\Model\Category|\Thelia\Model\Content|\Thelia\Model\Folder|\Thelia\Model\Product
|
||||||
*
|
*
|
||||||
@@ -520,7 +521,7 @@ class FileManager
|
|||||||
/**
|
/**
|
||||||
* Get image parent model from type
|
* Get image parent model from type
|
||||||
*
|
*
|
||||||
* @param string $parentType Parent type
|
* @param string $parentType Parent type ex : self::TYPE_PRODUCT
|
||||||
* @param Request $request Request service
|
* @param Request $request Request service
|
||||||
*
|
*
|
||||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||||
@@ -552,7 +553,7 @@ class FileManager
|
|||||||
/**
|
/**
|
||||||
* Get document parent model from type
|
* Get document parent model from type
|
||||||
*
|
*
|
||||||
* @param string $parentType Parent type
|
* @param string $parentType Parent type ex : self::TYPE_PRODUCT
|
||||||
* @param Request $request Request service
|
* @param Request $request Request service
|
||||||
*
|
*
|
||||||
* @todo refactor make all document using propel inheritance and factorise image behaviour into one single clean action
|
* @todo refactor make all document using propel inheritance and factorise image behaviour into one single clean action
|
||||||
@@ -585,7 +586,7 @@ class FileManager
|
|||||||
* Get image upload dir
|
* Get image upload dir
|
||||||
*
|
*
|
||||||
* @param string $parentType Parent type ex FileManager::TYPE_PRODUCT
|
* @param string $parentType Parent type ex FileManager::TYPE_PRODUCT
|
||||||
* @param string $fileType File type
|
* @param string $fileType File type ex : self::FILE_TYPE_DOCUMENTS
|
||||||
*
|
*
|
||||||
* @return string Uri
|
* @return string Uri
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user