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->next() ) { $matches[] = $row->getTitle()->getPrefixedText(); } $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( 'Smithee' ), $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( 'Smithee', 'Talk:Main Page', ), $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( 'Alan Smithee', 'Smithee', ), $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( 'Alan Smithee', 'Smithee', 'Talk:Smithee', ), $this->fetchIds( $this->search->searchTitle( 'smithee' ) ), "Title power search failed" ); } } }