diff --git a/core/lib/Thelia/Action/Document.php b/core/lib/Thelia/Action/Document.php
index 228dea9f5..6b5188ba8 100644
--- a/core/lib/Thelia/Action/Document.php
+++ b/core/lib/Thelia/Action/Document.php
@@ -25,7 +25,6 @@ namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-use Symfony\Component\HttpFoundation\File\File;
use Thelia\Core\Event\DocumentCreateOrUpdateEvent;
use Thelia\Core\Event\DocumentDeleteEvent;
use Thelia\Core\Event\DocumentEvent;
@@ -163,6 +162,7 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
$model = $event->getModelDocument();
$nbModifiedLines = $model->save();
+
$event->setModelDocument($model);
if (!$nbModifiedLines) {
@@ -202,6 +202,10 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
)
);
+ if (null !== $event->getUploadedFile()) {
+ $event->getModelDocument()->setTitle($event->getUploadedFile()->getClientOriginalName());
+ }
+
$fileManager = new FileManager($this->container);
// Copy and save file
if ($event->getUploadedFile()) {
diff --git a/core/lib/Thelia/Controller/Admin/FileController.php b/core/lib/Thelia/Controller/Admin/FileController.php
index 25c7d5dfa..f43f30fe6 100755
--- a/core/lib/Thelia/Controller/Admin/FileController.php
+++ b/core/lib/Thelia/Controller/Admin/FileController.php
@@ -181,9 +181,8 @@ class FileController extends BaseAdminController
return new Response('', 404);
}
- $defaultTitle = $parentModel->getTitle();
$documentModel->setParentId($parentId);
- $documentModel->setTitle($defaultTitle);
+ $documentModel->setTitle($fileBeingUploaded->getClientOriginalName());
$documentCreateOrUpdateEvent = new DocumentCreateOrUpdateEvent(
$parentType,
@@ -292,12 +291,13 @@ class FileController extends BaseAdminController
try {
$fileManager = new FileManager($this->container);
$image = $fileManager->getImageModelQuery($parentType)->findPk($imageId);
- $redirectUrl = $fileManager->getRedirectionUrl($parentType, $image->getParentId());
+ $redirectUrl = $fileManager->getRedirectionUrl($parentType, $image->getParentId(), FileManager::FILE_TYPE_IMAGES);
return $this->render('image-edit', array(
'imageId' => $imageId,
'imageType' => $parentType,
- 'redirectUrl' => $redirectUrl
+ 'redirectUrl' => $redirectUrl,
+ 'formId' => $fileManager->getFormId($parentType, FileManager::FILE_TYPE_IMAGES)
));
} catch (\Exception $e) {
$this->pageNotFound();
@@ -320,12 +320,13 @@ class FileController extends BaseAdminController
try {
$fileManager = new FileManager($this->container);
$document = $fileManager->getDocumentModelQuery($parentType)->findPk($documentId);
- $redirectUrl = $fileManager->getRedirectionUrl($parentType, $document->getParentId());
+ $redirectUrl = $fileManager->getRedirectionUrl($parentType, $document->getParentId(), FileManager::FILE_TYPE_DOCUMENTS);
return $this->render('document-edit', array(
'documentId' => $documentId,
'documentType' => $parentType,
- 'redirectUrl' => $redirectUrl
+ 'redirectUrl' => $redirectUrl,
+ 'formId' => $fileManager->getFormId($parentType, FileManager::FILE_TYPE_DOCUMENTS)
));
} catch (\Exception $e) {
$this->pageNotFound();
@@ -399,9 +400,13 @@ class FileController extends BaseAdminController
->setGeneralError($message);
}
+ $redirectUrl = $fileManager->getRedirectionUrl($parentType, $image->getParentId(), FileManager::FILE_TYPE_IMAGES);
+
return $this->render('image-edit', array(
'imageId' => $imageId,
- 'imageType' => $parentType
+ 'imageType' => $parentType,
+ 'redirectUrl' => $redirectUrl,
+ 'formId' => $fileManager->getFormId($parentType, FileManager::FILE_TYPE_IMAGES)
));
}
@@ -415,14 +420,14 @@ class FileController extends BaseAdminController
*/
public function updateDocumentAction($documentId, $parentType)
{
- if (null !== $response = $this->checkAuth('admin.image.update')) {
+ if (null !== $response = $this->checkAuth('admin.document.update')) {
return $response;
}
$message = false;
$fileManager = new FileManager($this->container);
- $documentModification = $fileManager->getImageForm($parentType, $this->getRequest());
+ $documentModification = $fileManager->getDocumentForm($parentType, $this->getRequest());
try {
$document = $fileManager->getDocumentModelQuery($parentType)->findPk($documentId);
@@ -433,8 +438,8 @@ class FileController extends BaseAdminController
$form = $this->validateForm($documentModification);
- $event = $this->createImageEventInstance($parentType, $document, $form->getData());
- $event->setOldModelImage($oldDocument);
+ $event = $this->createDocumentEventInstance($parentType, $document, $form->getData());
+ $event->setOldModelDocument($oldDocument);
$files = $this->getRequest()->files;
$fileForm = $files->get($documentModification->getName());
@@ -444,7 +449,7 @@ class FileController extends BaseAdminController
$this->dispatch(TheliaEvents::DOCUMENT_UPDATE, $event);
- $documentUpdated = $event->getModelImage();
+ $documentUpdated = $event->getModelDocument();
$this->adminLogAppend(sprintf('Document with Ref %s (ID %d) modified', $documentUpdated->getTitle(), $documentUpdated->getId()));
@@ -472,9 +477,13 @@ class FileController extends BaseAdminController
->setGeneralError($message);
}
+ $redirectUrl = $fileManager->getRedirectionUrl($parentType, $document->getParentId(), FileManager::FILE_TYPE_DOCUMENTS);
+
return $this->render('document-edit', array(
'documentId' => $documentId,
- 'documentType' => $parentType
+ 'documentType' => $parentType,
+ 'redirectUrl' => $redirectUrl,
+ 'formId' => $fileManager->getFormId($parentType, FileManager::FILE_TYPE_DOCUMENTS)
));
}
@@ -640,7 +649,7 @@ class FileController extends BaseAdminController
* @param CategoryDocument|ProductDocument|ContentDocument|FolderDocument $model Document model
* @param array $data Post data
*
- * @return ImageCreateOrUpdateEvent
+ * @return DocumentCreateOrUpdateEvent
*/
protected function createDocumentEventInstance($parentType, $model, $data)
{
diff --git a/core/lib/Thelia/Core/Event/DocumentDeleteEvent.php b/core/lib/Thelia/Core/Event/DocumentDeleteEvent.php
index 16bb86229..d9e2b7161 100755
--- a/core/lib/Thelia/Core/Event/DocumentDeleteEvent.php
+++ b/core/lib/Thelia/Core/Event/DocumentDeleteEvent.php
@@ -56,7 +56,7 @@ class DocumentDeleteEvent extends ActionEvent
*/
public function __construct($documentToDelete, $documentType)
{
- $this->imageToDelete = $documentToDelete;
+ $this->documentToDelete = $documentToDelete;
$this->documentType = $documentType;
}
@@ -93,7 +93,7 @@ class DocumentDeleteEvent extends ActionEvent
*/
public function setDocumentToDelete($documentToDelete)
{
- $this->imageToDelete = $documentToDelete;
+ $this->documentToDelete = $documentToDelete;
return $this;
}
diff --git a/core/lib/Thelia/Tools/FileManager.php b/core/lib/Thelia/Tools/FileManager.php
index e5614202d..45c633fde 100644
--- a/core/lib/Thelia/Tools/FileManager.php
+++ b/core/lib/Thelia/Tools/FileManager.php
@@ -443,6 +443,48 @@ class FileManager
return $model;
}
+ /**
+ * Get form service id from type
+ *
+ * @param string $parentType
+ *
+ * @return string
+ *
+ * @todo refactor make all documents using propel inheritance and factorise image behaviour into one single clean action
+ */
+ public function getFormId($parentType, $fileType)
+ {
+ switch ($fileType) {
+ case self::FILE_TYPE_IMAGES:
+ $type = 'image';
+ break;
+ case self::FILE_TYPE_DOCUMENTS:
+ $type = 'document';
+ break;
+ default:
+ return false;
+ }
+
+ switch ($parentType) {
+ case self::TYPE_PRODUCT:
+ $formId = 'thelia.admin.product.' . $type . '.modification';
+ break;
+ case self::TYPE_CATEGORY:
+ $formId = 'thelia.admin.category.' . $type . '.modification';
+ break;
+ case self::TYPE_CONTENT:
+ $formId = 'thelia.admin.content.' . $type . '.modification';
+ break;
+ case self::TYPE_FOLDER:
+ $formId = 'thelia.admin.folder.' . $type . '.modification';
+ break;
+ default:
+ $formId = false;
+ }
+
+ return $formId;
+ }
+
/**
* Get image parent model from type
*
@@ -577,24 +619,30 @@ class FileManager
/**
* Deduce image redirecting URL from parent type
*
- * @param string $parentType Parent type
+ * @param string $parentType Parent type ex : self::TYPE_PRODUCT
* @param int $parentId Parent id
+ * @param string $fileType File type ex : self::FILE_TYPE_DOCUMENTS
+ *
* @return string
*/
- public function getRedirectionUrl($parentType, $parentId)
+ public function getRedirectionUrl($parentType, $parentId, $fileType)
{
+ if (!in_array($fileType, self::$availableFileType)) {
+ return false;
+ }
+
switch ($parentType) {
case self::TYPE_PRODUCT:
- $uri = '/admin/products/update?product_id=' . $parentId . '¤t_tab=images';
+ $uri = '/admin/products/update?product_id=' . $parentId . '¤t_tab=' . $fileType;
break;
case self::TYPE_CATEGORY:
- $uri = '/admin/categories/update?category_id=' . $parentId . '¤t_tab=images';
+ $uri = '/admin/categories/update?category_id=' . $parentId . '¤t_tab=' . $fileType;
break;
case self::TYPE_CONTENT:
- $uri = '/admin/content/update/' . $parentId . '¤t_tab=images';
+ $uri = '/admin/content/update/' . $parentId . '?current_tab=' . $fileType;
break;
case self::TYPE_FOLDER:
- $uri = '/admin/folders/update/' . $parentId . '¤t_tab=images';
+ $uri = '/admin/folders/update/' . $parentId . '?current_tab=' . $fileType;
break;
default:
$uri = false;
diff --git a/templates/admin/default/assets/js/document-upload.js b/templates/admin/default/assets/js/document-upload.js
index cd022cd93..dc35ea943 100644
--- a/templates/admin/default/assets/js/document-upload.js
+++ b/templates/admin/default/assets/js/document-upload.js
@@ -8,6 +8,8 @@ $(function($){
// Remove image on click
$.documentUploadManager.initDocumentDropZone = function() {
+ $.documentUploadManager.onClickDeleteDocument();
+
var documentDropzone = new Dropzone("#documents-dropzone", {
dictDefaultMessage : $('.btn-browse').html(),
uploadMultiple: false,
@@ -95,5 +97,4 @@ $(function($){
return false;
});
};
- $.documentUploadManager.onClickDeleteDocument();
});
diff --git a/templates/admin/default/assets/js/image-upload.js b/templates/admin/default/assets/js/image-upload.js
index bd3d12dea..c2ef15ad4 100644
--- a/templates/admin/default/assets/js/image-upload.js
+++ b/templates/admin/default/assets/js/image-upload.js
@@ -8,6 +8,8 @@ $(function($){
// Remove image on click
$.imageUploadManager.initImageDropZone = function() {
+ $.imageUploadManager.onClickDeleteImage();
+
var imageDropzone = new Dropzone("#images-dropzone", {
dictDefaultMessage : $('.btn-browse').html(),
uploadMultiple: false,
@@ -96,5 +98,4 @@ $(function($){
return false;
});
};
- $.imageUploadManager.onClickDeleteImage();
});
diff --git a/templates/admin/default/content-edit.html b/templates/admin/default/content-edit.html
index f4eb063cf..c891897cc 100644
--- a/templates/admin/default/content-edit.html
+++ b/templates/admin/default/content-edit.html
@@ -250,6 +250,7 @@
+ {include file='includes/document-upload-form.html' documentType='content' parentId=$content_id}
@@ -293,10 +294,14 @@ form_content = {$smarty.capture.delete_content_dialog nofilter}
{javascripts file='assets/js/image-upload.js'}
{/javascripts}
+ {javascripts file='assets/js/document-upload.js'}
+
+ {/javascripts}
{/javascripts}
+ {javascripts file='assets/js/document-upload.js'}
+
+ {/javascripts}
{javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'}
{/javascripts}
diff --git a/tests/functionnal/casperjs/exe/00_parameters.js b/tests/functionnal/casperjs/exe/00_parameters.js
index df5470229..813f73c32 100644
--- a/tests/functionnal/casperjs/exe/00_parameters.js
+++ b/tests/functionnal/casperjs/exe/00_parameters.js
@@ -9,6 +9,13 @@ var thelia2_login_coupon_update_url = thelia2_base_url + 'admin/coupon/update/1'
+var thelia2_category_image_list_url = thelia2_base_url + 'admin/categories/update?category_id=1';
+var thelia2_product_image_list_url = thelia2_base_url + 'admin/products/update?product_id=1';
+var thelia2_folder_image_list_url = thelia2_base_url + 'admin/folders/update/1';
+var thelia2_content_image_list_url = thelia2_base_url + 'admin/content/update/1';
+
+
+
//var findMyId = /([0-9]+)$/;
//var currentId;
diff --git a/tests/functionnal/casperjs/exe/30_coupons.js b/tests/functionnal/casperjs/exe/30_coupons.js
index 2147c14cf..073ccbb08 100644
--- a/tests/functionnal/casperjs/exe/30_coupons.js
+++ b/tests/functionnal/casperjs/exe/30_coupons.js
@@ -12,145 +12,145 @@
casper.test.comment('Testing coupons');
////LIST
-// @todo implement
-
-////CREATE
-casper.start(thelia2_login_coupon_create_url, function() {
- this.test.assertHttpStatus(200);
- this.test.comment('Now on : ' + this.getCurrentUrl());
- this.capture('tests/functionnal/casperjs/screenshot/coupons/init.png');
- this.test.comment('COUPON - CREATE EMPTY');
-
- // Click on is unlimited button
- this.click("form #is-unlimited");
- this.sendKeys('input#max-usage', '-2');
-
- // cleaning expiration date default value
- this.evaluate(function() {
- $("#expiration-date").val('').change();
- return true;
- });
-
- this.capture('tests/functionnal/casperjs/screenshot/coupons/creating-new-coupon.png');
- this.click("form .control-group .btn.btn-default.btn-primary");
-
-});
-
-casper.wait(1000, function() {
- this.echo("\nWaiting....");
-});
-
-// Test Coupon creation if no input
-casper.then(function(){
- this.test.assertHttpStatus(200);
- this.capture('tests/functionnal/casperjs/screenshot/coupons/created-new-empty-coupon.png');
- this.test.assertExists('.has-error #code', 'Error on code input found');
- this.test.assertExists('.has-error #title', 'Error on title input found');
-
- this.test.assertExists('.has-error #expiration-date', 'Error on expiration date input found');
- this.test.assertExists('.has-error #max-usage', 'Error on max usage input found');
- this.test.assertExists('.has-error #description', 'Error on description input found');
- this.test.assertExists('.has-error #effect', 'Error on effect input found');
- this.test.assertExists('.has-error #amount', 'Error on amount input found');
- this.test.assertExists('.has-error #short-description', 'Error on short-description input found');
-});
-
-// Test Coupon creation if good input
-casper.then(function(){
-
- this.sendKeys('input#code', 'XMAS10');
- this.sendKeys('input#title', 'christmas');
- this.click("form #is-enabled");
- this.click("form #is-available-on-special-offers");
- this.click("form #is-cumulative");
- this.click("form #is-removing-postage");
-
- this.evaluate(function() {
- $("#expiration-date").val('2013-11-14').change();
- return true;
- });
-
- // Click on is unlimited button
- this.click("form #is-unlimited");
- this.sendKeys('input#max-usage', '40');
-
- this.evaluate(function() {
- $('#effect').val('thelia.coupon.type.remove_x_amount').change();
- return true;
- });
-
- this.test.assertSelectorHasText(
- '#effectToolTip',
- this.evaluate(function () {
- return $("#effect option[value^='thelia.coupon.type.remove_x_amount']").attr('data-description');
- }),
- 'Tooltip found'
- );
- this.sendKeys('input#amount', '42.12');
- this.sendKeys('#short-description', 'Mauris sed risus imperdiet, blandit arcu ac, tempus metus. Aliquam erat volutpat. Nullam dictum sed.');
- this.sendKeys('#description', 'Etiam sodales non nisi a condimentum. Morbi luctus mauris mattis sem ornare; ac blandit tortor porta! Sed vel viverra dolor. Nulla eget viverra eros. Donec rutrum felis ut quam blandit, eu massa nunc.');
-
- this.capture('tests/functionnal/casperjs/screenshot/coupons/coupon-created-ready-to-be-saved.png');
- this.click("#save-coupon-btn");
-});
-
-casper.wait(2000, function() {
- this.echo("\nWaiting....");
-});
-
-// Test Coupon creation if good input is well saved
-casper.then(function(){
- this.test.assertHttpStatus(302);
- this.test.comment('Now on : ' + this.getCurrentUrl());
- this.capture('tests/functionnal/casperjs/screenshot/coupons/created-new-coupon.png');
- this.test.assertField('thelia_coupon_creation[code]', 'XMAS10', 'Code found');
- this.test.assertField('thelia_coupon_creation[title]', 'christmas', 'Title found');
-
- this.test.assert(this.evaluate(function () {
- return document.getElementById('is-enabled').checked;
- }), 'Checkbox is enabled checked');
- this.test.assert(this.evaluate(function () {
- return document.getElementById('is-available-on-special-offers').checked;
- }), 'Checkbox is available on special offers checked');
- this.test.assert(this.evaluate(function () {
- return document.getElementById('is-cumulative').checked;
- }), 'Checkbox is cumulative checked');
- this.test.assert(this.evaluate(function () {
- return document.getElementById('is-removing-postage').checked;
- }), 'Checkbox is cumulative checked');
-
- this.test.assertField('thelia_coupon_creation[expirationDate]', '2013-11-14', 'Expiration date found');
- this.test.assertField('thelia_coupon_creation[maxUsage]', '40', 'Max usage found');
- this.test.assert(this.evaluate(function () {
- return !document.getElementById('is-unlimited').checked;
- }), 'Checkbox is unlimited not checked');
-
- this.test.assert(
- this.evaluate(function () {
- return $("#effect").val();
- }),
- 'thelia.coupon.type.remove_x_amount',
- 'Effect found'
- );
- this.test.assertSelectorHasText(
- '#effectToolTip',
- this.evaluate(function () {
- return $("#effect option[value^='thelia.coupon.type.remove_x_amount']").attr('data-description');
- }),
- 'Tooltip found'
- );
- this.test.assertField('thelia_coupon_creation[amount]', '42.12', 'Amount found');
-
- this.test.assertField('thelia_coupon_creation[shortDescription]', 'Mauris sed risus imperdiet, blandit arcu ac, tempus metus. Aliquam erat volutpat. Nullam dictum sed.', 'Short description found');
- this.test.assertField('thelia_coupon_creation[description]', 'Etiam sodales non nisi a condimentum. Morbi luctus mauris mattis sem ornare; ac blandit tortor porta! Sed vel viverra dolor. Nulla eget viverra eros. Donec rutrum felis ut quam blandit, eu massa nunc.', 'Description found');
-
-
-});
-////EDIT CHECK
-// @todo implement
-
-////DELETE
-// @todo implement
+////@todo implement
+//
+//////CREATE
+//casper.start(thelia2_login_coupon_create_url, function() {
+// this.test.assertHttpStatus(200);
+// this.test.comment('Now on : ' + this.getCurrentUrl());
+// this.capture('tests/functionnal/casperjs/screenshot/coupons/init.png');
+// this.test.comment('COUPON - CREATE EMPTY');
+//
+// // Click on is unlimited button
+// this.click("form #is-unlimited");
+// this.sendKeys('input#max-usage', '-2');
+//
+// // cleaning expiration date default value
+// this.evaluate(function() {
+// $("#expiration-date").val('').change();
+// return true;
+// });
+//
+// this.capture('tests/functionnal/casperjs/screenshot/coupons/creating-new-coupon.png');
+// this.click("form .control-group .btn.btn-default.btn-primary");
+//
+//});
+//
+//casper.wait(1000, function() {
+// this.echo("\nWaiting....");
+//});
+//
+//// Test Coupon creation if no input
+//casper.then(function(){
+// this.test.assertHttpStatus(200);
+// this.capture('tests/functionnal/casperjs/screenshot/coupons/created-new-empty-coupon.png');
+// this.test.assertExists('.has-error #code', 'Error on code input found');
+// this.test.assertExists('.has-error #title', 'Error on title input found');
+//
+// this.test.assertExists('.has-error #expiration-date', 'Error on expiration date input found');
+// this.test.assertExists('.has-error #max-usage', 'Error on max usage input found');
+// this.test.assertExists('.has-error #description', 'Error on description input found');
+// this.test.assertExists('.has-error #effect', 'Error on effect input found');
+// this.test.assertExists('.has-error #amount', 'Error on amount input found');
+// this.test.assertExists('.has-error #short-description', 'Error on short-description input found');
+//});
+//
+//// Test Coupon creation if good input
+//casper.then(function(){
+//
+// this.sendKeys('input#code', 'XMAS10');
+// this.sendKeys('input#title', 'christmas');
+// this.click("form #is-enabled");
+// this.click("form #is-available-on-special-offers");
+// this.click("form #is-cumulative");
+// this.click("form #is-removing-postage");
+//
+// this.evaluate(function() {
+// $("#expiration-date").val('2013-11-14').change();
+// return true;
+// });
+//
+// // Click on is unlimited button
+// this.click("form #is-unlimited");
+// this.sendKeys('input#max-usage', '40');
+//
+// this.evaluate(function() {
+// $('#effect').val('thelia.coupon.type.remove_x_amount').change();
+// return true;
+// });
+//
+// this.test.assertSelectorHasText(
+// '#effectToolTip',
+// this.evaluate(function () {
+// return $("#effect option[value^='thelia.coupon.type.remove_x_amount']").attr('data-description');
+// }),
+// 'Tooltip found'
+// );
+// this.sendKeys('input#amount', '42.12');
+// this.sendKeys('#short-description', 'Mauris sed risus imperdiet, blandit arcu ac, tempus metus. Aliquam erat volutpat. Nullam dictum sed.');
+// this.sendKeys('#description', 'Etiam sodales non nisi a condimentum. Morbi luctus mauris mattis sem ornare; ac blandit tortor porta! Sed vel viverra dolor. Nulla eget viverra eros. Donec rutrum felis ut quam blandit, eu massa nunc.');
+//
+// this.capture('tests/functionnal/casperjs/screenshot/coupons/coupon-created-ready-to-be-saved.png');
+// this.click("#save-coupon-btn");
+//});
+//
+//casper.wait(2000, function() {
+// this.echo("\nWaiting....");
+//});
+//
+//// Test Coupon creation if good input is well saved
+//casper.then(function(){
+// this.test.assertHttpStatus(302);
+// this.test.comment('Now on : ' + this.getCurrentUrl());
+// this.capture('tests/functionnal/casperjs/screenshot/coupons/created-new-coupon.png');
+// this.test.assertField('thelia_coupon_creation[code]', 'XMAS10', 'Code found');
+// this.test.assertField('thelia_coupon_creation[title]', 'christmas', 'Title found');
+//
+// this.test.assert(this.evaluate(function () {
+// return document.getElementById('is-enabled').checked;
+// }), 'Checkbox is enabled checked');
+// this.test.assert(this.evaluate(function () {
+// return document.getElementById('is-available-on-special-offers').checked;
+// }), 'Checkbox is available on special offers checked');
+// this.test.assert(this.evaluate(function () {
+// return document.getElementById('is-cumulative').checked;
+// }), 'Checkbox is cumulative checked');
+// this.test.assert(this.evaluate(function () {
+// return document.getElementById('is-removing-postage').checked;
+// }), 'Checkbox is cumulative checked');
+//
+// this.test.assertField('thelia_coupon_creation[expirationDate]', '2013-11-14', 'Expiration date found');
+// this.test.assertField('thelia_coupon_creation[maxUsage]', '40', 'Max usage found');
+// this.test.assert(this.evaluate(function () {
+// return !document.getElementById('is-unlimited').checked;
+// }), 'Checkbox is unlimited not checked');
+//
+// this.test.assert(
+// this.evaluate(function () {
+// return $("#effect").val();
+// }),
+// 'thelia.coupon.type.remove_x_amount',
+// 'Effect found'
+// );
+// this.test.assertSelectorHasText(
+// '#effectToolTip',
+// this.evaluate(function () {
+// return $("#effect option[value^='thelia.coupon.type.remove_x_amount']").attr('data-description');
+// }),
+// 'Tooltip found'
+// );
+// this.test.assertField('thelia_coupon_creation[amount]', '42.12', 'Amount found');
+//
+// this.test.assertField('thelia_coupon_creation[shortDescription]', 'Mauris sed risus imperdiet, blandit arcu ac, tempus metus. Aliquam erat volutpat. Nullam dictum sed.', 'Short description found');
+// this.test.assertField('thelia_coupon_creation[description]', 'Etiam sodales non nisi a condimentum. Morbi luctus mauris mattis sem ornare; ac blandit tortor porta! Sed vel viverra dolor. Nulla eget viverra eros. Donec rutrum felis ut quam blandit, eu massa nunc.', 'Description found');
+//
+//
+//});
+//////EDIT CHECK
+//// @todo implement
+//
+//////DELETE
+//// @todo implement
//RUN
casper.run(function() {
diff --git a/tests/functionnal/casperjs/exe/31_coupons_rule.js b/tests/functionnal/casperjs/exe/31_coupons_rule.js
index 66706aada..219802903 100644
--- a/tests/functionnal/casperjs/exe/31_coupons_rule.js
+++ b/tests/functionnal/casperjs/exe/31_coupons_rule.js
@@ -9,7 +9,7 @@
//// verbose:true
////});
//
-//casper.test.comment('Testing coupons rules');
+casper.test.comment('Testing coupons rules');
//
////UPDATE COUPON RULE
//casper.start(thelia2_login_coupon_update_url, function() {
@@ -306,7 +306,7 @@
// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)');
//});
//
-////RUN
-//casper.run(function() {
-// this.test.done();
-//});
\ No newline at end of file
+//RUN
+casper.run(function() {
+ this.test.done();
+});
\ No newline at end of file
diff --git a/tests/functionnal/casperjs/exe/40_images_management.js b/tests/functionnal/casperjs/exe/40_images_management.js
new file mode 100644
index 000000000..a982f84ff
--- /dev/null
+++ b/tests/functionnal/casperjs/exe/40_images_management.js
@@ -0,0 +1,77 @@
+//
+//var casper = require('casper').create({
+// viewportSize:{
+// width:1024, height:768
+// },
+// pageSettings:{
+// userAgent:'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11'
+// },
+// verbose:true
+//});
+
+casper.test.comment('Testing Image Management');
+
+// Image list
+// @todo implement
+////CREATE
+casper.start(thelia2_category_image_list_url, function() {
+ this.test.assertHttpStatus(200);
+ this.test.comment('Now on : ' + this.getCurrentUrl());
+ this.capture('tests/functionnal/casperjs/screenshot/category/images/init.png');
+ this.test.comment('CATEGORY : IMAGES - CREATE');
+
+ // Click on is unlimited button
+ this.clickLabel('Images', 'a');
+
+});
+
+casper.wait(1000, function() {
+ this.echo("\nWaiting....");
+});
+
+// Test Coupon creation if no input
+casper.then(function(){
+ this.capture('tests/functionnal/casperjs/screenshot/category/images/init-tab-image.png');
+ this.test.assertExists('.existing-image tr:nth-child(1)', 'First image found');
+
+ this.click('.existing-image tr:nth-child(1) .image-update-btn');
+
+});
+
+casper.wait(1000, function() {
+ this.echo("\nWaiting....");
+
+});
+
+// Test Coupon creation if no input
+casper.then(function(){
+ this.test.assertHttpStatus(200);
+ this.test.comment('Now on : ' + this.getCurrentUrl());
+ this.capture('tests/functionnal/casperjs/screenshot/category/images/read-image.png');
+});
+
+// Image add 1
+// @todo implement
+
+// Image add 4
+// @todo implement
+
+// Image read
+// @todo implement
+
+// Image update
+// @todo implement
+
+// Image delete
+// @todo implement
+
+// Image links
+// @todo implement
+
+// Image i18n
+// @todo implement
+
+//RUN
+casper.run(function() {
+ this.test.done();
+});
\ No newline at end of file