From 9338cdb472d3bcdd48ea2f0d833463a034096b28 Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 22:05:33 +0200 Subject: [PATCH 001/192] Merge branch 'master' of https://github.com/thelia/thelia into coupon # By Manuel Raynaud (19) and others # Via Manuel Raynaud (5) and others * 'master' of https://github.com/thelia/thelia: (37 commits) add PropelDataCollector to debugbar, still missing some informations remove unused class integrate debugbar module remove htmlpurifier modify insert.sql including debugBar module add new event and new tag Started category modification Factorized modal dialogs javascript Factorized creation and confirmation modal dialogs create controller adding delivery module in session create Delivery loop Working : Continuing categories administration... Working : create base loop for delivery and payment entities remove htmlpurifier dependency country id can be an argument for calculate method Working : Working : fix typo ... Conflicts: composer.lock core/lib/Thelia/Controller/Admin/CategoryController.php templates/admin/default/assets/less/thelia/variables.less --- local/modules/Colissimo/Colissimo.php | 0 local/modules/Colissimo/Config/config.xml | 0 local/modules/Colissimo/Config/plugin.xml | 0 local/modules/Colissimo/Config/schema.xml | 0 local/modules/DebugBar/Config/config.xml | 0 local/modules/DebugBar/Config/plugin.xml | 0 local/modules/DebugBar/Config/schema.xml | 0 local/modules/DebugBar/DataCollector/PropelCollector.php | 0 local/modules/DebugBar/DebugBar.php | 0 local/modules/DebugBar/Listeners/DebugBarListeners.php | 0 local/modules/DebugBar/Smarty/Plugin/DebugBar.php | 0 11 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 local/modules/Colissimo/Colissimo.php mode change 100644 => 100755 local/modules/Colissimo/Config/config.xml mode change 100644 => 100755 local/modules/Colissimo/Config/plugin.xml mode change 100644 => 100755 local/modules/Colissimo/Config/schema.xml mode change 100644 => 100755 local/modules/DebugBar/Config/config.xml mode change 100644 => 100755 local/modules/DebugBar/Config/plugin.xml mode change 100644 => 100755 local/modules/DebugBar/Config/schema.xml mode change 100644 => 100755 local/modules/DebugBar/DataCollector/PropelCollector.php mode change 100644 => 100755 local/modules/DebugBar/DebugBar.php mode change 100644 => 100755 local/modules/DebugBar/Listeners/DebugBarListeners.php mode change 100644 => 100755 local/modules/DebugBar/Smarty/Plugin/DebugBar.php diff --git a/local/modules/Colissimo/Colissimo.php b/local/modules/Colissimo/Colissimo.php old mode 100644 new mode 100755 diff --git a/local/modules/Colissimo/Config/config.xml b/local/modules/Colissimo/Config/config.xml old mode 100644 new mode 100755 diff --git a/local/modules/Colissimo/Config/plugin.xml b/local/modules/Colissimo/Config/plugin.xml old mode 100644 new mode 100755 diff --git a/local/modules/Colissimo/Config/schema.xml b/local/modules/Colissimo/Config/schema.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Config/config.xml b/local/modules/DebugBar/Config/config.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Config/plugin.xml b/local/modules/DebugBar/Config/plugin.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Config/schema.xml b/local/modules/DebugBar/Config/schema.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/DataCollector/PropelCollector.php b/local/modules/DebugBar/DataCollector/PropelCollector.php old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/DebugBar.php b/local/modules/DebugBar/DebugBar.php old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Listeners/DebugBarListeners.php b/local/modules/DebugBar/Listeners/DebugBarListeners.php old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Smarty/Plugin/DebugBar.php b/local/modules/DebugBar/Smarty/Plugin/DebugBar.php old mode 100644 new mode 100755 From 6f1c77a57ede3ccc358710d2b752fbee540b2965 Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 22:41:17 +0200 Subject: [PATCH 002/192] WIP : Coupon functional tests --- .../functionnal/casperjs/exe/00_parameters.js | 5 - .../casperjs/exe/31_coupons_rule.js | 618 +++++++++--------- 2 files changed, 309 insertions(+), 314 deletions(-) diff --git a/tests/functionnal/casperjs/exe/00_parameters.js b/tests/functionnal/casperjs/exe/00_parameters.js index df5470229..29bf20a25 100644 --- a/tests/functionnal/casperjs/exe/00_parameters.js +++ b/tests/functionnal/casperjs/exe/00_parameters.js @@ -7,11 +7,6 @@ var thelia2_login_coupon_create_url = thelia2_base_url + 'admin/coupon/create/'; var thelia2_login_coupon_read_url = thelia2_base_url + 'admin/coupon/read/1'; var thelia2_login_coupon_update_url = thelia2_base_url + 'admin/coupon/update/1'; - - -//var findMyId = /([0-9]+)$/; -//var currentId; - casper.test.comment('Variables are set'); casper.test.done(0); diff --git a/tests/functionnal/casperjs/exe/31_coupons_rule.js b/tests/functionnal/casperjs/exe/31_coupons_rule.js index 66706aada..4b9ada4ba 100644 --- a/tests/functionnal/casperjs/exe/31_coupons_rule.js +++ b/tests/functionnal/casperjs/exe/31_coupons_rule.js @@ -1,312 +1,312 @@ -//// -////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 coupons rules'); -// -////UPDATE COUPON RULE -//casper.start(thelia2_login_coupon_update_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 RULE - EDIT'); -// this.test.assertTitle('Update coupon - Thelia Back Office', 'Web page title OK'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','1) 1st default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','1) 2nd default rule found'); -// -// // Create rule -// this.evaluate(function() { -// $('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change(); -// return true; +//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 coupons rules'); + +//UPDATE COUPON RULE +casper.start(thelia2_login_coupon_update_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 RULE - EDIT'); + this.test.assertTitle('Update coupon - Thelia Back Office', 'Web page title OK'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','1) 1st default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','1) 2nd default rule found'); + + // Create rule + this.evaluate(function() { + $('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change(); + return true; + }); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected.png'); +}); + +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); + +// Test Rule updating +casper.then(function(){ + this.evaluate(function() { + $('#quantity-operator').val('>=').change(); + return true; + }); + this.sendKeys('input#quantity-value', '4'); + this.click('#constraint-save-btn'); +}); + +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); + +casper.then(function(){ + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','2) 1st default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','2) 2nd default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', ' If cart products quantity is superior or equal to 4','2) 3rd rule found'); + + // Click on Edit button + this.click('tbody#constraint-list tr:nth-child(3) .constraint-update-btn'); +}); + +casper.wait(2000, function() { + this.echo("\nWaiting...."); +}); + +casper.then(function(){ + this.evaluate(function() { + $('#quantity-operator').val('==').change(); + return true; + }); + + // Removing old value +// casper.evaluate(function triggerKeyDownEvent() { +// var e = $.Event("keydown"); +// e.which = 8; +// e.keyCode = 8; +// $("#quantity-value").trigger(e); // }); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected.png'); -//}); -// -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -// -//// Test Rule updating -//casper.then(function(){ -// this.evaluate(function() { -// $('#quantity-operator').val('>=').change(); -// return true; + this.evaluate(function() { + $("#quantity-value").val('').change(); + return true; + }); + + // Adding new value + this.sendKeys('#quantity-value', '5'); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-being-edited.png'); + this.click('#constraint-save-btn'); +}); + +casper.wait(2000, function() { + this.echo("\nWaiting...."); +}); +// Check if updated rule has been saved and list refreshed +casper.then(function(){ + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','3) 1st default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','3) 2nd default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','3) 3rd rule updated found'); +}); + +// Check if updated rule has been well saved +casper.thenOpen(thelia2_login_coupon_update_url, function() { + this.test.assertHttpStatus(200); + this.test.comment('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited-refreshed.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','4) 1st default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','4) 2nd default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','4) 3rd rule updated found'); + + // Click on Delete button + this.click('tbody#constraint-list tr:nth-child(2) .constraint-delete-btn'); +}); + +casper.wait(2000, function() { + this.echo("\nWaiting...."); +}); + +casper.then(function(){ + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','5) 1st default rule found'); + this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','5) 2nd default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','5) 3rd rule updated found'); +}); + +// Check if updated rule has been well saved +casper.thenOpen(thelia2_login_coupon_update_url, function() { + this.test.assertHttpStatus(200); + this.test.comment('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-deleted-refreshed.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','6) 1st default rule found'); + this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','6) 2nd default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','6) 3rd rule updated found'); +}); + +// Test creating rule that won't be edited +casper.then(function(){ +// Create rule + this.evaluate(function() { + $('#category-rule').val('thelia.constraint.rule.available_for_total_amount').change(); + return true; + }); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected2.png'); +}); + +casper.wait(2000, function() { + this.echo("\nWaiting...."); +}); + +// Test Rule creation +casper.then(function(){ + this.evaluate(function() { + $('#price-operator').val('<=').change(); + return true; + }); + // Removing old value +// casper.evaluate(function triggerKeyDownEvent() { +// var e = $.Event("keydown"); +// e.which = 8; +// e.keyCode = 8; +// $("input#price-value").trigger(e); // }); -// this.sendKeys('input#quantity-value', '4'); -// this.click('#constraint-save-btn'); -//}); -// -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -// -//casper.then(function(){ -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','2) 1st default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','2) 2nd default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', ' If cart products quantity is superior or equal to 4','2) 3rd rule found'); -// -// // Click on Edit button -// this.click('tbody#constraint-list tr:nth-child(3) .constraint-update-btn'); -//}); -// -//casper.wait(2000, function() { -// this.echo("\nWaiting...."); -//}); -// -//casper.then(function(){ -// this.evaluate(function() { -// $('#quantity-operator').val('==').change(); -// return true; -// }); -// -// // Removing old value -//// casper.evaluate(function triggerKeyDownEvent() { -//// var e = $.Event("keydown"); -//// e.which = 8; -//// e.keyCode = 8; -//// $("#quantity-value").trigger(e); -//// }); -// this.evaluate(function() { -// $("#quantity-value").val('').change(); -// return true; -// }); -// -// // Adding new value -// this.sendKeys('#quantity-value', '5'); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-being-edited.png'); -// this.click('#constraint-save-btn'); -//}); -// -//casper.wait(2000, function() { -// this.echo("\nWaiting...."); -//}); -//// Check if updated rule has been saved and list refreshed -//casper.then(function(){ -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','3) 1st default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','3) 2nd default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','3) 3rd rule updated found'); -//}); -// -//// Check if updated rule has been well saved -//casper.thenOpen(thelia2_login_coupon_update_url, function() { -// this.test.assertHttpStatus(200); -// this.test.comment('Now on : ' + this.getCurrentUrl()); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited-refreshed.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','4) 1st default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','4) 2nd default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','4) 3rd rule updated found'); -// -// // Click on Delete button -// this.click('tbody#constraint-list tr:nth-child(2) .constraint-delete-btn'); -//}); -// -//casper.wait(2000, function() { -// this.echo("\nWaiting...."); -//}); -// -//casper.then(function(){ -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','5) 1st default rule found'); -// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','5) 2nd default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','5) 3rd rule updated found'); -//}); -// -//// Check if updated rule has been well saved -//casper.thenOpen(thelia2_login_coupon_update_url, function() { -// this.test.assertHttpStatus(200); -// this.test.comment('Now on : ' + this.getCurrentUrl()); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-deleted-refreshed.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','6) 1st default rule found'); -// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','6) 2nd default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','6) 3rd rule updated found'); -//}); -// -//// Test creating rule that won't be edited -//casper.then(function(){ -//// Create rule -// this.evaluate(function() { -// $('#category-rule').val('thelia.constraint.rule.available_for_total_amount').change(); -// return true; -// }); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected2.png'); -//}); -// -//casper.wait(2000, function() { -// this.echo("\nWaiting...."); -//}); -// -//// Test Rule creation -//casper.then(function(){ -// this.evaluate(function() { -// $('#price-operator').val('<=').change(); -// return true; -// }); -// // Removing old value -//// casper.evaluate(function triggerKeyDownEvent() { -//// var e = $.Event("keydown"); -//// e.which = 8; -//// e.keyCode = 8; -//// $("input#price-value").trigger(e); -//// }); -// this.evaluate(function() { -// $("input#price-value").val('').change(); -// return true; -// }); -// -// // Changing 400 to 401 -// this.sendKeys('input#price-value', '401'); -// this.evaluate(function() { -// $('#currency-value').val('GBP').change(); -// return true; -// }); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-saved-edited-before-click-save.png'); -// this.click('#constraint-save-btn'); -//}); -// -//casper.wait(2000, function() { -// this.echo("\nWaiting...."); -//}); -// -//casper.then(function(){ -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','7) 1st default rule found'); -// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','7) 2nd default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','7) 3rd rule updated found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','7) 4rd rule created found'); -//}); -// -//// Check if created rule has been well saved -//casper.thenOpen(thelia2_login_coupon_update_url, function() { -// this.test.assertHttpStatus(200); -// this.test.comment('Now on : ' + this.getCurrentUrl()); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added-refreshed.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','8) 1st default rule found'); -// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','8) 2nd default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','8) 3rd rule updated found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','8) 4rd rule created found'); -//}); -// -//// Testing deleting all rules -//casper.then(function(){ -//// Click on Delete button -// this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); -//}); -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -//casper.then(function(){ -//// Click on Delete button -// this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); -//}); -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -//casper.then(function(){ -//// Click on Delete button -// this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); -//}); -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -//casper.then(function(){ -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','9) 1st default rule found'); -// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); -//}); -// -//// Check if created rule has been well saved -//casper.thenOpen(thelia2_login_coupon_update_url, function() { -// this.test.assertHttpStatus(200); -// this.test.comment('Now on : ' + this.getCurrentUrl()); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','10) 1st default rule found'); -// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); -//}); -// -// -//// Test add no condition rule -//casper.then(function(){ -// this.evaluate(function() { -// $('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change(); -// return true; -// }); -//}); -// -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -// -//// Test Rule updating -//casper.then(function(){ -// this.evaluate(function() { -// $('#quantity-operator').val('>').change(); -// return true; -// }); -// this.sendKeys('input#quantity-value', '4'); -// this.click('#constraint-save-btn'); -//}); -// -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -// -//casper.then(function(){ -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart products quantity is superior to 4', '11) 1st default rule found'); -// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); -//}); -// -//// Check if created rule has been well saved -//casper.thenOpen(thelia2_login_coupon_update_url, function() { -// this.test.assertHttpStatus(200); -// this.test.comment('Now on : ' + this.getCurrentUrl()); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart products quantity is superior to 4','12) 1st default rule found'); -// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); -//}); -// -//casper.then(function(){ -// this.evaluate(function() { -// $('#category-rule').val('thelia.constraint.rule.available_for_everyone').change(); -// return true; -// }); -//}); -// -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -// -//// Test Rule updating -//casper.then(function(){ -// this.click('#constraint-save-btn'); -//}); -// -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -//casper.then(function(){ -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','13) 1st default rule found'); -// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); -//}); -// -//// Check if created rule has been well saved -//casper.thenOpen(thelia2_login_coupon_update_url, function() { -// this.test.assertHttpStatus(200); -// this.test.comment('Now on : ' + this.getCurrentUrl()); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','14) 1st default rule found'); -// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); -//}); -// -////RUN -//casper.run(function() { -// this.test.done(); -//}); \ No newline at end of file + this.evaluate(function() { + $("input#price-value").val('').change(); + return true; + }); + + // Changing 400 to 401 + this.sendKeys('input#price-value', '401'); + this.evaluate(function() { + $('#currency-value').val('GBP').change(); + return true; + }); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-saved-edited-before-click-save.png'); + this.click('#constraint-save-btn'); +}); + +casper.wait(2000, function() { + this.echo("\nWaiting...."); +}); + +casper.then(function(){ + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','7) 1st default rule found'); + this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','7) 2nd default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','7) 3rd rule updated found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','7) 4rd rule created found'); +}); + +// Check if created rule has been well saved +casper.thenOpen(thelia2_login_coupon_update_url, function() { + this.test.assertHttpStatus(200); + this.test.comment('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added-refreshed.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','8) 1st default rule found'); + this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','8) 2nd default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','8) 3rd rule updated found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','8) 4rd rule created found'); +}); + +// Testing deleting all rules +casper.then(function(){ +// Click on Delete button + this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); +}); +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); +casper.then(function(){ +// Click on Delete button + this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); +}); +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); +casper.then(function(){ +// Click on Delete button + this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); +}); +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); +casper.then(function(){ + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','9) 1st default rule found'); + test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +}); + +// Check if created rule has been well saved +casper.thenOpen(thelia2_login_coupon_update_url, function() { + this.test.assertHttpStatus(200); + this.test.comment('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','10) 1st default rule found'); + test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +}); + + +// Test add no condition rule +casper.then(function(){ + this.evaluate(function() { + $('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change(); + return true; + }); +}); + +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); + +// Test Rule updating +casper.then(function(){ + this.evaluate(function() { + $('#quantity-operator').val('>').change(); + return true; + }); + this.sendKeys('input#quantity-value', '4'); + this.click('#constraint-save-btn'); +}); + +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); + +casper.then(function(){ + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart products quantity is superior to 4', '11) 1st default rule found'); + test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +}); + +// Check if created rule has been well saved +casper.thenOpen(thelia2_login_coupon_update_url, function() { + this.test.assertHttpStatus(200); + this.test.comment('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart products quantity is superior to 4','12) 1st default rule found'); + test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +}); + +casper.then(function(){ + this.evaluate(function() { + $('#category-rule').val('thelia.constraint.rule.available_for_everyone').change(); + return true; + }); +}); + +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); + +// Test Rule updating +casper.then(function(){ + this.click('#constraint-save-btn'); +}); + +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); +casper.then(function(){ + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','13) 1st default rule found'); + test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +}); + +// Check if created rule has been well saved +casper.thenOpen(thelia2_login_coupon_update_url, function() { + this.test.assertHttpStatus(200); + this.test.comment('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','14) 1st default rule found'); + test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +}); + +//RUN +casper.run(function() { + this.test.done(); +}); \ No newline at end of file From 73c0a96979501b5c9a3f44e4dd69e6aed824954f Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 23:05:46 +0200 Subject: [PATCH 003/192] WIP : Coupon : unit tests on Operator --- .../Tests/Constraint/Rule/OperatorsTest.php | 62 +++++++++++++++++-- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php index 0b29baa62..d5a340d2b 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php @@ -23,7 +23,6 @@ namespace Thelia\Coupon; -use Thelia\Constraint\Validator\QuantityParam; use Thelia\Constraint\Rule\Operators; /** @@ -48,14 +47,58 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase { } - public function testSomething() +// public function testSomething() +// { +// // Stop here and mark this test as incomplete. +// $this->markTestIncomplete( +// 'This test has not been implemented yet.' +// ); +// } + + public function testOperatorI18n() { - // Stop here and mark this test as incomplete. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $stubTranslator = $this->getMockBuilder('\Symfony\Component\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + + $stubTranslator->expects($this->any()) + ->method('trans') + ->will($this->returnCallback((array($this, 'callbackI18n')))); + + $actual = Operators::getI18n($stubTranslator, Operators::INFERIOR); + $expected = 'inferior to'; + $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, Operators::INFERIOR_OR_EQUAL); + $expected = 'inferior or equal to'; + $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, Operators::EQUAL); + $expected = 'equal to'; + $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, Operators::SUPERIOR_OR_EQUAL); + $expected = 'superior or equal to'; + $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, Operators::SUPERIOR); + $expected = 'superior to'; + $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, Operators::DIFFERENT); + $expected = 'different from'; + $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, Operators::IN); + $expected = 'in'; + $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, Operators::OUT); + $expected = 'not in'; + $this->assertEquals($expected, $actual); } + // /** // * // * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator @@ -424,4 +467,11 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase { } + function callbackI18n() { + $args = func_get_args(); + + return $args[0]; + } } + + From ad48823b4819fdfe0a7a615fce8fabd38b9a991a Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 23:51:47 +0200 Subject: [PATCH 004/192] WIP : Coupon : unit tests on Rules --- ...=> AvailableForTotalAmountManagerTest.php} | 259 +++++++++++------- ...p => AvailableForXArticlesManagerTest.php} | 122 +++++---- .../Tests/Constraint/Rule/OperatorsTest.php | 4 + 3 files changed, 236 insertions(+), 149 deletions(-) rename core/lib/Thelia/Tests/Constraint/Rule/{AvailableForTotalAmountTest.php => AvailableForTotalAmountManagerTest.php} (78%) rename core/lib/Thelia/Tests/Constraint/Rule/{AvailableForXArticlesTest.php => AvailableForXArticlesManagerTest.php} (89%) diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountManagerTest.php similarity index 78% rename from core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php rename to core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountManagerTest.php index c3f7249df..4ad790a5b 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountManagerTest.php @@ -26,19 +26,20 @@ namespace Thelia\Coupon; use Thelia\Constraint\ConstraintValidator; use Thelia\Constraint\Rule\AvailableForTotalAmountManager; use Thelia\Constraint\Rule\Operators; +use Thelia\Exception\InvalidRuleValueException; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * Unit Test AvailableForTotalAmount Class + * Unit Test AvailableForTotalAmountManager Class * * @package Constraint * @author Guillaume MOREL * */ -class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase +class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase { /** @var CouponAdapterInterface $stubTheliaAdapter */ protected $stubTheliaAdapter = null; @@ -49,108 +50,168 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { -// /** @var CouponAdapterInterface $stubTheliaAdapter */ -// $this->stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + } -// /** -// * Generate valid CouponBaseAdapter -// * -// * @param float $cartTotalPrice Total amount of the current Cart -// * -// * @return CouponAdapterInterface -// */ -// protected function generateValidCouponBaseAdapterMock($cartTotalPrice = 421.23) -// { -// /** @var CouponAdapterInterface $stubTheliaAdapter */ -// $stubTheliaAdapter = $this->getMock( -// 'Thelia\Coupon\CouponBaseAdapter', -// array('getCartTotalPrice'), -// array() -// ); -// $stubTheliaAdapter->expects($this->any()) -// ->method('getCartTotalPrice') -// ->will($this->returnValue($cartTotalPrice)); -// -// return $stubTheliaAdapter; -// } + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmountManager::setValidators + * @expectedException \Thelia\Exception\InvalidRuleOperatorException + * + */ + public function testInValidBackOfficeInputOperator() + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') + ->disableOriginalConstructor() + ->getMock(); -// /** -// * Check if validity test on BackOffice inputs are working -// * -// * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput -// * -// */ -// public function testValidBackOfficeInput() -// { -// $adapter = new CouponBaseAdapter(); -// -// $validators = array( -// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( -// Operators::SUPERIOR, -// new PriceParam( -// $adapter, 421.23, 'EUR' -// ) -// ) -// ); -// $rule = new AvailableForTotalAmount($adapter, $validators); -// -// $expected = true; -// $actual = $rule->checkBackOfficeInput(); -// $this->assertEquals($expected, $actual); -// } + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(399)); + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); -// /** -// * Check if validity test on BackOffice inputs are working -// * -// * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput -// * @expectedException \Thelia\Exception\InvalidRuleOperatorException -// * -// */ -// public function testInValidBackOfficeInputOperator() -// { -// $adapter = new CouponBaseAdapter(); -// -// $validators = array( -// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( -// 'X', -// new PriceParam( -// $adapter, 421.23, 'EUR' -// ) -// ) -// ); -// -// $rule = new AvailableForTotalAmount($adapter, $validators); -// -// $expected = false; -// $actual = $rule->checkBackOfficeInput(); -// $this->assertEquals($expected, $actual); -// } + $rule1 = new AvailableForTotalAmountManager($stubAdapter); + $operators = array( + AvailableForTotalAmountManager::INPUT1 => Operators::IN, + AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + AvailableForTotalAmountManager::INPUT1 => '400', + AvailableForTotalAmountManager::INPUT2 => 'EUR'); + $rule1->setValidatorsFromForm($operators, $values); -// /** -// * Check if validity test on BackOffice inputs are working -// * -// * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput -// * @expectedException \ErrorException -// * -// */ -// public function testInValidBackOfficeInputValue() -// { -// $adapter = $this->generateValidCouponBaseAdapterMock(); -// -// $validators = array( -// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( -// Operators::SUPERIOR, -// 421 -// ) -// ); -// -// $rule = new AvailableForTotalAmount($adapter, $validators); -// -// $expected = false; -// $actual = $rule->checkBackOfficeInput(); -// $this->assertEquals($expected, $actual); -// } + $isValid = $rule1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmountManager::setValidators + * @expectedException \Thelia\Exception\InvalidRuleOperatorException + * + */ + public function testInValidBackOfficeInputOperator2() + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(399)); + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); + + $rule1 = new AvailableForTotalAmountManager($stubAdapter); + $operators = array( + AvailableForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + AvailableForTotalAmountManager::INPUT2 => Operators::INFERIOR + ); + $values = array( + AvailableForTotalAmountManager::INPUT1 => '400', + AvailableForTotalAmountManager::INPUT2 => 'EUR'); + $rule1->setValidatorsFromForm($operators, $values); + + $isValid = $rule1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmountManager::setValidators + * @expectedException \Thelia\Exception\InvalidRuleValueException + * + */ + public function testInValidBackOfficeInputValue() + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(399)); + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); + + $rule1 = new AvailableForTotalAmountManager($stubAdapter); + $operators = array( + AvailableForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + AvailableForTotalAmountManager::INPUT1 => 'X', + AvailableForTotalAmountManager::INPUT2 => 'EUR'); + $rule1->setValidatorsFromForm($operators, $values); + + $isValid = $rule1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmountManager::setValidators + * @expectedException \Thelia\Exception\InvalidRuleValueException + * + */ + public function testInValidBackOfficeInputValue2() + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(399)); + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); + + $rule1 = new AvailableForTotalAmountManager($stubAdapter); + $operators = array( + AvailableForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + AvailableForTotalAmountManager::INPUT1 => 400, + AvailableForTotalAmountManager::INPUT2 => 'FLA'); + $rule1->setValidatorsFromForm($operators, $values); + + $isValid = $rule1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } /** * Check if test inferior operator is working diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesManagerTest.php similarity index 89% rename from core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php rename to core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesManagerTest.php index 4ecbcb8ac..12deb34b8 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesManagerTest.php @@ -33,13 +33,13 @@ use Thelia\Constraint\Rule\SerializableRule; * Date: 8/19/13 * Time: 3:24 PM * - * Unit Test AvailableForXArticles Class + * Unit Test AvailableForXArticlesManager Class * * @package Constraint * @author Guillaume MOREL * */ -class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase +class AvailableForXArticlesManagerTest extends \PHPUnit_Framework_TestCase { // /** @var CouponAdapterInterface $stubTheliaAdapter */ @@ -51,30 +51,8 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { -// /** @var CouponAdapterInterface $stubTheliaAdapter */ -// $this->stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); - } -// /** -// * Generate valid CouponBaseAdapter -// * -// * @param int $nbArticlesInCart Total articles in the current Cart -// * -// * @return CouponAdapterInterface -// */ -// protected function generateValidCouponBaseAdapterMock($nbArticlesInCart = 4) -// { -// /** @var CouponAdapterInterface $stubTheliaAdapter */ -// $stubTheliaAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') -// ->disableOriginalConstructor() -// ->setMethods(array('getNbArticlesInCart')) -// ->getMock(); -// $stubTheliaAdapter->expects($this->any()) -// ->method('getNbArticlesInCart') -// ->will($this->returnValue($nbArticlesInCart)); -// -// return $stubTheliaAdapter; -// } + } // /** // * Check if validity test on BackOffice inputs are working @@ -100,31 +78,75 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase // $this->assertEquals($expected, $actual); // } -// /** -// * Check if validity test on BackOffice inputs are working -// * -// * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput -// * @expectedException \Thelia\Exception\InvalidRuleValueException -// */ -// public function testInValidBackOfficeInputFloat() -// { -// $adapter = $this->stubTheliaAdapter; -// -// $validators = array( -// AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( -// Operators::SUPERIOR, -// new QuantityParam( -// $adapter, -// 4.5 -// ) -// ) -// ); -// $rule = new AvailableForXArticles($adapter, $validators); -// -// $expected = false; -// $actual = $rule->checkBackOfficeInput(); -// $this->assertEquals($expected, $actual); -// } + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput + * @expectedException \Thelia\Exception\InvalidRuleOperatorException + */ + public function testInValidBackOfficeInputOperator() + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); + + $rule1 = new AvailableForXArticlesManager($stubAdapter); + $operators = array( + AvailableForXArticlesManager::INPUT1 => Operators::IN + ); + $values = array( + AvailableForXArticlesManager::INPUT1 => 5 + ); + $rule1->setValidatorsFromForm($operators, $values); + + $isValid = $rule1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput + * @expectedException \Thelia\Exception\InvalidRuleValueException + */ + public function testInValidBackOfficeInputValue() + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); + + $rule1 = new AvailableForXArticlesManager($stubAdapter); + $operators = array( + AvailableForXArticlesManager::INPUT1 => Operators::SUPERIOR + ); + $values = array( + AvailableForXArticlesManager::INPUT1 => 'X' + ); + $rule1->setValidatorsFromForm($operators, $values); + + $isValid = $rule1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } // /** // * Check if validity test on BackOffice inputs are working diff --git a/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php index d5a340d2b..6cdcb3430 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php @@ -96,6 +96,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $actual = Operators::getI18n($stubTranslator, Operators::OUT); $expected = 'not in'; $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, 'unexpected operator'); + $expected = 'unexpected operator'; + $this->assertEquals($expected, $actual); } From a7ef4300aa16ba189a9d383ed1d2f2ba5f8c374b Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 23:56:31 +0200 Subject: [PATCH 005/192] WIP : Coupon : unit tests on Rules --- .../Rule/AvailableForTotalAmountManager.php | 12 +-- .../Rule/AvailableForXArticlesManager.php | 9 ++- core/lib/Thelia/Constraint/Rule/Operators.php | 56 ------------- .../Rule/AvailableForXArticlesManagerTest.php | 80 +------------------ 4 files changed, 13 insertions(+), 144 deletions(-) diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php index 30bc86ad6..d8a4755f6 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php @@ -111,8 +111,8 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract $this->availableOperators[self::INPUT1] ); if (!$isOperator1Legit) { - throw new \InvalidArgumentException( - 'Operator for price field is not legit' + throw new InvalidRuleOperatorException( + get_class(), 'price' ); } @@ -121,15 +121,15 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract $this->availableOperators[self::INPUT2] ); if (!$isOperator1Legit) { - throw new \InvalidArgumentException( - 'Operator for currency field is not legit' + throw new InvalidRuleOperatorException( + get_class(), 'price' ); } $floatType = new FloatType(); if (!$floatType->isValid($priceValue) || $priceValue <= 0) { - throw new \InvalidArgumentException( - 'Value for price field is not legit' + throw new InvalidRuleValueException( + get_class(), 'price' ); } diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php b/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php index 572d39b1d..f73d5e2be 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php @@ -30,6 +30,7 @@ use Thelia\Constraint\Validator\QuantityParam; use Thelia\Constraint\Validator\RuleValidator; use Thelia\Coupon\CouponAdapterInterface; use Thelia\Exception\InvalidRuleException; +use Thelia\Exception\InvalidRuleOperatorException; use Thelia\Exception\InvalidRuleValueException; use Thelia\Type\FloatType; @@ -98,14 +99,14 @@ class AvailableForXArticlesManager extends CouponRuleAbstract $this->availableOperators[self::INPUT1] ); if (!$isOperator1Legit) { - throw new \InvalidArgumentException( - 'Operator for quantity field is not legit' + throw new InvalidRuleOperatorException( + get_class(), 'quantity' ); } if ((int) $quantityValue <= 0) { - throw new \InvalidArgumentException( - 'Value for quantity field is not legit' + throw new InvalidRuleValueException( + get_class(), 'quantity' ); } diff --git a/core/lib/Thelia/Constraint/Rule/Operators.php b/core/lib/Thelia/Constraint/Rule/Operators.php index 2ed5c2909..a6c457c75 100644 --- a/core/lib/Thelia/Constraint/Rule/Operators.php +++ b/core/lib/Thelia/Constraint/Rule/Operators.php @@ -56,62 +56,6 @@ abstract class Operators /** Param1 is not in Param2 */ CONST OUT = 'out'; -// /** -// * Check if a parameter is valid against a ComparableInterface from its operator -// * -// * @param mixed $a Parameter to validate -// * @param string $operator Operator to validate against -// * @param ComparableInterface $b Comparable to validate against -// * -// * @return bool -// */ -// public static function isValid($a, $operator, ComparableInterface $b) -// { -// $ret = false; -// -// try { -// $comparison = $b->compareTo($a); -// } catch (\Exception $e) { -// return false; -// } -// -// switch ($operator) { -// case self::INFERIOR: -// if ($comparison == 1) { -// return true; -// } -// break; -// case self::INFERIOR_OR_EQUAL: -// if ($comparison == 1 || $comparison == 0) { -// return true; -// } -// break; -// case self::EQUAL: -// if ($comparison == 0) { -// return true; -// } -// break; -// case self::SUPERIOR_OR_EQUAL: -// if ($comparison == -1 || $comparison == 0) { -// return true; -// } -// break; -// case self::SUPERIOR: -// if ($comparison == -1) { -// return true; -// } -// break; -// case self::DIFFERENT: -// if ($comparison != 0) { -// return true; -// } -// break; -// default: -// } -// -// return $ret; -// } - /** * Get operator translation * diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesManagerTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesManagerTest.php index 12deb34b8..4937826b6 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesManagerTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesManagerTest.php @@ -54,34 +54,10 @@ class AvailableForXArticlesManagerTest extends \PHPUnit_Framework_TestCase } -// /** -// * Check if validity test on BackOffice inputs are working -// * -// * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput -// * -// */ -// public function testValidBackOfficeInput() -// { -// $translator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') -// ->disableOriginalConstructor() -// ->getMock(); -// -// $rule = new AvailableForXArticles($translator); -// $operators = array(AvailableForXArticles::PARAM1_QUANTITY => Operators::SUPERIOR); -// $values = array( -// AvailableForXArticles::PARAM1_QUANTITY => 4 -// ); -// $rule->populateFromForm($operators, $values); -// -// $expected = true; -// $actual = $rule->checkBackOfficeInput(); -// $this->assertEquals($expected, $actual); -// } - /** * Check if validity test on BackOffice inputs are working * - * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput + * @covers Thelia\Coupon\Rule\AvailableForXArticlesManager::setValidators * @expectedException \Thelia\Exception\InvalidRuleOperatorException */ public function testInValidBackOfficeInputOperator() @@ -116,7 +92,7 @@ class AvailableForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if validity test on BackOffice inputs are working * - * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput + * @covers Thelia\Coupon\Rule\AvailableForXArticlesManager::setValidators * @expectedException \Thelia\Exception\InvalidRuleValueException */ public function testInValidBackOfficeInputValue() @@ -148,58 +124,6 @@ class AvailableForXArticlesManagerTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); } -// /** -// * Check if validity test on BackOffice inputs are working -// * -// * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput -// * @expectedException \Thelia\Exception\InvalidRuleValueException -// */ -// public function testInValidBackOfficeInputNegative() -// { -// $adapter = $this->stubTheliaAdapter; -// -// $validators = array( -// AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( -// Operators::SUPERIOR, -// new QuantityParam( -// $adapter, -// -1 -// ) -// ) -// ); -// $rule = new AvailableForXArticles($adapter, $validators); -// -// $expected = false; -// $actual = $rule->checkBackOfficeInput(); -// $this->assertEquals($expected, $actual); -// } - -// /** -// * Check if validity test on BackOffice inputs are working -// * -// * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput -// * @expectedException \Thelia\Exception\InvalidRuleValueException -// */ -// public function testInValidBackOfficeInputString() -// { -// $adapter = $this->stubTheliaAdapter; -// -// $validators = array( -// AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( -// Operators::SUPERIOR, -// new QuantityParam( -// $adapter, -// 'bad' -// ) -// ) -// ); -// $rule = new AvailableForXArticles($adapter, $validators); -// -// $expected = false; -// $actual = $rule->checkBackOfficeInput(); -// $this->assertEquals($expected, $actual); -// } - /** * Check if test inferior operator is working * From 3b249dc21c65bea8836a275d867b1d00d516cb4e Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 17 Sep 2013 11:41:09 +0200 Subject: [PATCH 006/192] Working : Coupon : Unit testing --- .../Rule/AvailableForTotalAmountManager.php | 11 +- .../Constraint/Rule/CouponRuleAbstract.php | 51 +++ .../Controller/Admin/CouponController.php | 2 + .../Thelia/Coupon/CouponAdapterInterface.php | 7 + core/lib/Thelia/Coupon/CouponBaseAdapter.php | 15 + .../AvailableForTotalAmountManagerTest.php | 290 ++++-------------- 6 files changed, 135 insertions(+), 241 deletions(-) diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php index d8a4755f6..c4087e734 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php @@ -126,14 +126,11 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract ); } - $floatType = new FloatType(); - if (!$floatType->isValid($priceValue) || $priceValue <= 0) { - throw new InvalidRuleValueException( - get_class(), 'price' - ); - } + $this->isPriceValid($priceValue); + + + $this->IsCurrencyValid($currencyValue); - // @todo check currency is legit or not $this->operators = array( self::INPUT1 => $priceOperator, diff --git a/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php b/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php index 0986daa50..ffd1eb0f3 100644 --- a/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php +++ b/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php @@ -31,6 +31,9 @@ use Thelia\Constraint\Validator\ComparableInterface; use Thelia\Constraint\Validator\RuleValidator; use Thelia\Exception\InvalidRuleException; use Thelia\Exception\InvalidRuleOperatorException; +use Thelia\Exception\InvalidRuleValueException; +use Thelia\Model\Currency; +use Thelia\Type\FloatType; /** * Created by JetBrains PhpStorm. @@ -268,4 +271,52 @@ abstract class CouponRuleAbstract implements CouponRuleInterface return $serializableRule; } + + /** + * Check if currency if valid or not + * + * @param string $currencyValue Currency EUR|USD|.. + * + * @return bool + * @throws \Thelia\Exception\InvalidRuleValueException + */ + protected function IsCurrencyValid($currencyValue) + { + $availableCurrencies = $this->adapter->getAvailableCurrencies(); + /** @var Currency $currency */ + $currencyFound = false; + foreach ($availableCurrencies as $key => $currency) { + if ($currencyValue == $currency->getCode()) { + $currencyFound = true; + } + } + if (!$currencyFound) { + throw new InvalidRuleValueException( + get_class(), 'currency' + ); + } + + return true; + } + + /** + * Check if price is valid + * + * @param float $priceValue Price value to check + * + * @return bool + * @throws \Thelia\Exception\InvalidRuleValueException + */ + protected function isPriceValid($priceValue) + { + $floatType = new FloatType(); + if (!$floatType->isValid($priceValue) || $priceValue <= 0) { + throw new InvalidRuleValueException( + get_class(), 'price' + ); + } + + return true; + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index 6803addfd..f50c58307 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -49,7 +49,9 @@ use Thelia\Form\Exception\FormValidationException; use Thelia\Log\Tlog; use Thelia\Model\Coupon; use Thelia\Model\CouponQuery; +use Thelia\Model\CurrencyQuery; use Thelia\Model\Lang; +use Thelia\Model\LangQuery; use Thelia\Tools\I18n; /** diff --git a/core/lib/Thelia/Coupon/CouponAdapterInterface.php b/core/lib/Thelia/Coupon/CouponAdapterInterface.php index b2c168186..413fc3df6 100644 --- a/core/lib/Thelia/Coupon/CouponAdapterInterface.php +++ b/core/lib/Thelia/Coupon/CouponAdapterInterface.php @@ -169,4 +169,11 @@ interface CouponAdapterInterface */ public function getConstraintValidator(); + /** + * Return all available currencies + * + * @return array of Currency + */ + public function getAvailableCurrencies(); + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponBaseAdapter.php b/core/lib/Thelia/Coupon/CouponBaseAdapter.php index f9fae8651..cb5162090 100644 --- a/core/lib/Thelia/Coupon/CouponBaseAdapter.php +++ b/core/lib/Thelia/Coupon/CouponBaseAdapter.php @@ -35,6 +35,8 @@ use Thelia\Model\Coupon; use Thelia\Model\CouponQuery; use Thelia\Cart\CartTrait; use Thelia\Model\Currency; +use Thelia\Model\CurrencyQuery; +use Thelia\Model\LangQuery; /** * Created by JetBrains PhpStorm. @@ -266,4 +268,17 @@ class CouponBaseAdapter implements CouponAdapterInterface { return $this->container->get('thelia.constraint.validator'); } + + + /** + * Return all available currencies + * + * @return array of Currency + */ + public function getAvailableCurrencies() + { + $currencies = CurrencyQuery::create(); + + return $currencies->find(); + } } diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountManagerTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountManagerTest.php index 4ad790a5b..a883a0712 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountManagerTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountManagerTest.php @@ -27,6 +27,7 @@ use Thelia\Constraint\ConstraintValidator; use Thelia\Constraint\Rule\AvailableForTotalAmountManager; use Thelia\Constraint\Rule\Operators; use Thelia\Exception\InvalidRuleValueException; +use Thelia\Model\Currency; /** * Created by JetBrains PhpStorm. @@ -44,6 +45,43 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var CouponAdapterInterface $stubTheliaAdapter */ protected $stubTheliaAdapter = null; + /** + * Generate adapter stub + * + * @param int $cartTotalPrice Cart total price + * @param string $checkoutCurrency Checkout currency + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ + public function generateAdapterStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR') + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue($cartTotalPrice)); + + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue($checkoutCurrency)); + + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); + + $currency1 = new Currency(); + $currency1->setCode('EUR'); + $currency2 = new Currency(); + $currency2->setCode('USD'); + $stubAdapter->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue(array($currency1, $currency2))); + + return $stubAdapter; + } + /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -62,19 +100,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testInValidBackOfficeInputOperator() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -102,19 +128,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testInValidBackOfficeInputOperator2() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -142,19 +156,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testInValidBackOfficeInputValue() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -182,19 +184,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testInValidBackOfficeInputValue2() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -221,19 +211,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleInferior() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -260,19 +238,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleInferior() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -299,19 +265,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleInferiorEquals() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -338,19 +292,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleInferiorEquals2() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -377,19 +319,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleInferiorEquals() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(401)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(401, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -416,19 +346,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleEqual() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -455,19 +373,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleEqual() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -494,19 +400,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleSuperiorEquals() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(401)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(401, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -533,19 +427,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleSuperiorEquals2() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -572,19 +454,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleSuperiorEquals() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399.00)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -611,19 +481,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleSuperior() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(401)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(401, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -650,19 +508,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleSuperior() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399.00)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -689,19 +535,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleCurrency() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400.00)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -728,19 +562,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleCurrency() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400.00)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(400.00, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( From 5326ab1341549c1020ff4235abda6e03386d703a Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 17 Sep 2013 22:54:49 +0200 Subject: [PATCH 007/192] Working : Coupon : fixture add old coupon --- install/faker.php | 57 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/install/faker.php b/install/faker.php index 66303f05a..25112d904 100755 --- a/install/faker.php +++ b/install/faker.php @@ -1,5 +1,6 @@ setIsUsed(1); $coupon1->setIsEnabled(1); $date = new \DateTime(); - $coupon1->setExpirationDate($date->setTimestamp(strtotime("today + 2 months"))); + $coupon1->setExpirationDate($date->setTimestamp(strtotime("today + 3 months"))); $rule1 = new AvailableForTotalAmountManager($adapter); $operators = array( @@ -588,27 +589,18 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $rules = new CouponRuleCollection(); $rules->add($rule1); $rules->add($rule2); - /** @var ConstraintFactory $constraintFactory */ $constraintFactory = $container->get('thelia.constraint.factory'); $serializedRules = $constraintFactory->serializeCouponRuleCollection($rules); $coupon1->setSerializedRules($serializedRules); - $coupon1->setMaxUsage(40); $coupon1->setIsCumulative(1); $coupon1->setIsRemovingPostage(0); $coupon1->setIsAvailableOnSpecialOffers(1); - $coupon1->save(); - - - - - - // Coupons $coupon2 = new Thelia\Model\Coupon(); $coupon2->setCode('SPRINGBREAK'); @@ -628,7 +620,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $coupon2->setIsUsed(1); $coupon2->setIsEnabled(1); $date = new \DateTime(); - $coupon2->setExpirationDate($date->setTimestamp(strtotime("today + 2 months"))); + $coupon2->setExpirationDate($date->setTimestamp(strtotime("today + 1 months"))); $rule1 = new AvailableForXArticlesManager($adapter); $operators = array( @@ -638,7 +630,6 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua AvailableForXArticlesManager::INPUT1 => 4, ); $rule1->setValidatorsFromForm($operators, $values); - $rules = new CouponRuleCollection(); $rules->add($rule1); @@ -647,11 +638,49 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $serializedRules = $constraintFactory->serializeCouponRuleCollection($rules); $coupon2->setSerializedRules($serializedRules); - $coupon2->setMaxUsage(-1); $coupon2->setIsCumulative(0); $coupon2->setIsRemovingPostage(1); $coupon2->setIsAvailableOnSpecialOffers(1); - $coupon2->save(); + + + // Coupons + $coupon3 = new Thelia\Model\Coupon(); + $coupon3->setCode('OLD'); + $coupon3->setType('thelia.coupon.type.remove_x_percent'); + $coupon3->setTitle('Old coupon'); + $coupon3->setShortDescription('Coupon for Springbreak removing 10% if you have more than 4 articles in your cart'); + $coupon3->setDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla. + +Donec rhoncus leo mauris, id porttitor ante luctus tempus. Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla. + +Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros. + +Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non. + +Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.'); + $coupon3->setAmount(10.00); + $coupon3->setIsUsed(1); + $coupon3->setIsEnabled(0); + $date = new \DateTime(); + $coupon3->setExpirationDate($date->setTimestamp(strtotime("today + 2 months"))); + + $rule1 = new AvailableForEveryoneManager($adapter); + $operators = array(); + $values = array(); + $rule1->setValidatorsFromForm($operators, $values); + $rules = new CouponRuleCollection(); + $rules->add($rule1); + + /** @var ConstraintFactory $constraintFactory */ + $constraintFactory = $container->get('thelia.constraint.factory'); + + $serializedRules = $constraintFactory->serializeCouponRuleCollection($rules); + $coupon3->setSerializedRules($serializedRules); + $coupon3->setMaxUsage(-1); + $coupon3->setIsCumulative(0); + $coupon3->setIsRemovingPostage(1); + $coupon3->setIsAvailableOnSpecialOffers(1); + $coupon3->save(); } From ce72a2007476b368f900cd18e986890d6426f453 Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 17 Sep 2013 23:09:55 +0200 Subject: [PATCH 008/192] Working : Coupon : fix loop --- core/lib/Thelia/Core/Template/Loop/Coupon.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Coupon.php b/core/lib/Thelia/Core/Template/Loop/Coupon.php index 4e8ca3e71..dff5e782b 100755 --- a/core/lib/Thelia/Core/Template/Loop/Coupon.php +++ b/core/lib/Thelia/Core/Template/Loop/Coupon.php @@ -88,8 +88,8 @@ class Coupon extends BaseI18nLoop $search->filterById($id, Criteria::IN); } - if ($isEnabled != BooleanOrBothType::ANY) { - $search->filterByIsEnabled($isEnabled ? 1 : 0); + if (isset($isEnabled)) { + $search->filterByIsEnabled($isEnabled ? true : false); } // Perform search From 542a1423298431263c72d3d0f6a835b13971c247 Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 17 Sep 2013 23:19:09 +0200 Subject: [PATCH 009/192] Working : Coupon : fix loop, fix read display --- core/lib/Thelia/Core/Template/Loop/Coupon.php | 2 +- install/faker.php | 8 ++++---- templates/admin/default/coupon-read.html | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Coupon.php b/core/lib/Thelia/Core/Template/Loop/Coupon.php index dff5e782b..063ffa397 100755 --- a/core/lib/Thelia/Core/Template/Loop/Coupon.php +++ b/core/lib/Thelia/Core/Template/Loop/Coupon.php @@ -63,7 +63,7 @@ class Coupon extends BaseI18nLoop { return new ArgumentCollection( Argument::createIntListTypeArgument('id'), - Argument::createBooleanOrBothTypeArgument('is_enabled', 1) + Argument::createBooleanOrBothTypeArgument('is_enabled') ); } diff --git a/install/faker.php b/install/faker.php index 94c507d02..9a1d3d480 100755 --- a/install/faker.php +++ b/install/faker.php @@ -742,7 +742,7 @@ Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentes Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.'); $coupon3->setAmount(10.00); - $coupon3->setIsUsed(1); + $coupon3->setIsUsed(0); $coupon3->setIsEnabled(0); $date = new \DateTime(); $coupon3->setExpirationDate($date->setTimestamp(strtotime("today + 2 months"))); @@ -760,8 +760,8 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $serializedRules = $constraintFactory->serializeCouponRuleCollection($rules); $coupon3->setSerializedRules($serializedRules); $coupon3->setMaxUsage(-1); - $coupon3->setIsCumulative(0); - $coupon3->setIsRemovingPostage(1); - $coupon3->setIsAvailableOnSpecialOffers(1); + $coupon3->setIsCumulative(1); + $coupon3->setIsRemovingPostage(0); + $coupon3->setIsAvailableOnSpecialOffers(0); $coupon3->save(); } diff --git a/templates/admin/default/coupon-read.html b/templates/admin/default/coupon-read.html index 4ae5e5c68..859163fc8 100755 --- a/templates/admin/default/coupon-read.html +++ b/templates/admin/default/coupon-read.html @@ -63,7 +63,11 @@ {intl l='Usage left'} - {if $USAGE_LEFT} + {if $USAGE_LEFT == -1} + + {intl l='Unlimited'} + + {elseif $USAGE_LEFT} {$USAGE_LEFT} From be665cba56d7ed3da0caf3d8d65e1ffea79625ef Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 17 Sep 2013 23:25:38 +0200 Subject: [PATCH 010/192] Working : Coupon : fix loop, fix read display --- templates/admin/default/coupon-list.html | 36 ++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/templates/admin/default/coupon-list.html b/templates/admin/default/coupon-list.html index 2eafde586..a17d01e96 100755 --- a/templates/admin/default/coupon-list.html +++ b/templates/admin/default/coupon-list.html @@ -41,7 +41,23 @@ {block name="coupon-code"}{$CODE}{/block} {block name="coupon-title"}{$TITLE}{/block} {block name="coupon-expiration-date"}{$EXPIRATION_DATE}{/block} - {block name="coupon-usage-left"}{$USAGE_LEFT}{/block} + + {block name="coupon-usage-left"} + {if $USAGE_LEFT == -1} + + {intl l='Unlimited'} + + {elseif $USAGE_LEFT} + + {$USAGE_LEFT} + + {else} + + 0 + + {/if} + {/block} + {block name="coupon-action"} @@ -77,7 +93,23 @@ {block name="coupon-code"}{$CODE}{/block} {block name="coupon-title"}{$TITLE}{/block} {block name="coupon-expiration-date"}{$EXPIRATION_DATE}{/block} - {block name="coupon-usage-left"}{$USAGE_LEFT}{/block} + + {block name="coupon-usage-left"} + {if $USAGE_LEFT == -1} + + {intl l='Unlimited'} + + {elseif $USAGE_LEFT} + + {$USAGE_LEFT} + + {else} + + 0 + + {/if} + {/block} + {block name="coupon-action"} From b545e1c012f1d3ef609612021b34c812ca5d36a3 Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 17 Sep 2013 23:29:25 +0200 Subject: [PATCH 011/192] Working : Coupon : fix loop, fix read display --- core/lib/Thelia/Core/Template/Loop/Coupon.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Coupon.php b/core/lib/Thelia/Core/Template/Loop/Coupon.php index 063ffa397..9b720ef13 100755 --- a/core/lib/Thelia/Core/Template/Loop/Coupon.php +++ b/core/lib/Thelia/Core/Template/Loop/Coupon.php @@ -31,13 +31,11 @@ use Thelia\Core\HttpFoundation\Request; use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; - -use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; - +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Coupon\Type\CouponInterface; -use Thelia\Model\CouponQuery; use Thelia\Model\Coupon as MCoupon; +use Thelia\Model\CouponQuery; use Thelia\Type; use Thelia\Type\BooleanOrBothType; From 3627d96175c1424916d353c5a06c25883a338703 Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 18 Sep 2013 10:07:57 +0200 Subject: [PATCH 012/192] WIP : Upload management --- core/lib/Thelia/Config/Resources/config.xml | 1 + .../Thelia/Config/Resources/routing/admin.xml | 4 + .../Controller/Admin/CategoryController.php | 60 +++++++++++ .../Form/CategoryPictureCreationForm.php | 100 ++++++++++++++++++ core/lib/Thelia/Model/CategoryImage.php | 44 ++++++++ templates/admin/default/category-edit.html | 25 +++++ 6 files changed, 234 insertions(+) create mode 100644 core/lib/Thelia/Form/CategoryPictureCreationForm.php diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 41e49d7d7..db2b1db82 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -54,6 +54,7 @@
+ diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index af7c950af..8f2e54f86 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -100,6 +100,10 @@ Thelia\Controller\Admin\CategoryController::addRelatedContentAction + + Thelia\Controller\Admin\CategoryController::addRelatedPictureAction + + Thelia\Controller\Admin\CategoryController::deleteRelatedContentAction diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index 8c74c31ec..1c7854416 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -27,6 +27,7 @@ use Thelia\Core\Event\CategoryDeleteEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\CategoryUpdateEvent; use Thelia\Core\Event\CategoryCreateEvent; +use Thelia\Form\CategoryPictureCreationForm; use Thelia\Model\CategoryQuery; use Thelia\Form\CategoryModificationForm; use Thelia\Form\CategoryCreationForm; @@ -306,6 +307,39 @@ class CategoryController extends AbstractCrudController $this->redirectToEditionTemplate(); } + /** + * Add category pictures + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function addRelatedPictureAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.categories.update")) { + return $response; + } + +// $content_id = intval($this->getRequest()->get('content_id')); +// +// if ($content_id > 0) { +// +// $event = new CategoryAddContentEvent( +// $this->getExistingObject(), +// $content_id +// ); +// +// try { +// $this->dispatch(TheliaEvents::CATEGORY_ADD_CONTENT, $event); +// } +// catch (\Exception $ex) { +// // Any error +// return $this->errorPage($ex); +// } +// } + + $this->redirectToEditionTemplate(); + } + public function deleteRelatedContentAction() { // Check current user authorization @@ -331,4 +365,30 @@ class CategoryController extends AbstractCrudController $this->redirectToEditionTemplate(); } + + /** + * @todo remove + * @return Symfony\Component\HttpFoundation\Response|void + */ + public function updateAction() + { + var_dump('updateAction'); + if ($this->getRequest()->isMethod('POST')) { + var_dump('getRequest', $this->getRequest()->files); + // Create the form from the request + $creationForm = new CategoryPictureCreationForm($this->getRequest()); + + // Check the form against constraints violations + $form = $this->validateForm($creationForm, 'POST'); + var_dump('$form', $form); + + // Get the form field values + $data = $form->getData(); + var_dump('$data', $data); + } + + + return parent::updateAction(); + } + } diff --git a/core/lib/Thelia/Form/CategoryPictureCreationForm.php b/core/lib/Thelia/Form/CategoryPictureCreationForm.php new file mode 100644 index 000000000..2dffc61c3 --- /dev/null +++ b/core/lib/Thelia/Form/CategoryPictureCreationForm.php @@ -0,0 +1,100 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\Image; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +class CategoryPictureCreationForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder +// ->add('alt') + ->add('file', 'file', array( + 'constraints' => array( + new NotBlank(), + new Image( + array( + 'minWidth' => 200, + 'maxWidth' => 400, + 'minHeight' => 200, + 'maxHeight' => 400, + ) + ) + ))) +// ->add('category_id', 'model', array( +// 'disabled' => false, +// 'class' => 'Thelia\Model\ProductImage' +// )) +// ->add('position', 'integer', array( +// 'constraints' => array( +// new NotBlank() +// ) +// )) + ->add('title', 'text', array( + 'constraints' => array( +// new NotBlank() + ), +// 'label' => Translator::getInstance()->trans('Category picture title *'), +// 'label_attr' => array( +// 'for' => 'title' +// ) + )) +// ->add('description', 'text', array( +// 'constraints' => array( +// new NotBlank() +// ), +// 'label' => Translator::getInstance()->trans('Category picture description *'), +// 'label_attr' => array( +// 'for' => 'description' +// ) +// )) +// ->add('chapo', 'text', array( +// 'constraints' => array( +// new NotBlank() +// ), +// 'label' => Translator::getInstance()->trans('Category picture chapo *'), +// 'label_attr' => array( +// 'for' => 'chapo' +// ) +// )) +// ->add('postscriptum', 'text', array( +// 'constraints' => array( +// new NotBlank() +// ), +// 'label' => Translator::getInstance()->trans('Category picture postscriptum *'), +// 'label_attr' => array( +// 'for' => 'postscriptum' +// ) +// )) + + ; + } + + public function getName() + { + return 'thelia_category_picture_creation'; + } +} diff --git a/core/lib/Thelia/Model/CategoryImage.php b/core/lib/Thelia/Model/CategoryImage.php index 5bf964e10..aca77615a 100755 --- a/core/lib/Thelia/Model/CategoryImage.php +++ b/core/lib/Thelia/Model/CategoryImage.php @@ -25,4 +25,48 @@ class CategoryImage extends BaseCategoryImage return true; } + + /** + * Get picture absolute path + * + * @return null|string + */ + public function getAbsolutePath() + { + return null === $this->file + ? null + : $this->getUploadRootDir().'/'.$this->file; + } + + /** + * Get picture web path + * + * @return null|string + */ + public function getWebPath() + { + return null === $this->file + ? null + : $this->getUploadDir().'/'.$this->file; + } + + /** + * The absolute directory path where uploaded + * documents should be saved + * @return string + */ + protected function getUploadRootDir() + { + return __DIR__.'/../../../../../'.$this->getUploadDir(); + } + + /** + * Get rid of the __DIR__ so it doesn't screw up + * when displaying uploaded doc/image in the view. + * @return string + */ + protected function getUploadDir() + { + return 'local/media/images/category'; + } } diff --git a/templates/admin/default/category-edit.html b/templates/admin/default/category-edit.html index 723cf8242..6d1c4a9c2 100755 --- a/templates/admin/default/category-edit.html +++ b/templates/admin/default/category-edit.html @@ -246,6 +246,31 @@
+ image + {form name="thelia.admin.category.picture.creation"} + + {form_hidden_fields form=$form} + + + {form_field form=$form field='title'} +
+ + + {if $error}{$message}{/if} +
+ {/form_field} + + {form_field form=$form field='file'} +
+ + + {if $error}{$message}{/if} +
+ {/form_field} + + + + {/form}
From 1468cb823c2c96423f29edece973de04c446fc01 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 19 Sep 2013 08:46:30 +0200 Subject: [PATCH 013/192] complete some informations in readme file --- Readme.md | 4 +- .../Controller/Admin/FolderController.php | 138 +++++++++++++++++- 2 files changed, 139 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index ac0862dae..ed4edf9ef 100755 --- a/Readme.md +++ b/Readme.md @@ -35,10 +35,10 @@ Installation ------------ ``` bash -$ git clone --recursive https://github.com/thelia/thelia.git +$ git clone https://github.com/thelia/thelia.git $ cd thelia $ curl -sS https://getcomposer.org/installer | php -$ php composer.phar install --optimize-autoloader +$ php composer.phar install --prefer-dist --optimize-autoloader ``` Finish the installation using cli tools : diff --git a/core/lib/Thelia/Controller/Admin/FolderController.php b/core/lib/Thelia/Controller/Admin/FolderController.php index dd2feb823..3a02949b7 100644 --- a/core/lib/Thelia/Controller/Admin/FolderController.php +++ b/core/lib/Thelia/Controller/Admin/FolderController.php @@ -28,7 +28,7 @@ namespace Thelia\Controller\Admin; * @package Thelia\Controller\Admin * @author Manuel Raynaud */ -class FolderController extends BaseAdminController +class FolderController extends AbstractCrudController { public function indexAction() { @@ -43,4 +43,140 @@ class FolderController extends BaseAdminController "folder_id" => $folder_id )); } + + /** + * Return the creation form for this object + */ + protected function getCreationForm() + { + // TODO: Implement getCreationForm() method. + } + + /** + * Return the update form for this object + */ + protected function getUpdateForm() + { + // TODO: Implement getUpdateForm() method. + } + + /** + * Hydrate the update form for this object, before passing it to the update template + * + * @param unknown $object + */ + protected function hydrateObjectForm($object) + { + // TODO: Implement hydrateObjectForm() method. + } + + /** + * Creates the creation event with the provided form data + * + * @param unknown $formData + */ + protected function getCreationEvent($formData) + { + // TODO: Implement getCreationEvent() method. + } + + /** + * Creates the update event with the provided form data + * + * @param unknown $formData + */ + protected function getUpdateEvent($formData) + { + // TODO: Implement getUpdateEvent() method. + } + + /** + * Creates the delete event with the provided form data + */ + protected function getDeleteEvent() + { + // TODO: Implement getDeleteEvent() method. + } + + /** + * Return true if the event contains the object, e.g. the action has updated the object in the event. + * + * @param unknown $event + */ + protected function eventContainsObject($event) + { + // TODO: Implement eventContainsObject() method. + } + + /** + * Get the created object from an event. + * + * @param unknown $createEvent + */ + protected function getObjectFromEvent($event) + { + // TODO: Implement getObjectFromEvent() method. + } + + /** + * Load an existing object from the database + */ + protected function getExistingObject() + { + // TODO: Implement getExistingObject() method. + } + + /** + * Returns the object label form the object event (name, title, etc.) + * + * @param unknown $object + */ + protected function getObjectLabel($object) + { + // TODO: Implement getObjectLabel() method. + } + + /** + * Returns the object ID from the object + * + * @param unknown $object + */ + protected function getObjectId($object) + { + // TODO: Implement getObjectId() method. + } + + /** + * Render the main list template + * + * @param unknown $currentOrder, if any, null otherwise. + */ + protected function renderListTemplate($currentOrder) + { + // TODO: Implement renderListTemplate() method. + } + + /** + * Render the edition template + */ + protected function renderEditionTemplate() + { + // TODO: Implement renderEditionTemplate() method. + } + + /** + * Redirect to the edition template + */ + protected function redirectToEditionTemplate() + { + // TODO: Implement redirectToEditionTemplate() method. + } + + /** + * Redirect to the list template + */ + protected function redirectToListTemplate() + { + // TODO: Implement redirectToListTemplate() method. + } } \ No newline at end of file From dad0c1b6a5a2791e45fcaf84c38afcb84a769f14 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 19 Sep 2013 09:07:53 +0200 Subject: [PATCH 014/192] begin working with http cache header --- .../lib/Thelia/Core/EventListener/ViewListener.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Core/EventListener/ViewListener.php b/core/lib/Thelia/Core/EventListener/ViewListener.php index 9de281dbe..dac1f943d 100755 --- a/core/lib/Thelia/Core/EventListener/ViewListener.php +++ b/core/lib/Thelia/Core/EventListener/ViewListener.php @@ -79,10 +79,20 @@ class ViewListener implements EventSubscriberInterface $content = $parser->getContent(); if ($content instanceof Response) { - $event->setResponse($content); + $response = $content;$event->setResponse($content); } else { - $event->setResponse(new Response($content, $parser->getStatus() ?: 200)); + $response = new Response($content, $parser->getStatus() ?: 200); } + + $response->setCache(array( + 'last_modified' => new \DateTime(), + 'max_age' => 600, + 's_maxage' => 600, + 'private' => false, + 'public' => true, + )); + + $event->setResponse($response); } catch (ResourceNotFoundException $e) { $event->setResponse(new Response($e->getMessage(), 404)); } catch (AuthenticationException $ex) { From fd46ba3648d4124b7ddd1014359164ed0712b57c Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 19 Sep 2013 09:23:43 +0200 Subject: [PATCH 015/192] create constant for folder management --- core/lib/Thelia/Core/Event/TheliaEvents.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 6a024f33b..4cec42be5 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -165,6 +165,27 @@ final class TheliaEvents const BEFORE_UPDATECATEGORY = "action.before_updateCategory"; const AFTER_UPDATECATEGORY = "action.after_updateCategory"; + // -- folder management ----------------------------------------------- + + const FOLDER_CREATE = "action.createFolder"; + const FOLDER_UPDATE = "action.updateFolder"; + const FOLDER_DELETE = "action.deleteFolder"; + const FOLDER_TOGGLE_VISIBILITY = "action.toggleFolderVisibility"; + const FOLDER_UPDATE_POSITION = "action.updateFolderPosition"; + +// const FOLDER_ADD_CONTENT = "action.categoryAddContent"; +// const FOLDER_REMOVE_CONTENT = "action.categoryRemoveContent"; + + const BEFORE_CREATEFOLDER = "action.before_createFolder"; + const AFTER_CREATEFOLDER = "action.after_createFolder"; + + const BEFORE_DELETEFOLDER = "action.before_deleteFolder"; + const AFTER_DELETEFOLDER = "action.after_deleteFolder"; + + const BEFORE_UPDATEFOLDER = "action.before_updateFolder"; + const AFTER_UPDATEFOLDER = "action.after_updateFolder"; + + // -- Product management ----------------------------------------------- const PRODUCT_CREATE = "action.createProduct"; From 466798e7af0716425ae2ffac2a427c883004585c Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 19 Sep 2013 11:31:13 +0200 Subject: [PATCH 016/192] start creating folder management --- .../Thelia/Config/Resources/routing/admin.xml | 5 +- .../Controller/Admin/FolderController.php | 57 +++++++++++++------ templates/admin/default/folder-edit.html | 8 +-- templates/admin/default/folders.html | 14 ++--- 4 files changed, 54 insertions(+), 30 deletions(-) diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 50b622451..053dbc24e 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -159,16 +159,15 @@ - Thelia\Controller\Admin\FolderController::indexAction + Thelia\Controller\Admin\FolderController::defaultAction Thelia\Controller\Admin\FolderController::createAction - + Thelia\Controller\Admin\FolderController::updateAction - \d+ diff --git a/core/lib/Thelia/Controller/Admin/FolderController.php b/core/lib/Thelia/Controller/Admin/FolderController.php index 3a02949b7..4575035da 100644 --- a/core/lib/Thelia/Controller/Admin/FolderController.php +++ b/core/lib/Thelia/Controller/Admin/FolderController.php @@ -22,6 +22,7 @@ /*************************************************************************************/ namespace Thelia\Controller\Admin; +use Thelia\Core\Event\TheliaEvents; /** * Class FolderController @@ -30,18 +31,25 @@ namespace Thelia\Controller\Admin; */ class FolderController extends AbstractCrudController { - public function indexAction() - { - if (null !== $response = $this->checkAuth("admin.folder.view")) return $response; - return $this->render("folders", array("display_folder" => 20)); - } - - public function updateAction($folder_id) - { - return $this->render("folder-edit", array( - "folder_id" => $folder_id - )); + public function __construct() + { + parent::__construct( + 'folder', + 'manual', + 'folder_order', + + 'admin.folder.default', + 'admin.folder.create', + 'admin.folder.update', + 'admin.folder.delete', + + TheliaEvents::FOLDER_CREATE, + TheliaEvents::FOLDER_UPDATE, + TheliaEvents::FOLDER_DELETE, + TheliaEvents::FOLDER_TOGGLE_VISIBILITY, + TheliaEvents::FOLDER_UPDATE_POSITION + ); } /** @@ -151,17 +159,34 @@ class FolderController extends AbstractCrudController * * @param unknown $currentOrder, if any, null otherwise. */ - protected function renderListTemplate($currentOrder) - { - // TODO: Implement renderListTemplate() method. + protected function renderListTemplate($currentOrder) { + + // Get product order + $product_order = $this->getListOrderFromSession('content', 'content_order', 'manual'); + + return $this->render('folders', + array( + 'folder_order' => $currentOrder, + 'content_order' => $product_order, + 'folder_id' => $this->getRequest()->get('folder_id', 0) + )); } + /** * Render the edition template */ - protected function renderEditionTemplate() + protected function renderEditionTemplate() { + + return $this->render('folder-edit', $this->getEditionArguments()); + } + + protected function getEditionArguments() { - // TODO: Implement renderEditionTemplate() method. + return array( + 'folder_id' => $this->getRequest()->get('folder_id', 0), + 'current_tab' => $this->getRequest()->get('current_tab', 'general') + ); } /** diff --git a/templates/admin/default/folder-edit.html b/templates/admin/default/folder-edit.html index 6986a1e69..cba9a2742 100644 --- a/templates/admin/default/folder-edit.html +++ b/templates/admin/default/folder-edit.html @@ -101,9 +101,9 @@ {$myparent=$PARENT} - {loop name="fold-parent" type="folder-tree" visible="*" folder="0"} + {* loop name="fold-parent" type="folder-tree" visible="*" folder="0"} - {/loop} + {/loop *}
@@ -209,7 +209,7 @@ - {loop name="assigned_contents" type="associated_content" folder="$folder_id" backend_context="1" lang="$edit_language_id"} + {*loop name="assigned_contents" type="associated_content" folder="$folder_id" backend_context="1" lang="$edit_language_id"} {$ID} @@ -239,7 +239,7 @@ - {/elseloop} + {/elseloop*} diff --git a/templates/admin/default/folders.html b/templates/admin/default/folders.html index e836770ab..89e02b774 100644 --- a/templates/admin/default/folders.html +++ b/templates/admin/default/folders.html @@ -45,7 +45,7 @@ current_order=$folder_order order='id' reverse_order='id_reverse' - path={url path='/admin/folders' id_folder=$folder_id} + path={url path='/admin/folders' folder_id=$folder_id} request_parameter_name='folder_order' label="{intl l='ID'}" } @@ -58,7 +58,7 @@ current_order=$folder_order order='alpha' reverse_order='alpha_reverse' - path={url path='/admin/folders' id_folder=$folder_id} + path={url path='/admin/folders' folder_id=$folder_id} request_parameter_name='folder_order' label="{intl l='Folder title'}" } @@ -71,7 +71,7 @@ current_order=$folder_order order='visible' reverse_order='visible_reverse' - path={url path='/admin/folders' id_folder=$folder_id} + path={url path='/admin/folders' folder_id=$folder_id} request_parameter_name='folder_order' label="{intl l='Online'}" } @@ -82,7 +82,7 @@ current_order=$folder_order order='manual' reverse_order='manual_reverse' - path={url path='/admin/folders' id_folder=$folder_id} + path={url path='/admin/folders' folder_id=$folder_id} request_parameter_name='folder_order' label="{intl l='Position'}" } @@ -99,12 +99,12 @@ {loop type="image" name="folder_image" source="folder" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} -
{$TITLE} + {$TITLE} {/loop} - + {$TITLE} @@ -138,7 +138,7 @@
- + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.folders.edit"} From cb20f5e38b4e52516bddaa53c4d1705d5e0310d1 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 19 Sep 2013 16:33:34 +0200 Subject: [PATCH 017/192] add block more info in product template --- templates/default/product.html | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/templates/default/product.html b/templates/default/product.html index f5224a9d2..8888ac606 100644 --- a/templates/default/product.html +++ b/templates/default/product.html @@ -193,7 +193,17 @@

{$DESCRIPTION}

-

Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.

+ {ifloop rel="feature_value_info"} +
    + {loop name="feature_info" type="feature" product="{$ID}"} +
  • {$TITLE} : + {loop name="feature_value_info" type="feature_value" feature="{$ID}" product="{product attr="id"}"} + {$TITLE} + {/loop} +
  • + {/loop} +
+ {/ifloop}
From af532ea271ca332c46aa08afef30f3a724bf0626 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 19 Sep 2013 16:45:38 +0200 Subject: [PATCH 018/192] change link to home page in front template --- templates/default/account.html | 2 +- templates/default/address-update.html | 2 +- templates/default/address.html | 4 ++-- templates/default/login.html | 2 +- templates/default/password.html | 2 +- templates/default/product.html | 2 +- templates/default/register.html | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/templates/default/account.html b/templates/default/account.html index cffd5d754..187847ced 100644 --- a/templates/default/account.html +++ b/templates/default/account.html @@ -8,7 +8,7 @@ diff --git a/templates/default/address-update.html b/templates/default/address-update.html index 51739d849..9e58e19ac 100644 --- a/templates/default/address-update.html +++ b/templates/default/address-update.html @@ -8,7 +8,7 @@