Example #1
0
 /**
  * @param CurrencyModel $currency
  * @depends testUpdate
  * @return CurrencyModel
  */
 public function testSetDefault(CurrencyModel $currency)
 {
     $event = new CurrencyUpdateEvent($currency->getId());
     $event->setIsDefault(1);
     $action = new Currency($this->getCurrencyConverter());
     $action->setDefault($event, null, $this->getMockEventDispatcher());
     $updatedCurrency = $event->getCurrency();
     $this->assertInstanceOf('Thelia\\Model\\Currency', $updatedCurrency);
     $this->assertEquals(1, $updatedCurrency->getByDefault());
     $this->assertEquals(1, CurrencyQuery::create()->filterByByDefault(true)->count());
     return $updatedCurrency;
 }
Example #2
0
 /**
  * Sets the default currency
  */
 public function setDefaultAction()
 {
     // Check current user authorization
     if (null !== ($response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE))) {
         return $response;
     }
     $changeEvent = new CurrencyUpdateEvent($this->getRequest()->get('currency_id', 0));
     // Create and dispatch the change event
     $changeEvent->setIsDefault(true);
     try {
         $this->dispatch(TheliaEvents::CURRENCY_SET_DEFAULT, $changeEvent);
     } catch (\Exception $ex) {
         // Any error
         return $this->errorPage($ex);
     }
     return $this->redirectToListTemplate();
 }