Пример #1
0
    public function testTermStreamStyleReadingSkipTo()
    {
        $directory = new Directory\Filesystem(__DIR__ . '/_source/_files');

        $segmentInfo = new Index\SegmentInfo($directory, '_3', 2);

        $this->assertEquals($segmentInfo->resetTermsStream(6, Index\SegmentInfo::SM_FULL_INFO), 8);

        $segmentInfo->skipTo(new Index\Term('prefetch', 'contents'));

        $terms = array();

        $terms[] = $segmentInfo->currentTerm();
        $firstTermPositions = $segmentInfo->currentTermPositions();

        $this->assertEquals(count($firstTermPositions), 1);

        reset($firstTermPositions); // go to the first element
        $this->assertEquals(key($firstTermPositions), 7);
        $this->assertTrue(current($firstTermPositions) == array(112, 409));

        while (($term = $segmentInfo->nextTerm()) != null) {
            $terms[] = $term;
        }

        $this->assertTrue($terms ==
                          array(new Index\Term('prev', 'contents'),
                                new Index\Term('previous', 'contents'),
                                new Index\Term('proper', 'contents'),
                                new Index\Term('quote', 'contents'),
                                new Index\Term('read', 'contents'),
                                new Index\Term('rel', 'contents'),
                                new Index\Term('report', 'contents'),
                                new Index\Term('reported', 'contents'),
                                new Index\Term('reporting', 'contents'),
                                new Index\Term('requirements', 'contents'),
                                new Index\Term('right', 'contents'),
                                new Index\Term('sect', 'contents'),
                                new Index\Term('span', 'contents'),
                                new Index\Term('still', 'contents'),
                                new Index\Term('stylesheet', 'contents'),
                                new Index\Term('submitting', 'contents'),
                                new Index\Term('summary', 'contents'),
                                new Index\Term('system', 'contents'),
                                new Index\Term('t', 'contents'),
                                new Index\Term('table', 'contents'),
                                new Index\Term('take', 'contents'),
                                new Index\Term('target', 'contents'),
                                new Index\Term('td', 'contents'),
                                new Index\Term('text', 'contents'),
                                new Index\Term('th', 'contents'),
                                new Index\Term('that', 'contents'),
                                new Index\Term('the', 'contents'),
                                new Index\Term('think', 'contents'),
                                new Index\Term('this', 'contents'),
                                new Index\Term('tips', 'contents'),
                                new Index\Term('title', 'contents'),
                                new Index\Term('to', 'contents'),
                                new Index\Term('top', 'contents'),
                                new Index\Term('tr', 'contents'),
                                new Index\Term('translating', 'contents'),
                                new Index\Term('type', 'contents'),
                                new Index\Term('u', 'contents'),
                                new Index\Term('unable', 'contents'),
                                new Index\Term('up', 'contents'),
                                new Index\Term('using', 'contents'),
                                new Index\Term('valign', 'contents'),
                                new Index\Term('version', 'contents'),
                                new Index\Term('vlink', 'contents'),
                                new Index\Term('way', 'contents'),
                                new Index\Term('which', 'contents'),
                                new Index\Term('width', 'contents'),
                                new Index\Term('will', 'contents'),
                                new Index\Term('with', 'contents'),
                                new Index\Term('writing', 'contents'),
                                new Index\Term('you', 'contents'),
                                new Index\Term('your', 'contents'),
                                new Index\Term('1178009946', 'modified'),
                                new Index\Term('bugs', 'path'),
                                new Index\Term('contributing', 'path'),
                                new Index\Term('html', 'path'),
                                new Index\Term('indexsource', 'path'),
                                new Index\Term('newpackage', 'path'),
                               ));

        unset($segmentInfo);


        $segmentInfo1 = new Index\SegmentInfo($directory, '_3', 2);
        $this->assertEquals($segmentInfo1->resetTermsStream(6, Index\SegmentInfo::SM_MERGE_INFO), 7);
    }