Merge branch 'actions'
Conflicts: core/lib/Thelia/Action/Currency.php core/lib/Thelia/Core/Event/TheliaEvents.php
This commit is contained in:
@@ -12,3 +12,4 @@ before_script:
|
||||
- composer install --prefer-dist --dev
|
||||
- sh -c "mysql -u$DB_USER -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS thelia;SET FOREIGN_KEY_CHECKS = 1;'; fi"
|
||||
- php Thelia thelia:install --db_host=localhost --db_username=$DB_USER --db_name=thelia
|
||||
- php install/faker.php
|
||||
|
||||
@@ -43,11 +43,22 @@ class Address extends BaseAction implements EventSubscriberInterface
|
||||
$this->createOrUpdate($address, $event);
|
||||
}
|
||||
|
||||
public function update(AddressCreateOrUpdateEvent $event)
|
||||
{
|
||||
$addressModel = $event->getAddress();
|
||||
|
||||
$this->createOrUpdate($addressModel, $event);
|
||||
}
|
||||
|
||||
|
||||
protected function createOrUpdate(AddressModel $addressModel, AddressCreateOrUpdateEvent $event)
|
||||
{
|
||||
$addressModel->setDispatcher($this->getDispatcher());
|
||||
|
||||
if ($addressModel->isNew()) {
|
||||
$addressModel->setLabel($event->getLabel());
|
||||
}
|
||||
|
||||
$addressModel
|
||||
->setTitleId($event->getTitle())
|
||||
->setFirstname($event->getFirstname())
|
||||
@@ -63,6 +74,8 @@ class Address extends BaseAction implements EventSubscriberInterface
|
||||
->setCompany($event->getCompany())
|
||||
->save()
|
||||
;
|
||||
|
||||
$event->setAddress($addressModel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +101,8 @@ class Address extends BaseAction implements EventSubscriberInterface
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::ADDRESS_CREATE => array("create", 128)
|
||||
TheliaEvents::ADDRESS_CREATE => array("create", 128),
|
||||
TheliaEvents::ADDRESS_UPDATE => array("update", 128)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class Category extends BaseAction implements EventSubscriberInterface
|
||||
);
|
||||
}
|
||||
|
||||
public function modify(CategoryChangeEvent $event)
|
||||
public function update(CategoryChangeEvent $event)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ class Category extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::CATEGORY_CREATE => array("create", 128),
|
||||
TheliaEvents::CATEGORY_MODIFY => array("modify", 128),
|
||||
TheliaEvents::CATEGORY_UPDATE => array("update", 128),
|
||||
TheliaEvents::CATEGORY_DELETE => array("delete", 128),
|
||||
|
||||
TheliaEvents::CATEGORY_TOGGLE_VISIBILITY => array("toggleVisibility", 128),
|
||||
|
||||
@@ -148,7 +148,7 @@ class Config extends BaseAction implements EventSubscriberInterface
|
||||
return array(
|
||||
TheliaEvents::CONFIG_CREATE => array("create", 128),
|
||||
TheliaEvents::CONFIG_SETVALUE => array("setValue", 128),
|
||||
TheliaEvents::CONFIG_MODIFY => array("modify", 128),
|
||||
TheliaEvents::CONFIG_UPDATE => array("modify", 128),
|
||||
TheliaEvents::CONFIG_DELETE => array("delete", 128),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
|
||||
*
|
||||
* @param CurrencyChangeEvent $event
|
||||
*/
|
||||
public function modify(CurrencyChangeEvent $event)
|
||||
public function update(CurrencyChangeEvent $event)
|
||||
{
|
||||
$search = CurrencyQuery::create();
|
||||
|
||||
@@ -165,7 +165,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::CURRENCY_CREATE => array("create", 128),
|
||||
TheliaEvents::CURRENCY_MODIFY => array("modify", 128),
|
||||
TheliaEvents::CURRENCY_UPDATE => array("update", 128),
|
||||
TheliaEvents::CURRENCY_DELETE => array("delete", 128),
|
||||
TheliaEvents::CURRENCY_SET_DEFAULT => array("setDefault", 128),
|
||||
TheliaEvents::CURRENCY_UPDATE_RATES => array("updateRates", 128),
|
||||
|
||||
@@ -118,7 +118,7 @@ class Message extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::MESSAGE_CREATE => array("create", 128),
|
||||
TheliaEvents::MESSAGE_MODIFY => array("modify", 128),
|
||||
TheliaEvents::MESSAGE_UPDATE => array("modify", 128),
|
||||
TheliaEvents::MESSAGE_DELETE => array("delete", 128),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ class ConfigController extends BaseAdminController
|
||||
->setPostscriptum($data['postscriptum'])
|
||||
;
|
||||
|
||||
$this->dispatch(TheliaEvents::CONFIG_MODIFY, $changeEvent);
|
||||
$this->dispatch(TheliaEvents::CONFIG_UPDATE, $changeEvent);
|
||||
|
||||
// Log config modification
|
||||
$changedObject = $changeEvent->getConfig();
|
||||
|
||||
@@ -220,7 +220,7 @@ class CurrencyController extends BaseAdminController
|
||||
->setRate($data['rate'])
|
||||
;
|
||||
|
||||
$this->dispatch(TheliaEvents::CURRENCY_MODIFY, $changeEvent);
|
||||
$this->dispatch(TheliaEvents::CURRENCY_UPDATE, $changeEvent);
|
||||
|
||||
// Log currency modification
|
||||
$changedObject = $changeEvent->getCurrency();
|
||||
|
||||
@@ -204,7 +204,7 @@ class MessageController extends BaseAdminController
|
||||
->setTextMessage($data['text_message'])
|
||||
;
|
||||
|
||||
$this->dispatch(TheliaEvents::MESSAGE_MODIFY, $changeEvent);
|
||||
$this->dispatch(TheliaEvents::MESSAGE_UPDATE, $changeEvent);
|
||||
|
||||
// Log message modification
|
||||
$changedObject = $changeEvent->getMessage();
|
||||
|
||||
@@ -74,7 +74,7 @@ class CartController extends BaseFrontController
|
||||
$cartEvent->setQuantity($this->getRequest()->get("quantity"));
|
||||
|
||||
try {
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_CHANGEITEM, $cartEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_UPDATEITEM, $cartEvent);
|
||||
|
||||
$this->redirectSuccess();
|
||||
} catch(PropelException $e) {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Thelia\Model\Address;
|
||||
use Thelia\Model\Customer;
|
||||
|
||||
|
||||
@@ -103,7 +104,12 @@ class AddressCreateOrUpdateEvent extends Event
|
||||
*/
|
||||
protected $customer;
|
||||
|
||||
function __construct($label, $title, $firstname, $lastname, $address1, $address2, $address3, $zipcode, $city, $country, $cellphone, $phone, $company, Customer $customer)
|
||||
/**
|
||||
* @var \Thelia\Model\Address
|
||||
*/
|
||||
protected $address;
|
||||
|
||||
function __construct($label, $title, $firstname, $lastname, $address1, $address2, $address3, $zipcode, $city, $country, $cellphone, $phone, $company)
|
||||
{
|
||||
$this->address1 = $address1;
|
||||
$this->address2 = $address2;
|
||||
@@ -118,7 +124,6 @@ class AddressCreateOrUpdateEvent extends Event
|
||||
$this->phone = $phone;
|
||||
$this->title = $title;
|
||||
$this->zipcode = $zipcode;
|
||||
$this->customer = $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,6 +230,14 @@ class AddressCreateOrUpdateEvent extends Event
|
||||
return $this->zipcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Model\Customer $customer
|
||||
*/
|
||||
public function setCustomer(Customer $customer)
|
||||
{
|
||||
$this->customer = $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Customer
|
||||
*/
|
||||
@@ -233,4 +246,22 @@ class AddressCreateOrUpdateEvent extends Event
|
||||
return $this->customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Model\Address $address
|
||||
*/
|
||||
public function setAddress(Address $address)
|
||||
{
|
||||
$this->address = $address;
|
||||
$this->setCustomer($address->getCustomer());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Address
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -64,7 +64,7 @@ final class TheliaEvents
|
||||
/**
|
||||
* sent on customer account update
|
||||
*/
|
||||
const CUSTOMER_UPDATEACCOUNT = "action.modifyCustomer";
|
||||
const CUSTOMER_UPDATEACCOUNT = "action.updateCustomer";
|
||||
|
||||
/**
|
||||
* Sent before the logout of the administrator.
|
||||
@@ -88,16 +88,21 @@ final class TheliaEvents
|
||||
/**
|
||||
* Sent once the customer change form has been successfully validated, and before customer update in the database.
|
||||
*/
|
||||
const BEFORE_CHANGECUSTOMER = "action.before_changecustomer";
|
||||
const BEFORE_CHANGECUSTOMER = "action.before_updateCustomer";
|
||||
/**
|
||||
* Sent just after a successful update of a customer in the database.
|
||||
*/
|
||||
const AFTER_CHANGECUSTOMER = "action.after_changecustomer";
|
||||
const AFTER_CHANGECUSTOMER = "action.after_updateCustomer";
|
||||
|
||||
/**
|
||||
* sent for address creation
|
||||
*/
|
||||
const ADDRESS_CREATE = "action.addressCreate";
|
||||
const ADDRESS_CREATE = "action.createAddress";
|
||||
|
||||
/**
|
||||
* sent for address creation
|
||||
*/
|
||||
const ADDRESS_UPDATE = "action.updateAddress";
|
||||
|
||||
/**
|
||||
* Sent once the category creation form has been successfully validated, and before category insertion in the database.
|
||||
@@ -108,7 +113,7 @@ final class TheliaEvents
|
||||
* Create, change or delete a category
|
||||
*/
|
||||
const CATEGORY_CREATE = "action.createCategory";
|
||||
const CATEGORY_MODIFY = "action.modifyCategory";
|
||||
const CATEGORY_UPDATE = "action.updateCategory";
|
||||
const CATEGORY_DELETE = "action.deleteCategory";
|
||||
|
||||
/**
|
||||
@@ -138,12 +143,12 @@ final class TheliaEvents
|
||||
/**
|
||||
* Sent just before a successful change of a category in the database.
|
||||
*/
|
||||
const BEFORE_CHANGECATEGORY = "action.before_changecategory";
|
||||
const BEFORE_UPDATECATEGORY = "action.before_updateCategory";
|
||||
|
||||
/**
|
||||
* Sent just after a successful change of a category in the database.
|
||||
*/
|
||||
const AFTER_CHANGECATEGORY = "action.after_changecategory";
|
||||
const AFTER_UPDATECATEGORY = "action.after_updateCategory";
|
||||
|
||||
/**
|
||||
* sent when a new existing cat id duplicated. This append when current customer is different from current cart
|
||||
@@ -158,7 +163,7 @@ final class TheliaEvents
|
||||
/**
|
||||
* sent when a cart item is modify
|
||||
*/
|
||||
const AFTER_CARTCHANGEITEM = "cart.modifyItem";
|
||||
const AFTER_CARTUPDATEITEM = "cart.updateItem";
|
||||
|
||||
/**
|
||||
* sent for addArticle action
|
||||
@@ -168,7 +173,7 @@ final class TheliaEvents
|
||||
/**
|
||||
* sent on modify article action
|
||||
*/
|
||||
const CART_CHANGEITEM = "action.changeArticle";
|
||||
const CART_UPDATEITEM = "action.updateArticle";
|
||||
|
||||
const CART_DELETEITEM = "action.deleteArticle";
|
||||
|
||||
@@ -186,14 +191,14 @@ final class TheliaEvents
|
||||
|
||||
const CONFIG_CREATE = "action.createConfig";
|
||||
const CONFIG_SETVALUE = "action.setConfigValue";
|
||||
const CONFIG_MODIFY = "action.changeConfig";
|
||||
const CONFIG_UPDATE = "action.updateConfig";
|
||||
const CONFIG_DELETE = "action.deleteConfig";
|
||||
|
||||
const BEFORE_CREATECONFIG = "action.before_createConfig";
|
||||
const AFTER_CREATECONFIG = "action.after_createConfig";
|
||||
|
||||
const BEFORE_CHANGECONFIG = "action.before_changeConfig";
|
||||
const AFTER_CHANGECONFIG = "action.after_changeConfig";
|
||||
const BEFORE_UPDATECONFIG = "action.before_updateConfig";
|
||||
const AFTER_UPDATECONFIG = "action.after_updateConfig";
|
||||
|
||||
const BEFORE_DELETECONFIG = "action.before_deleteConfig";
|
||||
const AFTER_DELETECONFIG = "action.after_deleteConfig";
|
||||
@@ -201,14 +206,14 @@ final class TheliaEvents
|
||||
// -- Messages management ---------------------------------------------
|
||||
|
||||
const MESSAGE_CREATE = "action.createMessage";
|
||||
const MESSAGE_MODIFY = "action.changeMessage";
|
||||
const MESSAGE_UPDATE = "action.updateMessage";
|
||||
const MESSAGE_DELETE = "action.deleteMessage";
|
||||
|
||||
const BEFORE_CREATEMESSAGE = "action.before_createMessage";
|
||||
const AFTER_CREATEMESSAGE = "action.after_createMessage";
|
||||
|
||||
const BEFORE_CHANGEMESSAGE = "action.before_changeMessage";
|
||||
const AFTER_CHANGEMESSAGE = "action.after_changeMessage";
|
||||
const BEFORE_UPDATEMESSAGE = "action.before_updateMessage";
|
||||
const AFTER_UPDATEMESSAGE = "action.after_updateMessage";
|
||||
|
||||
const BEFORE_DELETEMESSAGE = "action.before_deleteMessage";
|
||||
const AFTER_DELETEMESSAGE = "action.after_deleteMessage";
|
||||
@@ -216,16 +221,17 @@ final class TheliaEvents
|
||||
// -- Currencies management ---------------------------------------------
|
||||
|
||||
const CURRENCY_CREATE = "action.createCurrency";
|
||||
const CURRENCY_MODIFY = "action.changeCurrency";
|
||||
const CURRENCY_UPDATE = "action.updateCurrency";
|
||||
const CURRENCY_DELETE = "action.deleteCurrency";
|
||||
const CURRENCY_SET_DEFAULT = "action.setDefaultCurrency";
|
||||
const CURRENCY_UPDATE_RATES = "action.updateCurrencyRates";
|
||||
|
||||
|
||||
const BEFORE_CREATECURRENCY = "action.before_createCurrency";
|
||||
const AFTER_CREATECURRENCY = "action.after_createCurrency";
|
||||
|
||||
const BEFORE_CHANGECURRENCY = "action.before_changeCurrency";
|
||||
const AFTER_CHANGECURRENCY = "action.after_changeCurrency";
|
||||
const BEFORE_UPDATECURRENCY = "action.before_updateCurrency";
|
||||
const AFTER_UPDATECURRENCY = "action.after_updateCurrency";
|
||||
|
||||
const BEFORE_DELETECURRENCY = "action.before_deleteCurrency";
|
||||
const AFTER_DELETECURRENCY = "action.after_deleteCurrency";
|
||||
|
||||
@@ -32,7 +32,7 @@ class CartItem extends BaseCartItem
|
||||
if ($this->dispatcher) {
|
||||
$cartEvent = new CartEvent($this->getCart());
|
||||
|
||||
$this->dispatcher->dispatch(TheliaEvents::AFTER_CARTCHANGEITEM, $cartEvent);
|
||||
$this->dispatcher->dispatch(TheliaEvents::AFTER_CARTUPDATEITEM, $cartEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,14 +95,14 @@ class Category extends BaseCategory
|
||||
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CHANGECATEGORY, new CategoryEvent($this));
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATECATEGORY, new CategoryEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CHANGECATEGORY, new CategoryEvent($this));
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATECATEGORY, new CategoryEvent($this));
|
||||
}
|
||||
|
||||
public function preDelete(ConnectionInterface $con = null)
|
||||
|
||||
@@ -55,7 +55,7 @@ class Config extends BaseConfig {
|
||||
*/
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CHANGECONFIG, new ConfigEvent($this));
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATECONFIG, new ConfigEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class Config extends BaseConfig {
|
||||
*/
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CHANGECONFIG, new ConfigEvent($this));
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATECONFIG, new ConfigEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@ class Currency extends BaseCurrency {
|
||||
*/
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CHANGECURRENCY, new CurrencyEvent($this));
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATECURRENCY, new CurrencyEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class Currency extends BaseCurrency {
|
||||
*/
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CHANGECURRENCY, new CurrencyEvent($this));
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATECURRENCY, new CurrencyEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@ class Message extends BaseMessage {
|
||||
*/
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CHANGEMESSAGE, new MessageEvent($this));
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEMESSAGE, new MessageEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class Message extends BaseMessage {
|
||||
*/
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CHANGEMESSAGE, new MessageEvent($this));
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATEMESSAGE, new MessageEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
145
core/lib/Thelia/Tests/Action/AddressTest.php
Normal file
145
core/lib/Thelia/Tests/Action/AddressTest.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Action;
|
||||
use Thelia\Action\Address;
|
||||
use Thelia\Core\Event\AddressCreateOrUpdateEvent;
|
||||
use Thelia\Model\Base\CustomerQuery;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* test address eventListener
|
||||
*
|
||||
* Class AddressTest
|
||||
* @package Thelia\Tests\Action
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AddressTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function getContainer()
|
||||
{
|
||||
$container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
|
||||
|
||||
$dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface");
|
||||
|
||||
$container->set("event_dispatcher", $dispatcher);
|
||||
|
||||
return $container;
|
||||
}
|
||||
|
||||
public function testCreatedAddress()
|
||||
{
|
||||
$customer = CustomerQuery::create()->findOne();
|
||||
|
||||
$AddressCreateOrUpdateEvent = new AddressCreateOrUpdateEvent(
|
||||
"test address",
|
||||
1,
|
||||
"Thelia",
|
||||
"Thelia",
|
||||
"5 rue rochon",
|
||||
"",
|
||||
"",
|
||||
"63000",
|
||||
"clermont-ferrand",
|
||||
64,
|
||||
"0102030405",
|
||||
"",
|
||||
""
|
||||
);
|
||||
$AddressCreateOrUpdateEvent->setCustomer($customer);
|
||||
|
||||
$actionAddress = new Address($this->getContainer());
|
||||
$actionAddress->create($AddressCreateOrUpdateEvent);
|
||||
|
||||
$createdAddress = $AddressCreateOrUpdateEvent->getAddress();
|
||||
|
||||
$this->assertInstanceOf("Thelia\Model\Address", $createdAddress);
|
||||
$this->assertFalse($createdAddress->isNew());
|
||||
$this->assertSame($customer, $createdAddress->getCustomer());
|
||||
|
||||
$this->assertEquals($AddressCreateOrUpdateEvent->getLabel(), $createdAddress->getLabel());
|
||||
$this->assertEquals($AddressCreateOrUpdateEvent->getTitle(), $createdAddress->getTitleId());
|
||||
$this->assertEquals($AddressCreateOrUpdateEvent->getFirstname(), $createdAddress->getFirstname());
|
||||
$this->assertEquals($AddressCreateOrUpdateEvent->getLastname(), $createdAddress->getLastname());
|
||||
$this->assertEquals($AddressCreateOrUpdateEvent->getAddress1(), $createdAddress->getAddress1());
|
||||
$this->assertEquals($AddressCreateOrUpdateEvent->getAddress2(), $createdAddress->getAddress2());
|
||||
$this->assertEquals($AddressCreateOrUpdateEvent->getAddress3(), $createdAddress->getAddress3());
|
||||
$this->assertEquals($AddressCreateOrUpdateEvent->getZipcode(), $createdAddress->getZipcode());
|
||||
$this->assertEquals($AddressCreateOrUpdateEvent->getCity(), $createdAddress->getCity());
|
||||
$this->assertEquals($AddressCreateOrUpdateEvent->getCountry(), $createdAddress->getCountryId());
|
||||
$this->assertEquals($AddressCreateOrUpdateEvent->getPhone(), $createdAddress->getPhone());
|
||||
$this->assertEquals($AddressCreateOrUpdateEvent->getCellphone(), $createdAddress->getCellphone());
|
||||
$this->assertEquals($AddressCreateOrUpdateEvent->getCompany(), $createdAddress->getCompany());
|
||||
}
|
||||
|
||||
public function testUpdatedAddress()
|
||||
{
|
||||
|
||||
$customer = CustomerQuery::create()->findOne();
|
||||
$address = $customer->getAddresses()->getFirst();
|
||||
|
||||
$addressEvent = new AddressCreateOrUpdateEvent(
|
||||
"",
|
||||
1,
|
||||
"Thelia modif",
|
||||
"Thelia modif",
|
||||
"cour des étoiles",
|
||||
"rue des miracles",
|
||||
"",
|
||||
"63000",
|
||||
"clermont-ferrand",
|
||||
64,
|
||||
"0102030405",
|
||||
"",
|
||||
""
|
||||
);
|
||||
$addressEvent->setAddress($address);
|
||||
|
||||
$actionAddress = new Address($this->getContainer());
|
||||
$actionAddress->update($addressEvent);
|
||||
|
||||
|
||||
$updatedAddress = $addressEvent->getAddress();
|
||||
$this->assertInstanceOf("Thelia\Model\Address", $updatedAddress);
|
||||
$this->assertFalse($updatedAddress->isNew());
|
||||
$this->assertSame($customer, $updatedAddress->getCustomer());
|
||||
|
||||
$this->assertEquals($address->getLabel(), $updatedAddress->getLabel());
|
||||
$this->assertEquals($addressEvent->getTitle(), $updatedAddress->getTitleId());
|
||||
$this->assertEquals($addressEvent->getFirstname(), $updatedAddress->getFirstname());
|
||||
$this->assertEquals($addressEvent->getLastname(), $updatedAddress->getLastname());
|
||||
$this->assertEquals($addressEvent->getAddress1(), $updatedAddress->getAddress1());
|
||||
$this->assertEquals($addressEvent->getAddress2(), $updatedAddress->getAddress2());
|
||||
$this->assertEquals($addressEvent->getAddress3(), $updatedAddress->getAddress3());
|
||||
$this->assertEquals($addressEvent->getZipcode(), $updatedAddress->getZipcode());
|
||||
$this->assertEquals($addressEvent->getCity(), $updatedAddress->getCity());
|
||||
$this->assertEquals($addressEvent->getCountry(), $updatedAddress->getCountryId());
|
||||
$this->assertEquals($addressEvent->getPhone(), $updatedAddress->getPhone());
|
||||
$this->assertEquals($addressEvent->getCellphone(), $updatedAddress->getCellphone());
|
||||
$this->assertEquals($addressEvent->getCompany(), $updatedAddress->getCompany());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1637,12 +1637,12 @@
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_AFTER_CREATECATEGORY" class="">AFTER_CREATECATEGORY</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_BEFORE_DELETECATEGORY" class="">BEFORE_DELETECATEGORY</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_AFTER_DELETECATEGORY" class="">AFTER_DELETECATEGORY</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_AFTER_CHANGECATEGORY" class="">AFTER_CHANGECATEGORY</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_AFTER_CHANGECATEGORY" class="">AFTER_UPDATECATEGORY</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_CART_DUPLICATE" class="">CART_DUPLICATE</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_AFTER_CARTADDITEM" class="">AFTER_CARTADDITEM</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_AFTER_CARTCHANGEITEM" class="">AFTER_CARTCHANGEITEM</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_AFTER_CARTCHANGEITEM" class="">AFTER_CARTUPDATEITEM</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_CART_ADDITEM" class="">CART_ADDITEM</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_CART_CHANGEITEM" class="">CART_CHANGEITEM</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_CART_CHANGEITEM" class="">CART_UPDATEITEM</a><br />
|
||||
<a href="../classes/Thelia.Core.Event.TheliaEvents.html#constant_CART_DELETEITEM" class="">CART_DELETEITEM</a><br />
|
||||
</section>
|
||||
</section>
|
||||
@@ -2023,8 +2023,8 @@
|
||||
<div class="span8 content class">
|
||||
<a id="constant_AFTER_CHANGECATEGORY" name="constant_AFTER_CHANGECATEGORY" class="anchor"></a>
|
||||
<article id="constant_AFTER_CHANGECATEGORY" class="constant">
|
||||
<h3 class="">AFTER_CHANGECATEGORY</h3>
|
||||
<pre class="signature">AFTER_CHANGECATEGORY</pre>
|
||||
<h3 class="">AFTER_UPDATECATEGORY</h3>
|
||||
<pre class="signature">AFTER_UPDATECATEGORY</pre>
|
||||
<p><em>Sent just after a successful change of a category in the database.</em></p>
|
||||
|
||||
|
||||
@@ -2089,8 +2089,8 @@
|
||||
<div class="span8 content class">
|
||||
<a id="constant_AFTER_CARTCHANGEITEM" name="constant_AFTER_CARTCHANGEITEM" class="anchor"></a>
|
||||
<article id="constant_AFTER_CARTCHANGEITEM" class="constant">
|
||||
<h3 class="">AFTER_CARTCHANGEITEM</h3>
|
||||
<pre class="signature">AFTER_CARTCHANGEITEM</pre>
|
||||
<h3 class="">AFTER_CARTUPDATEITEM</h3>
|
||||
<pre class="signature">AFTER_CARTUPDATEITEM</pre>
|
||||
<p><em>sent when a cart item is modify</em></p>
|
||||
|
||||
|
||||
@@ -2133,8 +2133,8 @@
|
||||
<div class="span8 content class">
|
||||
<a id="constant_CART_CHANGEITEM" name="constant_CART_CHANGEITEM" class="anchor"></a>
|
||||
<article id="constant_CART_CHANGEITEM" class="constant">
|
||||
<h3 class="">CART_CHANGEITEM</h3>
|
||||
<pre class="signature">CART_CHANGEITEM</pre>
|
||||
<h3 class="">CART_UPDATEITEM</h3>
|
||||
<pre class="signature">CART_UPDATEITEM</pre>
|
||||
<p><em>sent on modify article action</em></p>
|
||||
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ class Category extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
$categoryEvent = new CategoryEvent($category);
|
||||
|
||||
$event->getDispatcher()->dispatch(TheliaEvents::AFTER_CHANGECATEGORY, $categoryEvent);
|
||||
$event->getDispatcher()->dispatch(TheliaEvents::AFTER_UPDATECATEGORY, $categoryEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ class CartController extends BaseFrontController
|
||||
$cartEvent->setQuantity($this->getRequest()->get("quantity"));
|
||||
|
||||
try {
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_CHANGEITEM, $cartEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_UPDATEITEM, $cartEvent);
|
||||
|
||||
$this->redirectSuccess();
|
||||
} catch(PropelException $e) {
|
||||
|
||||
@@ -106,7 +106,7 @@ final class TheliaEvents
|
||||
/**
|
||||
* Sent just after a successful change of a category in the database.
|
||||
*/
|
||||
const AFTER_CHANGECATEGORY = "action.after_changecategory";
|
||||
const AFTER_UPDATECATEGORY = "action.after_changecategory";
|
||||
|
||||
/**
|
||||
* sent when a new existing cat id duplicated. This append when current customer is different from current cart
|
||||
@@ -121,7 +121,7 @@ final class TheliaEvents
|
||||
/**
|
||||
* sent when a cart item is modify
|
||||
*/
|
||||
const AFTER_CARTCHANGEITEM = "cart.modifyItem";
|
||||
const AFTER_CARTUPDATEITEM = "cart.modifyItem";
|
||||
|
||||
/**
|
||||
* sent for addArticle action
|
||||
@@ -131,7 +131,7 @@ final class TheliaEvents
|
||||
/**
|
||||
* sent on modify article action
|
||||
*/
|
||||
const CART_CHANGEITEM = "action.changeArticle";
|
||||
const CART_UPDATEITEM = "action.changeArticle";
|
||||
|
||||
const CART_DELETEITEM = "action.deleteArticle";
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class CartItem extends BaseCartItem
|
||||
if ($this->dispatcher) {
|
||||
$cartEvent = new CartEvent($this->getCart());
|
||||
|
||||
$this->dispatcher->dispatch(TheliaEvents::AFTER_CARTCHANGEITEM, $cartEvent);
|
||||
$this->dispatcher->dispatch(TheliaEvents::AFTER_CARTUPDATEITEM, $cartEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user