<?php // Get environment & autoloader. require __DIR__ . '/config.php'; // Create services and inject into the app. $di = new \Anax\DI\CDIFactoryDefault(); $di->setShared('fmsg', function () use($di) { $fmsg = new rudden\Flash\FlashMessages(); $fmsg->setDI($di); return $fmsg; }); $app = new \Anax\Kernel\CAnax($di); // Home Route $app->router->add('', function () use($app) { $app->theme->setTitle('Flash'); $app->theme->addStyleSheet('css/flash.css'); $app->fmsg->success('Success message'); $app->fmsg->info('Informative message'); $app->fmsg->error('Error message'); $app->fmsg->warning('Warning message'); $fmsg = $app->fmsg->printMessage(); $app->views->addString($fmsg, 'main'); }); $app->router->handle(); $app->theme->render();
/** * * Test * * @return void * */ public function testPrint() { $flash = new \rudden\Flash\FlashMessages(); $di = new \Anax\DI\CDIFactoryDefault(); $flash->setDI($di); $di->setShared('session', function () { $session = new \Anax\Session\CSession(); $session->configure(ANAX_APP_PATH . 'config/session.php'); $session->name(); return $session; }); $flash->info('info message'); $msg1 = $flash->printMessage(); $msg2 = "<div class='flash info'>info message</div>"; $this->assertEquals($msg1, $msg2, "Values doesn't match"); }