Removes container from all Thelia actions, but Modules (#198)
This commit is contained in:
@@ -26,7 +26,7 @@ namespace Thelia\Tests\Action;
|
||||
use Thelia\Action\Address;
|
||||
use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent;
|
||||
use Thelia\Model\Base\CustomerQuery;
|
||||
use Thelia\Tests\Action\BaseAction;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Tests\Action;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Thelia\Action\Content;
|
||||
use Thelia\Core\Event\Content\ContentAddFolderEvent;
|
||||
use Thelia\Core\Event\Content\ContentCreateEvent;
|
||||
@@ -44,6 +45,15 @@ use Thelia\Tests\TestCaseWithURLToolSetup;
|
||||
*/
|
||||
class ContentTest extends TestCaseWithURLToolSetup
|
||||
{
|
||||
/**
|
||||
* @var EventDispatcherInterface
|
||||
*/
|
||||
protected $dispatcher;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface");
|
||||
}
|
||||
|
||||
public function getUpdateEvent(&$content)
|
||||
{
|
||||
@@ -52,6 +62,7 @@ class ContentTest extends TestCaseWithURLToolSetup
|
||||
}
|
||||
|
||||
$event = new ContentUpdateEvent($content->getId());
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
$event
|
||||
->setVisible(1)
|
||||
->setLocale($content->getLocale())
|
||||
@@ -78,6 +89,7 @@ class ContentTest extends TestCaseWithURLToolSetup
|
||||
$folder = $this->getRandomFolder();
|
||||
|
||||
$event = new ContentCreateEvent();
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
$event
|
||||
->setVisible(1)
|
||||
->setLocale('en_US')
|
||||
@@ -103,6 +115,7 @@ class ContentTest extends TestCaseWithURLToolSetup
|
||||
$folder = $this->getRandomFolder();
|
||||
|
||||
$event = new ContentUpdateEvent($content->getId());
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
$event
|
||||
->setVisible(1)
|
||||
->setLocale('en_US')
|
||||
@@ -132,6 +145,7 @@ class ContentTest extends TestCaseWithURLToolSetup
|
||||
$content = $this->getRandomContent();
|
||||
|
||||
$event = new ContentDeleteEvent($content->getId());
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
|
||||
$contentAction = new Content($this->getContainer());
|
||||
$contentAction->delete($event);
|
||||
@@ -150,6 +164,7 @@ class ContentTest extends TestCaseWithURLToolSetup
|
||||
$visibility = $content->getVisible();
|
||||
|
||||
$event = new ContentToggleVisibilityEvent($content);
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
|
||||
$contentAction = new Content($this->getContainer());
|
||||
$contentAction->toggleVisibility($event);
|
||||
@@ -173,6 +188,7 @@ class ContentTest extends TestCaseWithURLToolSetup
|
||||
$newPosition = $content->getPosition()-1;
|
||||
|
||||
$event = new UpdatePositionEvent($content->getId(), UpdatePositionEvent::POSITION_UP);
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
|
||||
$contentAction = new Content($this->getContainer());
|
||||
$contentAction->updatePosition($event);
|
||||
@@ -195,6 +211,7 @@ class ContentTest extends TestCaseWithURLToolSetup
|
||||
$newPosition = $content->getPosition()+1;
|
||||
|
||||
$event = new UpdatePositionEvent($content->getId(), UpdatePositionEvent::POSITION_DOWN);
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
|
||||
$contentAction = new Content($this->getContainer());
|
||||
$contentAction->updatePosition($event);
|
||||
@@ -215,6 +232,7 @@ class ContentTest extends TestCaseWithURLToolSetup
|
||||
}
|
||||
|
||||
$event = new UpdatePositionEvent($content->getId(), UpdatePositionEvent::POSITION_ABSOLUTE, 1);
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
|
||||
$contentAction = new Content($this->getContainer());
|
||||
$contentAction->updatePosition($event);
|
||||
@@ -237,6 +255,7 @@ class ContentTest extends TestCaseWithURLToolSetup
|
||||
} while ($test->count() > 0);
|
||||
|
||||
$event = new ContentAddFolderEvent($content, $folder->getId());
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
|
||||
$contentAction = new Content($this->getContainer());
|
||||
$contentAction->addFolder($event);
|
||||
@@ -260,6 +279,7 @@ class ContentTest extends TestCaseWithURLToolSetup
|
||||
public function testRemoveFolder(ContentFolder $association)
|
||||
{
|
||||
$event = new ContentRemoveFolderEvent($association->getContent(), $association->getFolder()->getId());
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
|
||||
$contentAction = new Content($this->getContainer());
|
||||
$contentAction->removeFolder($event);
|
||||
|
||||
@@ -43,6 +43,16 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
{
|
||||
use RewrittenUrlTestTrait;
|
||||
|
||||
/**
|
||||
* @var EventDispatcherInterface
|
||||
*/
|
||||
protected $dispatcher;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface");
|
||||
}
|
||||
|
||||
public function getUpdateEvent(&$folder)
|
||||
{
|
||||
if (!$folder instanceof \Thelia\Model\Folder) {
|
||||
@@ -50,6 +60,7 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
}
|
||||
|
||||
$event = new FolderUpdateEvent($folder->getId());
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
$event
|
||||
->setVisible(1)
|
||||
->setLocale($folder->getLocale())
|
||||
@@ -70,7 +81,7 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
}
|
||||
|
||||
$event = new UpdateSeoEvent($folder->getId());
|
||||
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
$event
|
||||
->setLocale($folder->getLocale())
|
||||
->setMetaTitle($folder->getMetaTitle())
|
||||
@@ -82,14 +93,14 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
|
||||
public function processUpdateSeoAction($event)
|
||||
{
|
||||
$contentAction = new Folder($this->getContainer());
|
||||
$contentAction = new Folder();
|
||||
|
||||
return $contentAction->updateSeo($event);
|
||||
}
|
||||
|
||||
public function processUpdateAction($event)
|
||||
{
|
||||
$contentAction = new Folder($this->getContainer());
|
||||
$contentAction = new Folder();
|
||||
$contentAction->update($event);
|
||||
|
||||
return $event->getFolder();
|
||||
@@ -103,13 +114,14 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
{
|
||||
|
||||
$event = new FolderCreateEvent();
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
$event
|
||||
->setParent(0)
|
||||
->setVisible(1)
|
||||
->setLocale('en_US')
|
||||
->setTitle('folder creation test');
|
||||
|
||||
$folderAction = new Folder($this->getContainer());
|
||||
$folderAction = new Folder();
|
||||
|
||||
$folderAction->create($event);
|
||||
|
||||
@@ -131,7 +143,7 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
|
||||
$visible = !$folder->getVisible();
|
||||
$event = new FolderUpdateEvent($folder->getId());
|
||||
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
$event
|
||||
->setLocale('en_US')
|
||||
->setTitle('test update folder')
|
||||
@@ -142,7 +154,7 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
->setParent(0)
|
||||
;
|
||||
|
||||
$folderAction = new Folder($this->getContainer());
|
||||
$folderAction = new Folder();
|
||||
$folderAction->update($event);
|
||||
|
||||
$updatedFolder = $event->getFolder();
|
||||
@@ -165,8 +177,8 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
$folder = $this->getRandomFolder();
|
||||
|
||||
$event = new FolderDeleteEvent($folder->getId());
|
||||
|
||||
$folderAction = new Folder($this->getContainer());
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
$folderAction = new Folder();
|
||||
$folderAction->delete($event);
|
||||
|
||||
$deletedFolder = $event->getFolder();
|
||||
@@ -185,8 +197,9 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
$visible = $folder->getVisible();
|
||||
|
||||
$event = new FolderToggleVisibilityEvent($folder);
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
|
||||
$folderAction = new Folder($this->getContainer());
|
||||
$folderAction = new Folder();
|
||||
$folderAction->toggleVisibility($event);
|
||||
|
||||
$updatedFolder = $event->getFolder();
|
||||
@@ -208,8 +221,9 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
$newPosition = $folder->getPosition()-1;
|
||||
|
||||
$event = new UpdatePositionEvent($folder->getId(), UpdatePositionEvent::POSITION_UP);
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
|
||||
$folderAction = new Folder($this->getContainer());
|
||||
$folderAction = new Folder();
|
||||
$folderAction->updatePosition($event);
|
||||
|
||||
$updatedFolder = FolderQuery::create()->findPk($folder->getId());
|
||||
@@ -239,8 +253,9 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
$newPosition = $folder->getPosition()+1;
|
||||
|
||||
$event = new UpdatePositionEvent($folder->getId(), UpdatePositionEvent::POSITION_DOWN);
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
|
||||
$folderAction = new Folder($this->getContainer());
|
||||
$folderAction = new Folder();
|
||||
$folderAction->updatePosition($event);
|
||||
|
||||
$updatedFolder = FolderQuery::create()->findPk($folder->getId());
|
||||
@@ -259,8 +274,9 @@ class FolderTest extends TestCaseWithURLToolSetup
|
||||
}
|
||||
|
||||
$event = new UpdatePositionEvent($folder->getId(), UpdatePositionEvent::POSITION_ABSOLUTE, 1);
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
|
||||
$folderAction = new Folder($this->getContainer());
|
||||
$folderAction = new Folder();
|
||||
$folderAction->updatePosition($event);
|
||||
|
||||
$updatedFolder = FolderQuery::create()->findPk($folder->getId());
|
||||
|
||||
@@ -30,11 +30,14 @@ use Thelia\Core\Event\Order\OrderEvent;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\HttpFoundation\Session\Session;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Core\Template\ParserContext;
|
||||
use Thelia\Core\Template\Smarty\SmartyParser;
|
||||
use Thelia\Mailer\MailerFactory;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\Base\OrderAddressQuery;
|
||||
use Thelia\Model\Base\OrderProductQuery;
|
||||
use Thelia\Model\Base\OrderQuery;
|
||||
use Thelia\Model\OrderAddress;
|
||||
|
||||
use Thelia\Model\OrderStatus;
|
||||
use Thelia\Model\ProductSaleElementsQuery;
|
||||
use Thelia\Model\Cart;
|
||||
@@ -85,25 +88,42 @@ class OrderTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
protected $cartItems;
|
||||
|
||||
/**
|
||||
* @var SecurityContext
|
||||
*/
|
||||
protected $securityContext;
|
||||
|
||||
protected $request;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$session = new Session(new MockArraySessionStorage());
|
||||
$request = new Request();
|
||||
|
||||
$dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface");
|
||||
|
||||
$request->setSession($session);
|
||||
$this->request = new Request();
|
||||
$this->request->setSession($session);
|
||||
|
||||
$container->set("event_dispatcher", $dispatcher);
|
||||
$container->set('request', $request);
|
||||
$container->set('thelia.securityContext', new SecurityContext($request));
|
||||
$this->securityContext = new SecurityContext($this->request);
|
||||
|
||||
$this->container = $container;
|
||||
$this->container = new ContainerBuilder();
|
||||
|
||||
$this->container->set("event_dispatcher", $dispatcher);
|
||||
$this->container->set('request', $this->request);
|
||||
|
||||
$this->orderEvent = new OrderEvent(new OrderModel());
|
||||
|
||||
$this->orderAction = new Order($this->container);
|
||||
$this->orderEvent->setDispatcher($dispatcher);
|
||||
|
||||
// public function __construct(Request $this->request, ParserInterface $parser, MailerFactory $mailer, SecurityContext $securityContext)
|
||||
|
||||
$this->orderAction = new Order(
|
||||
$this->request,
|
||||
new SmartyParser($this->request, $dispatcher, new ParserContext($this->request)),
|
||||
new MailerFactory($dispatcher),
|
||||
$this->securityContext
|
||||
);
|
||||
|
||||
/* load customer */
|
||||
$this->customer = $this->loadCustomer();
|
||||
@@ -123,7 +143,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->container->get('thelia.securityContext')->setCustomerUser($customer);
|
||||
$this->securityContext->setCustomerUser($customer);
|
||||
|
||||
return $customer;
|
||||
}
|
||||
@@ -172,7 +192,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->cartItems[] = $cartItem;
|
||||
}
|
||||
|
||||
$this->container->get('request')->getSession()->setCart($cart->getId());
|
||||
$this->request->getSession()->setCart($cart->getId());
|
||||
|
||||
return $cart;
|
||||
}
|
||||
@@ -319,7 +339,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(OrderStatus::CODE_NOT_PAID, $placedOrder->getOrderStatus()->getCode(), 'status does not match');
|
||||
|
||||
/* check lang */
|
||||
$this->assertEquals($this->container->get('request')->getSession()->getLang()->getId(), $placedOrder->getLangId(), 'lang does not match');
|
||||
$this->assertEquals($this->request->getSession()->getLang()->getId(), $placedOrder->getLangId(), 'lang does not match');
|
||||
|
||||
/* check ordered product */
|
||||
foreach ($this->cartItems as $index => $cartItem) {
|
||||
|
||||
@@ -29,6 +29,7 @@ trait RewrittenUrlTestTrait
|
||||
{
|
||||
$object = null;
|
||||
$event = $this->getUpdateSeoEvent($object);
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
|
||||
/* get an existing url */
|
||||
$existingUrl = RewritingUrlQuery::create()
|
||||
@@ -50,6 +51,7 @@ trait RewrittenUrlTestTrait
|
||||
{
|
||||
$object = null;
|
||||
$event = $this->getUpdateSeoEvent($object);
|
||||
$event->setDispatcher($this->dispatcher);
|
||||
|
||||
$currentUrl = $object->getRewrittenUrl($object->getLocale());
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected $uniqid;
|
||||
|
||||
protected $dispatcher;
|
||||
|
||||
public function getContainer()
|
||||
{
|
||||
$container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
|
||||
@@ -67,6 +69,8 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->uniqid = uniqid('', true);
|
||||
|
||||
$this->dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface");
|
||||
|
||||
$this->cartTrait = new MockCartTrait($this->uniqid, $this->getContainer());
|
||||
}
|
||||
|
||||
@@ -79,7 +83,7 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$cartTrait = $this->cartTrait;
|
||||
|
||||
$cart = $cartTrait->getCart($this->request);
|
||||
$cart = $cartTrait->getCart($this->dispatcher, $this->request);
|
||||
|
||||
$this->assertInstanceOf("Thelia\Model\Cart", $cart, '$cart must be an instance of cart model Thelia\Model\Cart');
|
||||
$this->assertNull($cart->getCustomerId());
|
||||
@@ -109,7 +113,7 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$request->getSession()->setCustomerUser($customer);
|
||||
|
||||
$cart = $cartTrait->getCart($request);
|
||||
$cart = $cartTrait->getCart($this->dispatcher, $request);
|
||||
$this->assertInstanceOf("Thelia\Model\Cart", $cart, '$cart must be an instance of cart model Thelia\Model\Cart');
|
||||
$this->assertNotNull($cart->getCustomerId());
|
||||
$this->assertEquals($customer->getId(), $cart->getCustomerId());
|
||||
@@ -137,7 +141,7 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$request->cookies->set("thelia_cart", $uniqid);
|
||||
|
||||
$getCart = $cartTrait->getCart($request);
|
||||
$getCart = $cartTrait->getCart($this->dispatcher, $request);
|
||||
$this->assertInstanceOf("Thelia\Model\Cart", $getCart, '$cart must be an instance of cart model Thelia\Model\Cart');
|
||||
$this->assertNull($getCart->getCustomerId());
|
||||
$this->assertNull($getCart->getAddressDeliveryId());
|
||||
@@ -159,7 +163,7 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase
|
||||
$token = "WrongToken";
|
||||
$request->cookies->set("thelia_cart", $token);
|
||||
|
||||
$cart = $cartTrait->getCart($request);
|
||||
$cart = $cartTrait->getCart($this->dispatcher, $request);
|
||||
$this->assertInstanceOf("Thelia\Model\Cart", $cart, '$cart must be an instance of cart model Thelia\Model\Cart');
|
||||
$this->assertNull($cart->getCustomerId());
|
||||
$this->assertNull($cart->getAddressDeliveryId());
|
||||
@@ -196,7 +200,7 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$request->getSession()->setCustomerUser($customer);
|
||||
|
||||
$getCart = $cartTrait->getCart($request);
|
||||
$getCart = $cartTrait->getCart($this->dispatcher, $request);
|
||||
$this->assertInstanceOf("Thelia\Model\Cart", $getCart, '$cart must be an instance of cart model Thelia\Model\Cart');
|
||||
$this->assertNotNull($getCart->getCustomerId());
|
||||
$this->assertNull($getCart->getAddressDeliveryId());
|
||||
@@ -234,7 +238,7 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$request->getSession()->setCustomerUser($customer);
|
||||
|
||||
$getCart = $cartTrait->getCart($request);
|
||||
$getCart = $cartTrait->getCart($this->dispatcher, $request);
|
||||
$this->assertInstanceOf("Thelia\Model\Cart", $getCart, '$cart must be an instance of cart model Thelia\Model\Cart');
|
||||
$this->assertNotNull($getCart->getCustomerId());
|
||||
$this->assertNull($getCart->getAddressDeliveryId());
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
namespace Thelia\Condition\Implementation;
|
||||
|
||||
use Thelia\Condition\ConditionEvaluator;
|
||||
use Thelia\Condition\Operators;
|
||||
|
||||
use Thelia\Coupon\FacadeInterface;
|
||||
use Thelia\Model\Currency;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ use Thelia\Condition\ConditionFactory;
|
||||
use Thelia\Condition\Operators;
|
||||
use Thelia\Condition\ConditionCollection;
|
||||
use Thelia\Coupon\FacadeInterface;
|
||||
use Thelia\Exception\InvalidConditionValueException;
|
||||
|
||||
use Thelia\Model\Currency;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Thelia\Tests\Core\HttpFoundation;
|
||||
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
|
||||
|
||||
/**
|
||||
* the the helpers addinf in Request class
|
||||
|
||||
@@ -11,9 +11,8 @@ namespace Thelia\Tests\Tools;
|
||||
|
||||
use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Exception\ImageException;
|
||||
use Thelia\Model\Admin;
|
||||
|
||||
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\ContentQuery;
|
||||
use Thelia\Model\FolderQuery;
|
||||
|
||||
Reference in New Issue
Block a user