| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\Context\RequestContext; |
| 4 |
use MediaWiki\Language\ILanguageConverter; |
| 5 |
use MediaWiki\Languages\LanguageConverterFactory; |
| 6 |
use MediaWiki\MainConfigNames; |
| 7 |
use MediaWiki\MediaWikiServices; |
| 8 |
use MediaWiki\Request\FauxRequest; |
| 9 |
use MediaWiki\Search\TitleMatcher; |
| 10 |
use MediaWiki\Specials\SpecialSearch; |
| 11 |
use MediaWiki\Title\Title; |
| 12 |
use MediaWiki\User\User; |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
o |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
class SpecialSearchTest extends MediaWikiIntegrationTestCase { |
| 22 |
|
| 23 |
private function newSpecialPage() { |
| 24 |
$services = $this->getServiceContainer(); |
| 25 |
return new SpecialSearch( |
| 26 |
$services->getSearchEngineConfig(), |
| 27 |
$services->getSearchEngineFactory(), |
| 28 |
$services->getNamespaceInfo(), |
| 29 |
$services->getContentHandlerFactory(), |
| 30 |
$services->getInterwikiLookup(), |
| 31 |
$services->getReadOnlyMode(), |
| 32 |
$services->getUserOptionsManager(), |
| 33 |
$services->getLanguageConverterFactory(), |
| 34 |
$services->getRepoGroup(), |
| 35 |
$services->getSearchResultThumbnailProvider(), |
| 36 |
$services->getTitleMatcher() |
| 37 |
); |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public function testAlternativeBackend() { |
| 44 |
$this->overrideConfigValue( MainConfigNames::SearchTypeAlternatives, [ 'MockSearchEngine' ] ); |
| 45 |
|
| 46 |
$ctx = new RequestContext(); |
| 47 |
$ctx->setRequest( new FauxRequest( [ |
| 48 |
'search' => 'foo', |
| 49 |
'srbackend' => 'MockSearchEngine', |
| 50 |
] ) ); |
| 51 |
$search = $this->newSpecialPage(); |
| 52 |
$search->setContext( $ctx ); |
| 53 |
|
| 54 |
$search->load(); |
| 55 |
|
| 56 |
|
| 57 |
$this->assertInstanceOf( MockSearchEngine::class, $search->getSearchEngine() ); |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
public function testValidateSortOrder() { |
| 65 |
$ctx = new RequestContext(); |
| 66 |
$ctx->setRequest( new FauxRequest( [ |
| 67 |
'search' => 'foo', |
| 68 |
'fulltext' => 1, |
| 69 |
'sort' => 'invalid', |
| 70 |
] ) ); |
| 71 |
$sp = Title::makeTitle( NS_SPECIAL, 'Search' ); |
| 72 |
$this->getServiceContainer() |
| 73 |
->getSpecialPageFactory() |
| 74 |
->executePath( $sp, $ctx ); |
| 75 |
$html = $ctx->getOutput()->getHTML(); |
| 76 |
$this->assertStringContainsString( 'cdx-message--warning', $html, 'must contain warnings' ); |
| 77 |
$this->assertMatchesRegularExpression( '/Sort order of invalid is unrecognized/', |
| 78 |
$html, 'must tell user sort order is invalid' ); |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
public function testProfileAndNamespaceLoading( $requested, $userOptions, |
| 93 |
$expectedProfile, $expectedNS, $message = 'Profile name and namespaces mismatches!' |
| 94 |
) { |
| 95 |
$context = new RequestContext; |
| 96 |
$context->setUser( |
| 97 |
$this->newUserWithSearchNS( $userOptions ) |
| 98 |
); |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
$context->setRequest( new FauxRequest( $requested ) ); |
| 106 |
$search = $this->newSpecialPage(); |
| 107 |
$search->setContext( $context ); |
| 108 |
$search->load(); |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
$this->assertEquals( |
| 116 |
[ |
| 117 |
'ProfileName' => $expectedProfile, |
| 118 |
'Namespaces' => $expectedNS, |
| 119 |
], |
| 120 |
[ |
| 121 |
'ProfileName' => $search->getProfile(), |
| 122 |
'Namespaces' => $search->getNamespaces(), |
| 123 |
], |
| 124 |
$message |
| 125 |
); |
| 126 |
} |
| 127 |
|
| 128 |
public static function provideSearchOptionsTests() { |
| 129 |
$defaultNS = MediaWikiServices::getInstance()->getSearchEngineConfig()->defaultNamespaces(); |
| 130 |
$EMPTY_REQUEST = []; |
| 131 |
$NO_USER_PREF = null; |
| 132 |
|
| 133 |
return [ |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
[ |
| 142 |
$EMPTY_REQUEST, $NO_USER_PREF, |
| 143 |
'default', $defaultNS, |
| 144 |
'T35270: No request nor user preferences should give default profile' |
| 145 |
], |
| 146 |
[ |
| 147 |
[ 'ns5' => 1 ], $NO_USER_PREF, |
| 148 |
'advanced', [ 5 ], |
| 149 |
'Web request with specific NS should override user preference' |
| 150 |
], |
| 151 |
[ |
| 152 |
$EMPTY_REQUEST, [ |
| 153 |
'searchNs2' => 1, |
| 154 |
'searchNs14' => 1, |
| 155 |
] + array_fill_keys( array_map( static function ( $ns ) { |
| 156 |
return "searchNs$ns"; |
| 157 |
}, $defaultNS ), 0 ), |
| 158 |
'advanced', [ 2, 14 ], |
| 159 |
'T35583: search with no option should honor User search preferences' |
| 160 |
. ' and have all other namespace disabled' |
| 161 |
], |
| 162 |
]; |
| 163 |
} |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
protected function newUserWithSearchNS( $opt = null ) { |
| 172 |
$u = User::newFromId( 0 ); |
| 173 |
if ( $opt === null ) { |
| 174 |
return $u; |
| 175 |
} |
| 176 |
$userOptionsManager = $this->getServiceContainer()->getUserOptionsManager(); |
| 177 |
foreach ( $opt as $name => $value ) { |
| 178 |
$userOptionsManager->setOption( $u, $name, $value ); |
| 179 |
} |
| 180 |
|
| 181 |
return $u; |
| 182 |
} |
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
public function testSearchTermIsNotExpanded() { |
| 190 |
|
| 191 |
$this->markTestSkippedIfDbType( 'sqlite' ); |
| 192 |
$this->overrideConfigValue( MainConfigNames::SearchType, null ); |
| 193 |
|
| 194 |
|
| 195 |
$ctx = new RequestContext(); |
| 196 |
$term = '{{SITENAME}}'; |
| 197 |
$ctx->setRequest( new FauxRequest( [ 'search' => $term, 'fulltext' => 1 ] ) ); |
| 198 |
$ctx->setTitle( Title::makeTitle( NS_SPECIAL, 'Search' ) ); |
| 199 |
$search = $this->newSpecialPage(); |
| 200 |
$search->setContext( $ctx ); |
| 201 |
|
| 202 |
|
| 203 |
$search->execute( '' ); |
| 204 |
|
| 205 |
|
| 206 |
$pageTitle = $search |
| 207 |
->getContext() |
| 208 |
->getOutput() |
| 209 |
->getHTMLTitle(); |
| 210 |
|
| 211 |
|
| 212 |
$this->assertMatchesRegularExpression( |
| 213 |
'/' . preg_quote( $term, '/' ) . '/', |
| 214 |
$pageTitle, |
| 215 |
"Search term '{$term}' should not be expanded in Special:Search <title>" |
| 216 |
); |
| 217 |
} |
| 218 |
|
| 219 |
public static function provideRewriteQueryWithSuggestion() { |
| 220 |
return [ |
| 221 |
[ |
| 222 |
'With suggestion and no rewritten query shows did you mean', |
| 223 |
'/Did you mean: <a[^>]+>first suggestion/', |
| 224 |
'first suggestion', |
| 225 |
null, |
| 226 |
[ Title::newMainPage() ] |
| 227 |
], |
| 228 |
|
| 229 |
[ |
| 230 |
'With rewritten query informs user of change', |
| 231 |
'/Showing results for <a[^>]+>first suggestion/', |
| 232 |
'asdf', |
| 233 |
'first suggestion', |
| 234 |
[ Title::newMainPage() ] |
| 235 |
], |
| 236 |
|
| 237 |
[ |
| 238 |
'When both queries have no results user gets no results', |
| 239 |
'/There were no results matching the query/', |
| 240 |
'first suggestion', |
| 241 |
'first suggestion', |
| 242 |
[] |
| 243 |
], |
| 244 |
|
| 245 |
[ |
| 246 |
'Prev/next links are using the rewritten query', |
| 247 |
'/search=rewritten\+query" rel="next" title="Next 20 results"/', |
| 248 |
'original query', |
| 249 |
'rewritten query', |
| 250 |
array_fill( 0, 100, Title::newMainPage() ) |
| 251 |
], |
| 252 |
|
| 253 |
[ |
| 254 |
'Show x results per page link uses the rewritten query', |
| 255 |
'/search=rewritten\+query" title="Show \d+ results/', |
| 256 |
'original query', |
| 257 |
'rewritten query', |
| 258 |
array_fill( 0, 100, Title::newMainPage() ) |
| 259 |
], |
| 260 |
]; |
| 261 |
} |
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
public function testRewriteQueryWithSuggestion( |
| 268 |
$message, |
| 269 |
$expectRegex, |
| 270 |
$suggestion, |
| 271 |
$rewrittenQuery, |
| 272 |
array $resultTitles |
| 273 |
) { |
| 274 |
$results = array_map( static function ( $title ) { |
| 275 |
return SearchResult::newFromTitle( $title ); |
| 276 |
}, $resultTitles ); |
| 277 |
|
| 278 |
$searchResults = new SpecialSearchTestMockResultSet( |
| 279 |
$suggestion, |
| 280 |
$rewrittenQuery, |
| 281 |
$results |
| 282 |
); |
| 283 |
|
| 284 |
$mockSearchEngine = $this->mockSearchEngine( $searchResults ); |
| 285 |
$services = $this->getServiceContainer(); |
| 286 |
$search = $this->getMockBuilder( SpecialSearch::class ) |
| 287 |
->setConstructorArgs( [ |
| 288 |
$services->getSearchEngineConfig(), |
| 289 |
$services->getSearchEngineFactory(), |
| 290 |
$services->getNamespaceInfo(), |
| 291 |
$services->getContentHandlerFactory(), |
| 292 |
$services->getInterwikiLookup(), |
| 293 |
$services->getReadOnlyMode(), |
| 294 |
$services->getUserOptionsManager(), |
| 295 |
$services->getLanguageConverterFactory(), |
| 296 |
$services->getRepoGroup(), |
| 297 |
$services->getSearchResultThumbnailProvider(), |
| 298 |
$services->getTitleMatcher() |
| 299 |
] ) |
| 300 |
->onlyMethods( [ 'getSearchEngine' ] ) |
| 301 |
->getMock(); |
| 302 |
$search->method( 'getSearchEngine' ) |
| 303 |
->willReturn( $mockSearchEngine ); |
| 304 |
|
| 305 |
$search->getContext()->setTitle( Title::makeTitle( NS_SPECIAL, 'Search' ) ); |
| 306 |
$search->getContext()->setLanguage( 'en' ); |
| 307 |
$search->load(); |
| 308 |
$search->showResults( 'this is a fake search' ); |
| 309 |
|
| 310 |
$html = $search->getContext()->getOutput()->getHTML(); |
| 311 |
foreach ( (array)$expectRegex as $regex ) { |
| 312 |
$this->assertMatchesRegularExpression( $regex, $html, $message ); |
| 313 |
} |
| 314 |
} |
| 315 |
|
| 316 |
public static function provideLimitPreference() { |
| 317 |
return [ |
| 318 |
[ 20, 20 ], |
| 319 |
[ 101, null ], |
| 320 |
]; |
| 321 |
} |
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
public function testLimitPreference( |
| 328 |
$optionValue, |
| 329 |
$expectedLimit |
| 330 |
) { |
| 331 |
$results = array_fill( 0, 100, SearchResult::newFromTitle( Title::newMainPage() ) ); |
| 332 |
|
| 333 |
$searchResults = new SpecialSearchTestMockResultSet( |
| 334 |
'?', |
| 335 |
'!', |
| 336 |
$results |
| 337 |
); |
| 338 |
|
| 339 |
$userOptionsManager = $this->getServiceContainer()->getUserOptionsManager(); |
| 340 |
|
| 341 |
$user = $this->getTestSysop()->getUser(); |
| 342 |
$userOptionsManager->setOption( $user, 'searchlimit', $optionValue ); |
| 343 |
$user->saveSettings(); |
| 344 |
|
| 345 |
$mockSearchEngine = $this->mockSearchEngine( $searchResults ); |
| 346 |
$services = $this->getServiceContainer(); |
| 347 |
$search = $this->getMockBuilder( SpecialSearch::class ) |
| 348 |
->setConstructorArgs( [ |
| 349 |
$services->getSearchEngineConfig(), |
| 350 |
$services->getSearchEngineFactory(), |
| 351 |
$services->getNamespaceInfo(), |
| 352 |
$services->getContentHandlerFactory(), |
| 353 |
$services->getInterwikiLookup(), |
| 354 |
$services->getReadOnlyMode(), |
| 355 |
$userOptionsManager, |
| 356 |
$services->getLanguageConverterFactory(), |
| 357 |
$services->getRepoGroup(), |
| 358 |
$services->getSearchResultThumbnailProvider(), |
| 359 |
$services->getTitleMatcher() |
| 360 |
] ) |
| 361 |
->onlyMethods( [ 'getSearchEngine' ] ) |
| 362 |
->getMock(); |
| 363 |
$search->method( 'getSearchEngine' ) |
| 364 |
->willReturn( $mockSearchEngine ); |
| 365 |
|
| 366 |
$search->getContext()->setTitle( Title::makeTitle( NS_SPECIAL, 'Search' ) ); |
| 367 |
$search->getContext()->setUser( $user ); |
| 368 |
$search->getContext()->setLanguage( 'en' ); |
| 369 |
$search->load(); |
| 370 |
$search->showResults( 'this is a fake search' ); |
| 371 |
|
| 372 |
$html = $search->getContext()->getOutput()->getHTML(); |
| 373 |
if ( $expectedLimit === null ) { |
| 374 |
$this->assertDoesNotMatchRegularExpression( "/ title=\"Next \\d+ results\"/", $html ); |
| 375 |
} else { |
| 376 |
$this->assertMatchesRegularExpression( "/ title=\"Next $expectedLimit results\"/", $html ); |
| 377 |
} |
| 378 |
} |
| 379 |
|
| 380 |
protected function mockSearchEngine( SpecialSearchTestMockResultSet $results ) { |
| 381 |
$mock = $this->getMockBuilder( SearchEngine::class ) |
| 382 |
->onlyMethods( [ 'searchText' ] ) |
| 383 |
->getMock(); |
| 384 |
|
| 385 |
$mock->method( 'searchText' ) |
| 386 |
->willReturn( $results ); |
| 387 |
|
| 388 |
$mock->setHookContainer( $this->getServiceContainer()->getHookContainer() ); |
| 389 |
|
| 390 |
return $mock; |
| 391 |
} |
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
public function testSubPageRedirect() { |
| 397 |
$this->overrideConfigValue( MainConfigNames::Script, '/w/index.php' ); |
| 398 |
|
| 399 |
$ctx = new RequestContext; |
| 400 |
$sp = Title::makeTitle( NS_SPECIAL, 'Search/foo_bar' ); |
| 401 |
$this->getServiceContainer()->getSpecialPageFactory()->executePath( $sp, $ctx ); |
| 402 |
$url = $ctx->getOutput()->getRedirect(); |
| 403 |
|
| 404 |
$parts = parse_url( $url ); |
| 405 |
$this->assertEquals( '/w/index.php', $parts['path'] ); |
| 406 |
parse_str( $parts['query'], $query ); |
| 407 |
$this->assertEquals( 'Special:Search', $query['title'] ); |
| 408 |
$this->assertEquals( 'foo bar', $query['search'] ); |
| 409 |
} |
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
public function testGoResult_userPrefRedirectOn() { |
| 418 |
$context = new RequestContext; |
| 419 |
$context->setUser( |
| 420 |
$this->newUserWithSearchNS( [ 'search-match-redirect' => false ] ) |
| 421 |
); |
| 422 |
$context->setRequest( |
| 423 |
new FauxRequest( [ 'search' => 'TEST_SEARCH_PARAM', 'fulltext' => 1 ] ) |
| 424 |
); |
| 425 |
$search = $this->newSpecialPage(); |
| 426 |
$search->setContext( $context ); |
| 427 |
$search->load(); |
| 428 |
|
| 429 |
$this->assertNull( $search->goResult( 'TEST_SEARCH_PARAM' ) ); |
| 430 |
} |
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
public function testGoResult_userPrefRedirectOff() { |
| 439 |
|
| 440 |
$searchResults = new SpecialSearchTestMockResultSet( |
| 441 |
'TEST_SEARCH_SUGGESTION', |
| 442 |
'', |
| 443 |
[ SearchResult::newFromTitle( Title::newMainPage() ) ] |
| 444 |
); |
| 445 |
|
| 446 |
$nearMatcherMock = $this->getMockBuilder( TitleMatcher::class ) |
| 447 |
->disableOriginalConstructor() |
| 448 |
->onlyMethods( [ 'getNearMatch' ] ) |
| 449 |
->getMock(); |
| 450 |
|
| 451 |
$nearMatcherMock->method( 'getNearMatch' ) |
| 452 |
->willReturn( $searchResults->getFirstResult() ); |
| 453 |
|
| 454 |
$mockSearchEngine = $this->mockSearchEngine( $searchResults ); |
| 455 |
$services = $this->getServiceContainer(); |
| 456 |
$search = $this->getMockBuilder( SpecialSearch::class ) |
| 457 |
->setConstructorArgs( [ |
| 458 |
$services->getSearchEngineConfig(), |
| 459 |
$services->getSearchEngineFactory(), |
| 460 |
$services->getNamespaceInfo(), |
| 461 |
$services->getContentHandlerFactory(), |
| 462 |
$services->getInterwikiLookup(), |
| 463 |
$services->getReadOnlyMode(), |
| 464 |
$services->getUserOptionsManager(), |
| 465 |
$services->getLanguageConverterFactory(), |
| 466 |
$services->getRepoGroup(), |
| 467 |
$services->getSearchResultThumbnailProvider(), |
| 468 |
$nearMatcherMock |
| 469 |
] ) |
| 470 |
->onlyMethods( [ 'getSearchEngine' ] ) |
| 471 |
->getMock(); |
| 472 |
$search->method( 'getSearchEngine' ) |
| 473 |
->willReturn( $mockSearchEngine ); |
| 474 |
|
| 475 |
|
| 476 |
$context = new RequestContext; |
| 477 |
$context->setUser( |
| 478 |
$this->newUserWithSearchNS( [ 'search-match-redirect' => true ] ) |
| 479 |
); |
| 480 |
$context->setRequest( |
| 481 |
new FauxRequest( [ 'search' => 'TEST_SEARCH_PARAM', 'fulltext' => 1 ] ) |
| 482 |
); |
| 483 |
$search->setContext( $context ); |
| 484 |
$search->load(); |
| 485 |
|
| 486 |
$this->assertNotNull( $search->goResult( 'TEST_SEARCH_PARAM' ) ); |
| 487 |
} |
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
public function test_create_link_not_shown_if_variant_link_is_known() { |
| 493 |
$searchTerm = "Test create link not shown if variant link is known"; |
| 494 |
$variantLink = "the replaced link variant text should not be visible"; |
| 495 |
|
| 496 |
$variantTitle = $this->createNoOpMock( Title::class, [ 'isKnown', 'getPrefixedText', |
| 497 |
'getDBkey', 'isExternal' ] ); |
| 498 |
|
| 499 |
$variantTitle->method( "isKnown" )->willReturn( true ); |
| 500 |
$variantTitle->method( "isExternal" )->willReturn( false ); |
| 501 |
$variantTitle->method( "getDBkey" )->willReturn( $searchTerm . " (variant)" ); |
| 502 |
$variantTitle->method( "getPrefixedText" )->willReturn( $searchTerm . " (variant)" ); |
| 503 |
|
| 504 |
$specialSearchFactory = function () use ( $variantTitle, $variantLink, $searchTerm ) { |
| 505 |
$languageConverter = $this->createMock( ILanguageConverter::class ); |
| 506 |
$languageConverter->method( 'hasVariants' )->willReturn( true ); |
| 507 |
$languageConverter->expects( $this->once() ) |
| 508 |
->method( 'findVariantLink' ) |
| 509 |
->willReturnCallback( |
| 510 |
static function ( &$link, &$nt, $unused = false ) use ( $searchTerm, $variantTitle, $variantLink ) { |
| 511 |
if ( $link === $searchTerm ) { |
| 512 |
$link = $variantLink; |
| 513 |
$nt = $variantTitle; |
| 514 |
} |
| 515 |
} |
| 516 |
); |
| 517 |
$languageConverterFactory = $this->createMock( LanguageConverterFactory::class ); |
| 518 |
$languageConverterFactory->method( 'getLanguageConverter' ) |
| 519 |
->willReturn( $languageConverter ); |
| 520 |
|
| 521 |
$mockSearchEngineFactory = $this->createMock( SearchEngineFactory::class ); |
| 522 |
$mockSearchEngineFactory->method( "create" ) |
| 523 |
->willReturn( $this->mockSearchEngine( new SpecialSearchTestMockResultSet() ) ); |
| 524 |
|
| 525 |
$services = $this->getServiceContainer(); |
| 526 |
$specialSearch = new SpecialSearch( |
| 527 |
$services->getSearchEngineConfig(), |
| 528 |
$mockSearchEngineFactory, |
| 529 |
$services->getNamespaceInfo(), |
| 530 |
$services->getContentHandlerFactory(), |
| 531 |
$services->getInterwikiLookup(), |
| 532 |
$services->getReadOnlyMode(), |
| 533 |
$services->getUserOptionsManager(), |
| 534 |
$languageConverterFactory, |
| 535 |
$services->getRepoGroup(), |
| 536 |
$services->getSearchResultThumbnailProvider(), |
| 537 |
$services->getTitleMatcher() |
| 538 |
); |
| 539 |
$context = new RequestContext(); |
| 540 |
$context->setRequest( new FauxRequest() ); |
| 541 |
$context->setTitle( Title::makeTitle( NS_SPECIAL, 'Search' ) ); |
| 542 |
$specialSearch->setContext( $context ); |
| 543 |
$specialSearch->load(); |
| 544 |
return $specialSearch; |
| 545 |
}; |
| 546 |
$specialSearch = $specialSearchFactory(); |
| 547 |
$specialSearch->showResults( $searchTerm ); |
| 548 |
$html = $specialSearch->getContext()->getOutput()->getHTML(); |
| 549 |
$this->assertStringNotContainsString( $variantLink, $html ); |
| 550 |
$this->assertStringContainsString( 'class="mw-search-exists"', $html ); |
| 551 |
$this->assertStringNotContainsString( 'class="mw-search-createlink"', $html ); |
| 552 |
|
| 553 |
$specialSearch = $specialSearchFactory(); |
| 554 |
$specialSearch->showResults( $searchTerm . "_search_create_link" ); |
| 555 |
$html = $specialSearch->getContext()->getOutput()->getHTML(); |
| 556 |
$this->assertStringContainsString( 'class="mw-search-createlink"', $html ); |
| 557 |
$this->assertStringNotContainsString( 'class="mw-search-exists"', $html ); |
| 558 |
} |
| 559 |
} |