Example #1
0
 /**
  * test isLocked() unary comparison operator under various situations
  * expect lock status remains synchronized with last call to unlock() or lock()
  * expect no exceptions
  */
 public function testIsLockedNamespace()
 {
     try {
         $s = new Zend_Session('somenamespace');
         $s->a = 'apple';
         $s->p = 'pear';
         $this->assertFalse($s->isLocked(), 'isLocked() returned incorrect status (locked)');
         $s->lock();
         $s2 = new Zend_Session('mayday');
         $s2->lock();
         $this->assertTrue($s->isLocked(), 'isLocked() returned incorrect status (unlocked)');
         $s->unlock();
         $s->o = 'orange';
         $s->p = 'prune';
         $this->assertFalse($s->isLocked(), 'isLocked() returned incorrect status (locked)');
         $s->lock();
         $s2->unlock();
         $this->assertTrue($s->isLocked(), 'isLocked() returned incorrect status (unlocked)');
         $s->unlock();
         $this->assertFalse($s->isLocked(), 'isLocked() returned incorrect status (locked)');
         $s->o = 'orange';
         $s->p = 'papaya';
         $s->c = 'cherry';
         $this->assertFalse($s->isLocked(), 'isLocked() returned incorrect status (locked)');
     } catch (Zend_Session_Exception $e) {
         $this->fail('Unexpected exception when writing to named namespaces after unlocking them.');
     }
 }