/** * Tests clear() empties the message bag * * @return void **/ public function testClear() { $handler = new Handler(new Memory()); foreach ($this->data as $item) { $handler->message($item['message'], $item['type'], 'one'); } foreach ($this->data as $item) { $handler->message($item['message'], $item['type'], 'two'); } $handler->clear('one'); $this->assertTrue($handler->isEmpty('one')); $this->assertFalse($handler->any('one')); $m = $handler->messages('one'); $this->assertCount(0, $m, 'Total messages returned does not equal number added'); $this->assertFalse($handler->isEmpty('two')); $this->assertTrue($handler->any('two')); $m = $handler->messages('two'); $this->assertCount(count($this->data), $m, 'Total messages returned does not equal number added'); }
/** * Default task * * @return void */ public function displayTask() { // If authenticator is specified, call the plugin display method, // otherwise (or if method does not exist) use default $authenticator = Request::getVar('authenticator', '', 'method'); Plugin::import('authentication'); $plugins = Plugin::byType('authentication'); foreach ($plugins as $plugin) { $className = 'plg' . $plugin->type . $plugin->name; $params = json_decode($plugin->params); if (class_exists($className) && isset($params->admin_login) && $params->admin_login) { $myplugin = new $className($this, (array) $plugin); if ($plugin->name != $authenticator) { continue; } if (method_exists($className, 'display')) { $this->view->return = Request::getVar('return', null, 'method', 'base64'); $result = $myplugin->display($this->view, null); return $result; } } } // Special treatment is required for this plugin, as this view may be called // after a session timeout. We must reset the view and layout prior to display // otherwise an error will occur. Request::setVar('view', 'login'); Request::setVar('tmpl', 'login'); //Request::setVar('layout', 'default'); // See if we have any messages available by cookie $handler = new Handler(new Cookie(1)); if ($handler->any()) { foreach ($handler->messages() as $message) { Notify::{$message['type']}($message['message']); } } $this->view->setLayout('default')->display(); }
/** * Test that any() returns FALSE if there are no * messages and TRUE if there. * * @covers \Hubzero\Notification\Handler::any * @return void **/ public function testAny() { $handler = new Handler(new Memory()); $this->assertFalse($handler->any()); $handler->error('Lorem ipsum dol.'); $this->assertTrue($handler->any()); }