public function testFlashMessage() { $h = new App($this->container); $s = new Session(); $this->assertEmpty($h->flashMessage()); $s->flash('test & test'); $this->assertEquals('<div class="alert alert-success alert-fade-out">test & test</div>', $h->flashMessage()); $this->assertEmpty($h->flashMessage()); $this->assertEmpty($h->flashMessage()); $s->flashError('test & test'); $this->assertEquals('<div class="alert alert-error">test & test</div>', $h->flashMessage()); $this->assertEmpty($h->flashMessage()); }
public function testGetWithSession() { $this->container['session'] = new Session(); $c = new Config($this->container); session_id('test'); $this->assertTrue(Session::isOpen()); $this->assertEquals('', $c->get('board_columns')); $this->assertEquals('test', $c->get('board_columns', 'test')); $this->container['session']['config'] = array('board_columns' => 'foo', 'empty_value' => 0); $this->assertEquals('foo', $c->get('board_columns')); $this->assertEquals('foo', $c->get('board_columns', 'test')); $this->assertEquals('test', $c->get('empty_value', 'test')); session_id(''); unset($this->container['session']); }
/** * Modify a new user * * @access public * @param array $values Form values * @return array */ public function update(array $values) { $this->prepare($values); $result = $this->db->table(self::TABLE)->eq('id', $values['id'])->update($values); // If the user is connected refresh his session if (Session::isOpen() && $this->userSession->getId() == $values['id']) { $this->userSession->refresh(); } return $result; }
/** * Get a config variable from the session or the database * * @access public * @param string $name Parameter name * @param string $default_value Default value of the parameter * @return string */ public function get($name, $default_value = '') { if (!Session::isOpen()) { return $this->getOption($name, $default_value); } // Cache config in session if (!isset($this->session['config'][$name])) { $this->session['config'] = $this->getAll(); } if (!empty($this->session['config'][$name])) { return $this->session['config'][$name]; } return $default_value; }
/** * Get a config variable from the session or the database * * @access public * @param string $name Parameter name * @param string $default_value Default value of the parameter * @return string */ public function get($name, $default_value = '') { if (!Session::isOpen()) { $value = $this->db->table(self::TABLE)->eq('option', $name)->findOneColumn('value'); return $value ?: $default_value; } // Cache config in session if (!isset($this->session['config'][$name])) { $this->session['config'] = $this->getAll(); } if (!empty($this->session['config'][$name])) { return $this->session['config'][$name]; } return $default_value; }