diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php
index 64f343aa2..bfff73470 100755
--- a/core/lib/Thelia/Action/Cart.php
+++ b/core/lib/Thelia/Action/Cart.php
@@ -73,7 +73,6 @@ class Cart extends BaseAction implements EventSubscriberInterface
$request = $event->getRequest();
$cartAdd = $this->getAddCartForm($request);
-
$form = $cartAdd->getForm();
$form->bind($request);
diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml
index c4b517c38..4eb259842 100755
--- a/core/lib/Thelia/Config/Resources/config.xml
+++ b/core/lib/Thelia/Config/Resources/config.xml
@@ -29,6 +29,7 @@
+
@@ -84,7 +85,7 @@
- true
+ false
%kernel.environment%
%kernel.debug%
diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php
index 7fca50151..954bb58da 100755
--- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php
+++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php
@@ -26,6 +26,7 @@ namespace Thelia\Core\Template\Smarty\Plugins;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Template\Smarty\Assets\SmartyAssetsManager;
+use Thelia\Model\ConfigQuery;
class Assetic extends AbstractSmartyPlugin
{
@@ -35,7 +36,7 @@ class Assetic extends AbstractSmartyPlugin
{
$web_root = THELIA_WEB_DIR;
- $asset_dir_from_web_root = 'assets/admin/default'; // FIXME
+ $asset_dir_from_web_root = ConfigQuery::read('asset_dir_from_web_root', 'assets');
$this->assetManager = new SmartyAssetsManager($web_root, $asset_dir_from_web_root);
}
diff --git a/core/lib/Thelia/Form/CartAdd.php b/core/lib/Thelia/Form/CartAdd.php
index 36f10f2ec..46db7868d 100644
--- a/core/lib/Thelia/Form/CartAdd.php
+++ b/core/lib/Thelia/Form/CartAdd.php
@@ -57,28 +57,28 @@ class CartAdd extends BaseForm
protected function buildForm()
{
$this->formBuilder
- ->add("product", "hidden", array(
+ ->add("product", "text", array(
"constraints" => array(
new Constraints\NotBlank(),
- new Constraints\Callback(array(
- "methods" => array($this, "checkProduct")
- ))
+ new Constraints\Callback(array("methods" => array(
+ array($this, "checkProduct")
+ )))
)
))
- ->add("product_sale_elements_id", "hidden", array(
+ ->add("product_sale_elements_id", "text", array(
"constraints" => array(
- new Constraints\Callback(array(
- "methods" => array($this, "checkStockAvailability")
- ))
+ new Constraints\Callback(array("methods" => array(
+ array($this, "checkStockAvailability")
+ )))
)
))
->add("quantity", "text", array(
"constraints" => array(
new Constraints\NotBlank(),
- new Constraints\Callback(array(
- "methods" => array($this, "checkStock")
- )),
+ new Constraints\Callback(array("methods" => array(
+ array($this, "checkStock")
+ ))),
new Constraints\GreaterThanOrEqual(array(
"value" => 0
))
@@ -89,7 +89,7 @@ class CartAdd extends BaseForm
;
}
- protected function checkProduct($value, ExecutionContextInterface $context)
+ public function checkProduct($value, ExecutionContextInterface $context)
{
$product = ProductQuery::create()->findPk($value);
@@ -98,7 +98,7 @@ class CartAdd extends BaseForm
}
}
- protected function checkStockAvailability($value, ExecutionContextInterface $context)
+ public function checkStockAvailability($value, ExecutionContextInterface $context)
{
if ($value) {
$data = $context->getRoot()->getData();
@@ -114,7 +114,7 @@ class CartAdd extends BaseForm
}
}
- protected function checkStock($value, ExecutionContextInterface $context)
+ public function checkStock($value, ExecutionContextInterface $context)
{
$data = $context->getRoot()->getData();
diff --git a/core/lib/Thelia/Tests/Action/CartTest.php b/core/lib/Thelia/Tests/Action/CartTest.php
index 7570df1d6..c513b2058 100644
--- a/core/lib/Thelia/Tests/Action/CartTest.php
+++ b/core/lib/Thelia/Tests/Action/CartTest.php
@@ -29,6 +29,7 @@ use Thelia\Core\HttpFoundation\Session\Session;
use Thelia\Model\Cart;
use Thelia\Model\Customer;
use Thelia\Model\ProductQuery;
+use Thelia\Model\ProductSaleElementsQuery;
class CartTest extends \PHPUnit_Framework_TestCase
{
@@ -68,7 +69,9 @@ class CartTest extends \PHPUnit_Framework_TestCase
$this->actionCart
->expects($this->any())
- ->method("redirect");
+ ->method("redirect")
+ ->will($this->returnValue(true))
+ ;
}
/**
@@ -250,7 +253,7 @@ class CartTest extends \PHPUnit_Framework_TestCase
/**
* AddArticle action without data in the request, the form must not be valid
*/
- public function testAddArticleWithError()
+/* public function testAddArticleWithError()
{
$actionEvent = new DefaultActionEvent($this->request, "AddArticle");
@@ -258,8 +261,30 @@ class CartTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($actionEvent->hasErrorForm(), "no data in the request, so the action must failed and a form error must be present");
- }
+ }*/
+
+/* public function testAddArticleWithValidDataInRequest()
+ {
+ $request = $this->request;
+ $actionCart = $this->actionCart;
+
+ //find valid product
+
+ $product = ProductQuery::create()->findOne();
+ $productSalementElements = ProductSaleElementsQuery::create()->filterByProduct($product)->findOne();
+
+ $request->query->set("thelia_cart_add[product]", $product->getId());
+ $request->query->set("thelia_cart_add[product_sale_elements_id]", $productSalementElements->getId());
+ $request->query->set("thelia_cart_add[quantity]", 1);
+ $request->setMethod('GET');
+
+ $actionEvent = new DefaultActionEvent($request, "AddArticle");
+
+ $actionCart->addArticle($actionEvent);
+
+ $this->assertFalse($actionEvent->hasErrorForm(), "there is data in the request, form must be valid");
+ }*/
}
\ No newline at end of file