Exemplo n.º 1
0
 /**
  * Test middleware call
  */
 public function testFlashAsMiddleware()
 {
     $env = array();
     $app = new CustomAppFlash();
     //<-- See class definition at top of file
     $f = new Slim_Middleware_Flash($app);
     $this->assertFalse(isset($_SESSION['slim.flash']));
     list($status, $header, $body) = $f->call($env);
     $this->assertEquals('Foo', $_SESSION['slim.flash']['info']);
 }
Exemplo n.º 2
0
 /**
  * Test set Flash using array access
  */
 public function testFlashArrayAccess()
 {
     $_SESSION['slim.flash'] = array('info' => 'foo');
     $f = new Slim_Middleware_Flash();
     $f['info'] = 'bar';
     $f->save();
     $this->assertTrue(isset($f['info']));
     $this->assertEquals('bar', $f['info']);
     unset($f['info']);
     $this->assertFalse(isset($f['info']));
 }
Exemplo n.º 3
0
 /**
  * Test iteration
  */
 public function testIteration()
 {
     $_SESSION['slim.flash'] = array('info' => 'foo', 'error' => 'bar');
     $f = new Slim_Middleware_Flash();
     $f->loadMessages();
     $output = '';
     foreach ($f as $key => $value) {
         $output .= $key . $value;
     }
     $this->assertEquals('infofooerrorbar', $output);
 }