示例#1
0
 private function getDocument($path)
 {
     $reader = new StreamReader($path);
     $tokenizer = new RTFTokenizer($reader);
     $doc = new RTFDocument($tokenizer);
     $reader->close();
     return $doc;
 }
示例#2
0
 public function testReadToken()
 {
     $r = new StreamReader('tests/sample/hello-world.rtf');
     $tokenizer = new RTFTokenizer($r);
     $this->assertToken($tokenizer->readToken(), RTFToken::T_START_GROUP);
     $this->assertToken($tokenizer->readToken(), RTFToken::T_CONTROL_WORD, 'rtf', 1);
     $this->assertToken($tokenizer->readToken(), RTFToken::T_CONTROL_WORD, 'ansi');
     $this->assertToken($tokenizer->readToken(), RTFToken::T_CONTROL_WORD, 'ansicpg', 1252);
     $this->assertToken($tokenizer->readToken(), RTFToken::T_CONTROL_WORD, 'cocoartf', 1187);
     $this->assertToken($tokenizer->readToken(), RTFToken::T_CONTROL_WORD, 'cocoasubrtf', 370);
     $r->close();
 }
 public function testLookAhead()
 {
     $reader = new StreamReader('tests/sample/hello-world.txt');
     $this->assertEquals('S', $reader->lookAhead());
     $this->assertEquals('y', $reader->lookAhead(1));
     $this->assertEquals('S', $reader->readByte());
     $this->assertEquals('y', $reader->lookAhead());
     $this->assertEquals('y', $reader->lookAhead());
     $this->assertEquals('y', $reader->readByte());
     $this->assertEquals('n', $reader->lookAhead());
     $this->assertEquals(' ', $reader->lookAhead(2));
     $this->assertEquals('n', $reader->readByte());
     $reader->close();
 }