Example #1
0
 /**
  * Test flash information iteration
  */
 public function testFlashIteration()
 {
     $f = new Slim_Session_Flash();
     $data = array('one' => 'This is one', 'two' => 'This is two', 'three' => 'This is three');
     $f->now('info', $data);
     if (isset($f['info'])) {
         foreach ($f['info'] as $key => $value) {
             $this->assertArrayHasKey($key, $data);
             $this->assertEquals($data[$key], $value);
         }
         unset($f['info']);
         $this->assertNull($f['info']);
     }
     $f['test'] = $data;
     $this->assertEquals($data, $f['test']);
 }
Example #2
0
 /**
  * Test Flash sets messages for current request
  *
  * Pre-conditions:
  * Messages are loaded from $_SESSION;
  * Message set using now();
  * Message set using set();
  *
  * Post-conditions:
  * Flash messages for current request are equal to those
  * pulled from $_SESSION and the one set using now(). The
  * message set using set() is ignored until next request.
  */
 public function testFlashSetsMessagesForNow()
 {
     $f1 = new Slim_Session_Flash();
     $f1->now('error', 'Error message');
     $f1->set('later', 'Message for next request');
     $msgs = $f1->getMessages();
     $this->assertEquals(2, count($msgs));
     $this->assertArrayHasKey('info', $msgs);
     //From $_SESSION
     $this->assertArrayHasKey('error', $msgs);
     //From now()
 }