diff --git a/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php b/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php index 544e06bb0..2b31d265a 100755 --- a/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php +++ b/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php @@ -131,4 +131,42 @@ abstract class BaseLoopTestor extends \PHPUnit_Framework_TestCase $this->assertInstanceOf('\Thelia\Core\Template\Element\LoopResult', $methodReturn); } + + public function baseTestSearchById($id) + { + $this->instance->initializeArgs(array_merge( + $this->getMandatoryArguments(), + array( + "type" => "foo", + "name" => "foo", + "id" => $id, + ) + )); + + $dummy = null; + $loopResults = $this->instance->exec($dummy); + + $this->assertEquals(1, $loopResults->getCount()); + + $substitutions = $loopResults->current()->getVarVal(); + + $this->assertEquals($id, $substitutions['ID']); + } + + public function baseTestSearchWithLimit($limit) + { + $this->instance->initializeArgs(array_merge( + $this->getMandatoryArguments(), + array( + "type" => "foo", + "name" => "foo", + "limit" => $limit, + ) + )); + + $dummy = null; + $loopResults = $this->instance->exec($dummy); + + $this->assertEquals($limit, $loopResults->getCount()); + } } diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/CategoryTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/CategoryTest.php index a2a320693..ce5f56747 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/CategoryTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/CategoryTest.php @@ -23,6 +23,7 @@ namespace Thelia\Tests\Core\Template\Loop; +use Thelia\Model\CategoryQuery; use Thelia\Tests\Core\Template\Element\BaseLoopTestor; use Thelia\Core\Template\Loop\Category; @@ -48,4 +49,16 @@ class CategoryTest extends BaseLoopTestor { return array(); } + + public function testSearchById() + { + $category = CategoryQuery::create()->findOne(); + + $this->baseTestSearchById($category->getId()); + } + + public function testSearchLimit() + { + $this->baseTestSearchWithLimit(3); + } } diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/ContentTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/ContentTest.php index b6f9d0e3d..3a286200a 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/ContentTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/ContentTest.php @@ -23,6 +23,7 @@ namespace Thelia\Tests\Core\Template\Loop; +use Thelia\Model\ContentQuery; use Thelia\Tests\Core\Template\Element\BaseLoopTestor; use Thelia\Core\Template\Loop\Content; @@ -48,4 +49,16 @@ class ContentTest extends BaseLoopTestor { return array(); } + + public function testSearchById() + { + $content = ContentQuery::create()->findOne(); + + $this->baseTestSearchById($content->getId()); + } + + public function testSearchLimit() + { + $this->baseTestSearchWithLimit(3); + } } diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/FolderTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/FolderTest.php index 2388a86c0..15ea3968c 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/FolderTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/FolderTest.php @@ -23,6 +23,7 @@ namespace Thelia\Tests\Core\Template\Loop; +use Thelia\Model\FolderQuery; use Thelia\Tests\Core\Template\Element\BaseLoopTestor; use Thelia\Core\Template\Loop\Folder; @@ -48,4 +49,16 @@ class FolderTest extends BaseLoopTestor { return array(); } + + public function testSearchById() + { + $folder = FolderQuery::create()->findOne(); + + $this->baseTestSearchById($folder->getId()); + } + + public function testSearchLimit() + { + $this->baseTestSearchWithLimit(3); + } } diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php index acd3f9043..1b307c5b5 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php @@ -54,36 +54,11 @@ class ProductTest extends BaseLoopTestor { $product = ProductQuery::create()->findOne(); - $this->instance->initializeArgs(array_merge( - $this->getMandatoryArguments(), - array( - "type" => "product", - "name" => "product", - "id" => $product->getId(), - ) - )); - - $dummy = null; - $loopResults = $this->instance->exec($dummy); - - $this->assertEquals(1, $loopResults->getCount()); - - $substitutions = $loopResults->current()->getVarVal(); - - $this->assertEquals($product->getId(), $substitutions['ID']); + $this->baseTestSearchById($product->getId()); } 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()); + $this->baseTestSearchWithLimit(3); } }