public function testPaging() { $currency1 = CM_Model_Currency::create('123', 'FOO'); $currency2 = CM_Model_Currency::create('456', 'BAR'); $paging = new CM_Paging_Currency_All(); $this->assertContainsAll([$currency1, $currency2], $paging); }
public function testCreateAllData() { CMTest_TH::createDefaultCurrency(); $site = $this->getMockSite(); $language = CM_Model_Language::create('English', 'en', true); $currency = CM_Model_Currency::create('978', 'EUR'); $user = CM_Model_User::createStatic(['site' => $site, 'language' => $language, 'currency' => $currency]); $this->assertInternalType('int', $user->getCreated()); $this->assertEquals(time(), $user->getCreated()); $this->assertEquals(time(), $user->getLatestActivity()); $this->assertEquals($site, $user->getSite()); $this->assertEquals($language, $user->getLanguage()); $this->assertEquals($currency, $user->getCurrency()); }
public function testSetNull() { $defaultCurrency = CM_Model_Currency::create('840', 'USD'); $environment = new CM_Frontend_Environment(); $this->assertEquals(CM_Site_Abstract::factory(), $environment->getSite()); $this->assertNull($environment->getViewer()); $this->assertNull($environment->getLanguage()); $this->assertSame('en', $environment->getLocale()); $this->assertEquals(CM_Bootloader::getInstance()->getTimeZone(), $environment->getTimeZone()); $this->assertSame(CM_Bootloader::getInstance()->isDebug(), $environment->isDebug()); $this->assertNull($environment->getLocation()); $this->assertEquals($defaultCurrency, $environment->getCurrency()); $this->assertNull($environment->getClientDevice()); }
/** * @param CM_Model_Currency $currency * @return boolean */ public function contains(CM_Model_Currency $currency) { return in_array($currency->getId(), $this->getItemsRaw()); }
/** * @return CM_Model_Currency */ public function getCurrency() { $currency = $this->_currency; if (null === $currency) { $currency = CM_Model_Currency::getDefaultCurrency(); } return $currency; }
public function load(CM_OutputStream_Interface $output) { $defaultCurrencySettings = CM_Model_Currency::_getConfig()->default; CM_Model_Currency::create($defaultCurrencySettings['code'], $defaultCurrencySettings['abbreviation']); $this->_setLoaded(true); }
/** * @return CM_Frontend_Environment * @throws CM_Exception_AuthRequired */ public function getEnvironment() { $request = $this->getRequest(); $location = $request->getLocation(); $viewer = $request->getViewer(); $currency = null; if (null === $currency && null !== $viewer) { $currency = $viewer->getCurrency(); } if (null === $currency && null !== $location) { $currency = CM_Model_Currency::findByLocation($location); } $clientDevice = new CM_Http_ClientDevice($request); return new CM_Frontend_Environment($this->getSite(), $viewer, $request->getLanguage(), $request->getTimeZone(), null, $location, $currency, $clientDevice); }
public function testDelete() { $currencyDefault = CMTest_TH::createDefaultCurrency(); $currencyEUR = CM_Model_Currency::create('978', 'EUR'); $paging = new CM_Paging_Currency_All(); $this->assertCount(2, $paging); $this->assertContainsAll([$currencyDefault, $currencyEUR], $paging->getItems()); $currencyEUR->delete(); $paging = new CM_Paging_Currency_All(); $this->assertCount(1, $paging); $this->assertContains($currencyDefault, $paging->getItems()); $this->assertNotContains($currencyEUR, $paging->getItems()); }
/** * @return CM_Model_Currency */ public static function createDefaultCurrency() { $defaultCurrencyConfig = CM_Config::get()->CM_Model_Currency->default; if (!($defaultCurrency = CM_Model_Currency::findByAbbreviation($defaultCurrencyConfig['abbreviation']))) { $defaultCurrency = CM_Model_Currency::create($defaultCurrencyConfig['code'], $defaultCurrencyConfig['abbreviation']); } return $defaultCurrency; }
/** * @param CM_Model_Currency $currency */ public function setCurrency(CM_Model_Currency $currency) { CM_Db_Db::update('cm_user', array('currencyId' => $currency->getId()), array('userId' => $this->getId())); $this->_change(); }
/** * @return CM_Frontend_Environment * @throws CM_Exception_AuthRequired */ public function getEnvironment() { $location = $this->getRequest()->getLocation(); $currency = null !== $location ? CM_Model_Currency::findByLocation($location) : null; return new CM_Frontend_Environment($this->getSite(), $this->getRequest()->getViewer(), $this->getRequest()->getLanguage(), null, null, $location, $currency); }