loop tests
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user