product loop test
This commit is contained in:
@@ -29,6 +29,7 @@ use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
use Thelia\Core\HttpFoundation\Session\Session;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -82,9 +83,32 @@ abstract class BaseLoopTestor extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->securityContext = new SecurityContext($this->request);*/
|
||||
|
||||
$stubRouterAdmin = $this->getMockBuilder('\Symfony\Component\Routing\Router')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('getContext'))
|
||||
->getMock();
|
||||
|
||||
$stubRequestContext = $this->getMockBuilder('\Symfony\Component\Routing\RequestContext')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('getHost'))
|
||||
->getMock();
|
||||
|
||||
$stubRequestContext->expects($this->any())
|
||||
->method('getHost')
|
||||
->will($this->returnValue('localhost'));
|
||||
|
||||
$stubRouterAdmin->expects($this->any())
|
||||
->method('getContext')
|
||||
->will($this->returnValue(
|
||||
$stubRequestContext
|
||||
));
|
||||
|
||||
|
||||
$this->container->set('request', $request);
|
||||
$this->container->set('event_dispatcher', new EventDispatcher());
|
||||
$this->container->set('thelia.securityContext', new SecurityContext($request));
|
||||
$this->container->set('router.admin', $stubRouterAdmin);
|
||||
$this->container->set('thelia.url.manager', new URL($this->container));
|
||||
|
||||
$this->instance = $this->getTestedInstance();
|
||||
$this->instance->initializeArgs($this->getMandatoryArguments());
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Tests\Core\Template\Loop;
|
||||
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
|
||||
|
||||
use Thelia\Core\Template\Loop\Product;
|
||||
@@ -48,4 +49,23 @@ class ProductTest extends BaseLoopTestor
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function testSearchById()
|
||||
{
|
||||
$product = ProductQuery::create()->findOne();
|
||||
|
||||
$loop = new Product($this->container);
|
||||
$loop->initializeArgs(array(
|
||||
"type" => "product",
|
||||
"name" => "product",
|
||||
"id" => $product->getId(),
|
||||
));
|
||||
$loopResults = $loop->exec($pagination);
|
||||
|
||||
$this->assertEquals(1, $loopResults->getCount());
|
||||
|
||||
$substitutions = $loopResults->current()->getVarVal();
|
||||
|
||||
$this->assertEquals($product->getId(), $substitutions['ID']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user