コード例 #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);
 }
コード例 #2
0
 function testDoSearchTwoTermsIndexDocumentSingleDocumentThatExistsReturnsDocument()
 {
     $index = new Mockiindex();
     $documentstore = new Mockidocumentstore();
     $index->expectAt(0, 'getDocuments', array('test'));
     $index->expectAt(1, 'getDocuments', array('test2'));
     $index->returnsAt(0, 'getDocuments', array(array(1, 0, 0)));
     $index->returnsAt(1, 'getDocuments', array());
     $documentstore->expectOnce('getDocument', array(1));
     $documentstore->returns('getDocument', array('this is the document with id 1'));
     $this->search = new naievesearch($index, $documentstore);
     $ret = $this->search->dosearch('test test2');
     $this->assertEqual(array(array('this is the document with id 1')), $ret);
 }