Example #1
0
 function testIndexThreeWordsTwoSameCheckAssets()
 {
     $index = new Mockiindex();
     $documentstore = new Mockidocumentstore();
     $documentstore->expectOnce('storeDocument', array(array('test test2 test2')));
     $documentstore->returns('storeDocument', 1);
     $index->expectAt(0, 'storeDocuments', array('test', array(array(1, 1, 0))));
     $index->expectAt(1, 'storeDocuments', array('test2', array(array(1, 2, 0))));
     $this->indexer = new naieveindexer($index, $documentstore);
     $ret = $this->indexer->index(array('test test2 test2'));
     $this->assertTrue($ret);
 }
Example #2
0
 function testDoSearchThreeTermsIndexDocumentThreeDocumentThatExistsReturnsThreeDocument()
 {
     $index = new Mockiindex();
     $documentstore = new Mockidocumentstore();
     $index->expectAt(0, 'getDocuments', array('test'));
     $index->expectAt(1, 'getDocuments', array('test2'));
     $index->expectAt(2, 'getDocuments', array('test3'));
     $index->returnsAt(0, 'getDocuments', array(array(1, 0, 0)));
     $index->returnsAt(1, 'getDocuments', array(array(2, 0, 0)));
     $index->returnsAt(2, 'getDocuments', array(array(3, 0, 0)));
     $documentstore->expectAt(0, 'getDocument', array(1));
     $documentstore->expectAt(1, 'getDocument', array(2));
     $documentstore->expectAt(2, 'getDocument', array(3));
     $documentstore->returnsAt(0, 'getDocument', array('this is the document with id 1'));
     $documentstore->returnsAt(1, 'getDocument', array('this is the document with id 2'));
     $documentstore->returnsAt(2, 'getDocument', array('this is the document with id 3'));
     $this->search = new naievesearch($index, $documentstore);
     $ret = $this->search->dosearch('test test2 test3');
     $this->assertEqual(array(array('this is the document with id 1'), array('this is the document with id 2'), array('this is the document with id 3')), $ret);
 }