Example #1
0
 function testIndexThreeSameWordDocumentCheckMockAsserts()
 {
     $index = new Mockiindex();
     $documentstore = new Mockidocumentstore();
     $documentstore->expectOnce('storeDocument', array(array('test test test')));
     $documentstore->returns('storeDocument', 1);
     $index->expectOnce('storeDocuments', array('test', array(array(1, 3, 0))));
     $this->indexer = new naieveindexer($index, $documentstore);
     $ret = $this->indexer->index(array('test test test'));
     $this->assertTrue($ret);
 }
Example #2
0
 function testDoSearchIndexDocument1000DocumentsExistExpect1000()
 {
     $index = new Mockiindex();
     $documentstore = new Mockidocumentstore();
     $doclist = array();
     $expected = array();
     for ($i = 0; $i < 1000; $i++) {
         $doclist[] = array($i, 0, 0);
         $documentstore->expectAt($i, 'getDocument', array($i));
         $documentstore->returnsAt($i, 'getDocument', array('this is the document with id ' . $i));
         $expected[] = array('this is the document with id ' . $i);
     }
     $index->expectOnce('getDocuments', array('test'));
     $index->returns('getDocuments', $doclist);
     $this->search = new naievesearch($index, $documentstore);
     $ret = $this->search->dosearch('test');
     $this->assertEqual($expected, $ret);
 }