/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $this->View = new View(); $this->Session = new SessionHelper($this->View); Session::start(); if (!Session::started()) { Session::start(); } $_SESSION = array('test' => 'info', 'Message' => array('flash' => array('element' => 'default', 'params' => array(), 'message' => 'This is a calling'), 'notification' => array('element' => 'session_helper', 'params' => array('title' => 'Notice!', 'name' => 'Alert!'), 'message' => 'This is a test of the emergency broadcasting system'), 'classy' => array('element' => 'default', 'params' => array('class' => 'positive'), 'message' => 'Recorded'), 'bare' => array('element' => null, 'message' => 'Bare message', 'params' => array())), 'Deeply' => array('nested' => array('key' => 'value'))); }
/** * Returns a bool, whether or not the session has been started. * * @return bool */ public function started() { return Session::started(); }
/** * Returns a bool, whether or not the session has been started. * * @return bool */ public function started() { return $this->_session->started(); }
/** * testStarted method * * @return void */ public function testStarted() { $session = new Session(); $this->assertFalse($session->started()); $this->assertTrue($session->start()); $this->assertTrue($session->started()); }
/** * Used by the translation functions in basics.php * Returns a translated string based on current language and translation files stored in locale folder * * @param string $singular String to translate * @param string $plural Plural string (if any) * @param string $domain Domain The domain of the translation. Domains are often used by plugin translations. * If null, the default domain will be used. * @param int $category Category The integer value of the category to use. * @param int $count Count Count is used with $plural to choose the correct plural form. * @param string $language Language to translate string to. * If null it checks for language in session followed by Config.language configuration variable. * @return string translated string. * @throws \Cake\Error\Exception When '' is provided as a domain. */ public static function translate($singular, $plural = null, $domain = null, $category = self::LC_MESSAGES, $count = null, $language = null) { $_this = I18n::getInstance(); if (strpos($singular, "\r\n") !== false) { $singular = str_replace("\r\n", "\n", $singular); } if ($plural !== null && strpos($plural, "\r\n") !== false) { $plural = str_replace("\r\n", "\n", $plural); } if (is_numeric($category)) { $_this->category = $_this->_categories[$category]; } if (empty($language)) { if (Session::started()) { $language = Session::read('Config.language'); } if (empty($language)) { $language = Configure::read('Config.language'); } } if ($_this->_lang && $_this->_lang !== $language || !$_this->_lang) { $lang = $_this->l10n->get($language); $_this->_lang = $lang; } if ($domain === null) { $domain = static::$defaultDomain; } if ($domain === '') { throw new Exception('You cannot use "" as a domain.'); } $_this->domain = $domain . '_' . $_this->l10n->lang; if (!isset($_this->_domains[$domain][$_this->_lang])) { $_this->_domains[$domain][$_this->_lang] = []; $_this->_domains[$domain][$_this->_lang] = Cache::read($_this->domain, '_cake_core_'); } if (!isset($_this->_domains[$domain][$_this->_lang][$_this->category])) { $_this->_bindTextDomain($domain); Cache::write($_this->domain, $_this->_domains[$domain][$_this->_lang], '_cake_core_'); } if ($_this->category === 'LC_TIME') { return $_this->_translateTime($singular, $domain); } if (!isset($count)) { $plurals = 0; } elseif (!empty($_this->_domains[$domain][$_this->_lang][$_this->category]["%plural-c"]) && $_this->_noLocale === false) { $header = $_this->_domains[$domain][$_this->_lang][$_this->category]["%plural-c"]; $plurals = $_this->_pluralGuess($header, $count); } else { if ($count != 1) { $plurals = 1; } else { $plurals = 0; } } if (!empty($_this->_domains[$domain][$_this->_lang][$_this->category][$singular])) { if (($trans = $_this->_domains[$domain][$_this->_lang][$_this->category][$singular]) || $plurals && ($trans = $_this->_domains[$domain][$_this->_lang][$_this->category][$plural])) { if (is_array($trans)) { if (isset($trans[$plurals])) { $trans = $trans[$plurals]; } else { trigger_error(sprintf('Missing plural form translation for "%s" in "%s" domain, "%s" locale. ' . ' Check your po file for correct plurals and valid Plural-Forms header.', $singular, $domain, $_this->_lang), E_USER_WARNING); $trans = $trans[0]; } } if (strlen($trans)) { return $trans; } } } if (!empty($plurals)) { return $plural; } return $singular; }