From 183851b06bd6c52f3cae5375f433da720d410447 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 11 Oct 2006 18:12:39 +0000 Subject: MediaWiki 1.7.1 wiederhergestellt --- tests/SearchEngineTest.php | 136 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 tests/SearchEngineTest.php (limited to 'tests/SearchEngineTest.php') diff --git a/tests/SearchEngineTest.php b/tests/SearchEngineTest.php new file mode 100644 index 00000000..20d8017e --- /dev/null +++ b/tests/SearchEngineTest.php @@ -0,0 +1,136 @@ +db->safeQuery( <<db->tableName( 'page' ) ); + $this->db->safeQuery( <<db->tableName( 'revision' ) ); + $this->db->safeQuery( <<db->tableName( 'text' ) ); + $this->db->safeQuery( <<db->tableName( 'searchindex' ) ); + } + + function fetchIds( &$results ) { + $matches = array(); + while( $row = $results->fetchObject() ) { + $matches[] = intval( $row->page_id ); + } + $results->free(); + # Search is not guaranteed to return results in a certain order; + # sort them numerically so we will compare simply that we received + # the expected matches. + sort( $matches ); + return $matches; + } + + function testTextSearch() { + $this->assertFalse( is_null( $this->db ), "Can't find a database to test with." ); + if( !is_null( $this->db ) ) { + $this->assertEquals( + array( 3 ), + $this->fetchIds( $this->search->searchText( 'smithee' ) ), + "Plain search failed" ); + } + } + + function testTextPowerSearch() { + $this->assertFalse( is_null( $this->db ), "Can't find a database to test with." ); + if( !is_null( $this->db ) ) { + $this->search->setNamespaces( array( 0, 1, 4 ) ); + $this->assertEquals( + array( 2, 3 ), + $this->fetchIds( $this->search->searchText( 'smithee' ) ), + "Power search failed" ); + } + } + + function testTitleSearch() { + $this->assertFalse( is_null( $this->db ), "Can't find a database to test with." ); + if( !is_null( $this->db ) ) { + $this->assertEquals( + array( 3, 9 ), + $this->fetchIds( $this->search->searchTitle( 'smithee' ) ), + "Title search failed" ); + } + } + + function testTextTitlePowerSearch() { + $this->assertFalse( is_null( $this->db ), "Can't find a database to test with." ); + if( !is_null( $this->db ) ) { + $this->search->setNamespaces( array( 0, 1, 4 ) ); + $this->assertEquals( + array( 3, 4, 9 ), + $this->fetchIds( $this->search->searchTitle( 'smithee' ) ), + "Title power search failed" ); + } + } + +} + + +?> -- cgit v1.2.2