diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index 254560453..b684d06e2 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -129,6 +129,7 @@ abstract class BaseLoop $loopType = isset($nameValuePairs['type']) ? $nameValuePairs['type'] : "undefined"; $loopName = isset($nameValuePairs['name']) ? $nameValuePairs['name'] : "undefined"; + $this->args->rewind(); while (($argument = $this->args->current()) !== false) { $this->args->next(); diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php index 4fb6e7874..acd3f9043 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php @@ -54,13 +54,17 @@ class ProductTest extends BaseLoopTestor { $product = ProductQuery::create()->findOne(); - $loop = new Product($this->container); - $loop->initializeArgs(array( - "type" => "product", - "name" => "product", - "id" => $product->getId(), + $this->instance->initializeArgs(array_merge( + $this->getMandatoryArguments(), + array( + "type" => "product", + "name" => "product", + "id" => $product->getId(), + ) )); - $loopResults = $loop->exec($pagination); + + $dummy = null; + $loopResults = $this->instance->exec($dummy); $this->assertEquals(1, $loopResults->getCount()); @@ -68,4 +72,18 @@ class ProductTest extends BaseLoopTestor $this->assertEquals($product->getId(), $substitutions['ID']); } + + public function testSearchLimit() + { + $this->instance->initializeArgs(array( + "type" => "product", + "name" => "product", + "limit" => 3, + )); + + $dummy = null; + $loopResults = $this->instance->exec($dummy); + + $this->assertEquals(3, $loopResults->getCount()); + } }