示例#1
0
 /**
  * Tests the gotoNextByType method
  */
 public function testGotoPreviousByType()
 {
     $pos = 20;
     $this->object->seek($pos);
     $token = $this->object->gotoPreviousByType(T_CLASS, 0);
     $this->assertInstanceOf('DocBlox_Token', $token, 'Expected to find a T_CLASS in the dataset');
     $this->assertNotEquals($pos, $this->object->key(), 'Expected the key to have a different position');
     $this->object->seek($pos);
     $token = $this->object->gotoPreviousByType(T_CLASS, $pos);
     $this->assertInstanceOf('DocBlox_Token', $token, 'Expected to find a T_CLASS in the dataset within ' . $pos . ' tokens');
     $this->assertNotEquals($pos, $this->object->key(), 'Expected the key to have a different position');
     $this->object->seek($pos);
     $token = $this->object->gotoPreviousByType(T_CLASS, $pos, T_NAMESPACE);
     $this->assertInstanceOf('DocBlox_Token', $token, 'Expected to find a T_CLASS in the dataset within ' . $pos . ' tokens before a T_NAMESPACE is encountered');
     $this->assertNotEquals($pos, $this->object->key(), 'Expected the key to have a different position');
     $this->object->seek($pos);
     $token = $this->object->gotoPreviousByType(T_CLASS, $pos, T_FUNCTION);
     $this->assertFalse($token, 'Expected to fail finding a T_CLASS in the dataset within ' . $pos . ' tokens before a T_FUNCTION is encountered');
     $this->assertEquals($pos, $this->object->key(), 'Expected the key to be at the starting position');
 }