/**
  * popAtomic should not pop if the processor throws an error.
  */
 public function testPopAtomicRollback()
 {
     $data = array(mt_rand(), 'Abbie', 'Hoffman');
     $this->object->push($data);
     $self = $this;
     $callback = function ($message) use($self, $data) {
         $self->assertEquals($data, $message);
         throw new \Exception("Foiled!");
     };
     try {
         $this->assertEquals($data, $this->object->popAtomic($callback));
         $this->fail("Should have failed by this point");
     } catch (\Exception $ex) {
         $this->assertEquals("Foiled!", $ex->getMessage());
     }
     // Punchline: data should still be available for the retry pop.
     $this->assertEquals($data, $this->object->pop());
 }
Example #2
0
 public function testPopEmpty()
 {
     $this->assertNull($this->object->pop());
 }