From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 17 Dec 2015 09:15:42 +0100 Subject: Update to MediaWiki 1.26.0 --- .../test/lib/Elastica/Test/Query/CommonTest.php | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php') diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php new file mode 100644 index 00000000..016213a8 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php @@ -0,0 +1,63 @@ +setLowFrequencyOperator(Common::OPERATOR_AND); + + $expected = array( + 'common' => array( + 'body' => array( + 'query' => 'test query', + 'cutoff_frequency' => .001, + 'low_freq_operator' => 'and', + ), + ), + ); + + $this->assertEquals($expected, $query->toArray()); + } + + /** + * @group functional + */ + public function testQuery() + { + $index = $this->_createIndex(); + $type = $index->getType('test'); + + $docs = array( + new Document(1, array('body' => 'foo baz')), + new Document(2, array('body' => 'foo bar baz')), + new Document(3, array('body' => 'foo bar baz bat')), + ); + //add documents to create common terms + for ($i = 4; $i < 24; $i++) { + $docs[] = new Document($i, array('body' => 'foo bar')); + } + $type->addDocuments($docs); + $index->refresh(); + + $query = new Common('body', 'foo bar baz bat', .5); + $results = $type->search($query)->getResults(); + + //documents containing only common words should not be returned + $this->assertEquals(3, sizeof($results)); + + $query->setMinimumShouldMatch(2); + $results = $type->search($query); + + //only the document containing both low frequency terms should match + $this->assertEquals(1, $results->count()); + } +} -- cgit v1.2.3-54-g00ecf