| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Tests\Parser; |
| 4 |
|
| 5 |
use DummyContentForTesting; |
| 6 |
use InvalidArgumentException; |
| 7 |
use MediaWiki\Context\DerivativeContext; |
| 8 |
use MediaWiki\Context\IContextSource; |
| 9 |
use MediaWiki\Context\RequestContext; |
| 10 |
use MediaWiki\HookContainer\HookContainer; |
| 11 |
use MediaWiki\MainConfigNames; |
| 12 |
use MediaWiki\Parser\ParserOptions; |
| 13 |
use MediaWiki\Request\FauxRequest; |
| 14 |
use MediaWiki\Revision\SlotRecord; |
| 15 |
use MediaWiki\Tests\User\TempUser\TempUserTestTrait; |
| 16 |
use MediaWiki\Title\Title; |
| 17 |
use MediaWiki\User\User; |
| 18 |
use MediaWiki\User\UserIdentity; |
| 19 |
use MediaWiki\User\UserIdentityValue; |
| 20 |
use MediaWikiLangTestCase; |
| 21 |
use stdClass; |
| 22 |
use Wikimedia\ScopedCallback; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
class ParserOptionsTest extends MediaWikiLangTestCase { |
| 29 |
|
| 30 |
use TempUserTestTrait; |
| 31 |
|
| 32 |
protected function setUp(): void { |
| 33 |
parent::setUp(); |
| 34 |
|
| 35 |
$this->overrideConfigValues( [ |
| 36 |
MainConfigNames::RenderHashAppend => '', |
| 37 |
MainConfigNames::UsePigLatinVariant => false, |
| 38 |
] ); |
| 39 |
$this->setTemporaryHook( 'PageRenderingHash', HookContainer::NOOP ); |
| 40 |
} |
| 41 |
|
| 42 |
protected function tearDown(): void { |
| 43 |
ParserOptions::clearStaticCache(); |
| 44 |
parent::tearDown(); |
| 45 |
} |
| 46 |
|
| 47 |
public function testNewCanonical() { |
| 48 |
$user = $this->createMock( User::class ); |
| 49 |
$userLang = $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'fr' ); |
| 50 |
$contLang = $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'qqx' ); |
| 51 |
|
| 52 |
$this->setContentLang( $contLang ); |
| 53 |
$this->setUserLang( $userLang ); |
| 54 |
|
| 55 |
$lang = $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'de' ); |
| 56 |
$lang2 = $this->getServiceContainer()->getLanguageFactory()->getLanguage( 'bug' ); |
| 57 |
$context = new DerivativeContext( RequestContext::getMain() ); |
| 58 |
$context->setUser( $user ); |
| 59 |
$context->setLanguage( $lang ); |
| 60 |
|
| 61 |
|
| 62 |
$popt = ParserOptions::newCanonical( $user ); |
| 63 |
$this->assertSame( $user, $popt->getUserIdentity() ); |
| 64 |
$this->assertSame( $userLang, $popt->getUserLangObj() ); |
| 65 |
|
| 66 |
|
| 67 |
$popt = ParserOptions::newCanonical( $user, $lang ); |
| 68 |
$this->assertSame( $user, $popt->getUserIdentity() ); |
| 69 |
$this->assertSame( $lang, $popt->getUserLangObj() ); |
| 70 |
|
| 71 |
|
| 72 |
$popt = ParserOptions::newFromAnon(); |
| 73 |
$this->assertTrue( $popt->getUserIdentity()->isAnon() ); |
| 74 |
$this->assertSame( $contLang, $popt->getUserLangObj() ); |
| 75 |
$popt = ParserOptions::newCanonical( 'canonical', $lang2 ); |
| 76 |
$this->assertSame( $contLang, $popt->getUserLangObj() ); |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
$popt = ParserOptions::newCanonical( $context ); |
| 81 |
$this->assertSame( $user, $popt->getUserIdentity() ); |
| 82 |
$this->assertSame( $lang, $popt->getUserLangObj() ); |
| 83 |
$popt = ParserOptions::newCanonical( $context, $lang2 ); |
| 84 |
$this->assertSame( $lang, $popt->getUserLangObj() ); |
| 85 |
|
| 86 |
|
| 87 |
try { |
| 88 |
$popt = ParserOptions::newCanonical( 'bogus' ); |
| 89 |
$this->fail( 'Excpected exception not thrown' ); |
| 90 |
} catch ( InvalidArgumentException $ex ) { |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
private function commonTestNewFromContext( IContextSource $context, UserIdentity $expectedUser ) { |
| 95 |
$popt = ParserOptions::newFromContext( $context ); |
| 96 |
$this->assertTrue( $expectedUser->equals( $popt->getUserIdentity() ) ); |
| 97 |
$this->assertSame( $context->getLanguage(), $popt->getUserLangObj() ); |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
public function testNewFromContext( $contextUserIdentity, $contextLanguage ) { |
| 102 |
$this->enableAutoCreateTempUser(); |
| 103 |
|
| 104 |
$context = new DerivativeContext( RequestContext::getMain() ); |
| 105 |
$context->setUser( |
| 106 |
$this->getServiceContainer()->getUserFactory()->newFromUserIdentity( $contextUserIdentity ) |
| 107 |
); |
| 108 |
$context->setLanguage( $contextLanguage ); |
| 109 |
$this->commonTestNewFromContext( $context, $context->getUser() ); |
| 110 |
} |
| 111 |
|
| 112 |
public static function provideNewFromContext() { |
| 113 |
return [ |
| 114 |
'Username does not exist and user lang as en' => [ UserIdentityValue::newAnonymous( 'Testabc' ), 'en' ], |
| 115 |
'Username is IP address, no stashed temporary username, and user lang as qqx' => [ |
| 116 |
UserIdentityValue::newAnonymous( '1.2.3.4' ), 'qqx', |
| 117 |
], |
| 118 |
]; |
| 119 |
} |
| 120 |
|
| 121 |
public function testNewFromContextForNamedAccount() { |
| 122 |
$this->testNewFromContext( $this->getTestUser()->getUser(), 'qqx' ); |
| 123 |
} |
| 124 |
|
| 125 |
public function testNewFromContextForTemporaryAccount() { |
| 126 |
$this->testNewFromContext( |
| 127 |
$this->getServiceContainer()->getTempUserCreator() |
| 128 |
->create( null, new FauxRequest() )->getUser(), |
| 129 |
'de' |
| 130 |
); |
| 131 |
} |
| 132 |
|
| 133 |
public function testNewFromContextForAnonWhenTempNameStashed() { |
| 134 |
$this->enableAutoCreateTempUser(); |
| 135 |
|
| 136 |
$context = new DerivativeContext( RequestContext::getMain() ); |
| 137 |
$context->setUser( |
| 138 |
$this->getServiceContainer()->getUserFactory() |
| 139 |
->newFromUserIdentity( UserIdentityValue::newAnonymous( '1.2.3.4' ) ) |
| 140 |
); |
| 141 |
|
| 142 |
$stashedName = $this->getServiceContainer()->getTempUserCreator() |
| 143 |
->acquireAndStashName( $context->getRequest()->getSession() ); |
| 144 |
|
| 145 |
$this->commonTestNewFromContext( $context, UserIdentityValue::newAnonymous( $stashedName ) ); |
| 146 |
} |
| 147 |
|
| 148 |
public function testNewFromContextForAnonWhenTempNameStashedButFeatureSinceDisabled() { |
| 149 |
$this->enableAutoCreateTempUser(); |
| 150 |
|
| 151 |
$context = new DerivativeContext( RequestContext::getMain() ); |
| 152 |
$context->setUser( |
| 153 |
$this->getServiceContainer()->getUserFactory() |
| 154 |
->newFromUserIdentity( UserIdentityValue::newAnonymous( '1.2.3.4' ) ) |
| 155 |
); |
| 156 |
|
| 157 |
$this->getServiceContainer()->getTempUserCreator() |
| 158 |
->acquireAndStashName( $context->getRequest()->getSession() ); |
| 159 |
|
| 160 |
|
| 161 |
$this->disableAutoCreateTempUser( [ 'known' => true ] ); |
| 162 |
|
| 163 |
$this->commonTestNewFromContext( $context, UserIdentityValue::newAnonymous( '1.2.3.4' ) ); |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
public function testIsSafeToCache( bool $expect, array $options, ?array $usedOptions = null ) { |
| 173 |
$popt = ParserOptions::newFromAnon(); |
| 174 |
foreach ( $options as $name => $value ) { |
| 175 |
$popt->setOption( $name, $value ); |
| 176 |
} |
| 177 |
$this->assertSame( $expect, $popt->isSafeToCache( $usedOptions ) ); |
| 178 |
} |
| 179 |
|
| 180 |
public static function provideIsSafeToCache() { |
| 181 |
$seven = static function () { |
| 182 |
return 7; |
| 183 |
}; |
| 184 |
|
| 185 |
return [ |
| 186 |
'No overrides' => [ true, [] ], |
| 187 |
'No overrides, some used' => [ true, [], [ 'thumbsize', 'removeComments' ] ], |
| 188 |
'In-key options are ok' => [ true, [ |
| 189 |
'thumbsize' => 1e100, |
| 190 |
'printable' => false, |
| 191 |
] ], |
| 192 |
'In-key options are ok, some used' => [ true, [ |
| 193 |
'thumbsize' => 1e100, |
| 194 |
'printable' => false, |
| 195 |
], [ 'thumbsize', 'removeComments' ] ], |
| 196 |
'Non-in-key options are not ok' => [ false, [ |
| 197 |
'removeComments' => false, |
| 198 |
] ], |
| 199 |
'Non-in-key options are not ok, used' => [ false, [ |
| 200 |
'removeComments' => false, |
| 201 |
], [ 'removeComments' ] ], |
| 202 |
'Non-in-key options are ok if other used' => [ true, [ |
| 203 |
'removeComments' => false, |
| 204 |
], [ 'thumbsize' ] ], |
| 205 |
'Non-in-key options are ok if nothing used' => [ true, [ |
| 206 |
'removeComments' => false, |
| 207 |
], [] ], |
| 208 |
'Unknown used options do not crash' => [ true, [ |
| 209 |
], [ 'unknown' ] ], |
| 210 |
'Non-in-key options are not ok (2)' => [ false, [ |
| 211 |
'wrapclass' => 'foobar', |
| 212 |
] ], |
| 213 |
'Callback not default' => [ true, [ |
| 214 |
'speculativeRevIdCallback' => $seven, |
| 215 |
] ], |
| 216 |
]; |
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
public function testOptionsHash( |
| 228 |
$usedOptions, $expect, $options, $globals = [], $hookFunc = null |
| 229 |
) { |
| 230 |
$this->overrideConfigValues( $globals ); |
| 231 |
$this->setTemporaryHook( 'PageRenderingHash', $hookFunc ?: HookContainer::NOOP ); |
| 232 |
|
| 233 |
$popt = ParserOptions::newFromAnon(); |
| 234 |
foreach ( $options as $name => $value ) { |
| 235 |
$popt->setOption( $name, $value ); |
| 236 |
} |
| 237 |
$this->assertSame( $expect, $popt->optionsHash( $usedOptions ) ); |
| 238 |
} |
| 239 |
|
| 240 |
public static function provideOptionsHash() { |
| 241 |
$used = [ 'thumbsize', 'printable' ]; |
| 242 |
|
| 243 |
$allUsableOptions = array_diff( |
| 244 |
ParserOptions::allCacheVaryingOptions(), |
| 245 |
array_keys( ParserOptions::getLazyOptions() ) |
| 246 |
); |
| 247 |
|
| 248 |
return [ |
| 249 |
'Canonical options, nothing used' => [ [], 'canonical', [] ], |
| 250 |
'Canonical options, used some options' => [ $used, 'canonical', [] ], |
| 251 |
'Canonical options, used some more options' => [ array_merge( $used, [ 'wrapclass' ] ), 'canonical', [] ], |
| 252 |
'Used some options, non-default values' => [ |
| 253 |
$used, |
| 254 |
'printable=1!thumbsize=200', |
| 255 |
[ |
| 256 |
'thumbsize' => 200, |
| 257 |
'printable' => true, |
| 258 |
] |
| 259 |
], |
| 260 |
|
| 261 |
'Canonical options, used all non-lazy options' => [ $allUsableOptions, 'canonical', [] ], |
| 262 |
'Canonical options, nothing used, but with hooks and $wgRenderHashAppend' => [ |
| 263 |
[], |
| 264 |
'canonical!wgRenderHashAppend!onPageRenderingHash', |
| 265 |
[], |
| 266 |
[ MainConfigNames::RenderHashAppend => '!wgRenderHashAppend' ], |
| 267 |
__CLASS__ . '::onPageRenderingHash', |
| 268 |
], |
| 269 |
]; |
| 270 |
} |
| 271 |
|
| 272 |
public function testUsedLazyOptionsInHash() { |
| 273 |
$this->setTemporaryHook( 'ParserOptionsRegister', |
| 274 |
function ( &$defaults, &$inCacheKey, &$lazyOptions ) { |
| 275 |
$lazyFuncs = $this->getMockBuilder( stdClass::class ) |
| 276 |
->addMethods( [ 'neverCalled', 'calledOnce' ] ) |
| 277 |
->getMock(); |
| 278 |
$lazyFuncs->expects( $this->never() )->method( 'neverCalled' ); |
| 279 |
$lazyFuncs->expects( $this->once() )->method( 'calledOnce' )->willReturn( 'value' ); |
| 280 |
|
| 281 |
$defaults += [ |
| 282 |
'opt1' => null, |
| 283 |
'opt2' => null, |
| 284 |
'opt3' => null, |
| 285 |
]; |
| 286 |
$inCacheKey += [ |
| 287 |
'opt1' => true, |
| 288 |
'opt2' => true, |
| 289 |
]; |
| 290 |
$lazyOptions += [ |
| 291 |
'opt1' => [ $lazyFuncs, 'calledOnce' ], |
| 292 |
'opt2' => [ $lazyFuncs, 'neverCalled' ], |
| 293 |
'opt3' => [ $lazyFuncs, 'neverCalled' ], |
| 294 |
]; |
| 295 |
} |
| 296 |
); |
| 297 |
|
| 298 |
ParserOptions::clearStaticCache(); |
| 299 |
|
| 300 |
$popt = ParserOptions::newFromAnon(); |
| 301 |
$popt->registerWatcher( function () { |
| 302 |
$this->fail( 'Watcher should not have been called' ); |
| 303 |
} ); |
| 304 |
$this->assertSame( 'opt1=value', $popt->optionsHash( [ 'opt1', 'opt3' ] ) ); |
| 305 |
|
| 306 |
|
| 307 |
$this->assertSame( 'opt1=value', $popt->optionsHash( [ 'opt1', 'opt3' ] ) ); |
| 308 |
} |
| 309 |
|
| 310 |
public function testLazyOptionWithDefault() { |
| 311 |
$loaded = false; |
| 312 |
$this->setTemporaryHook( |
| 313 |
'ParserOptionsRegister', |
| 314 |
static function ( &$defaults, &$inCacheKey, &$lazyLoad ) use ( &$loaded ) { |
| 315 |
$defaults['test_option'] = 'default!'; |
| 316 |
$inCacheKey['test_option'] = true; |
| 317 |
$lazyLoad['test_option'] = static function () use ( &$loaded ) { |
| 318 |
$loaded = true; |
| 319 |
return 'default!'; |
| 320 |
}; |
| 321 |
} |
| 322 |
); |
| 323 |
|
| 324 |
$po = ParserOptions::newFromAnon(); |
| 325 |
$this->assertSame( 'default!', $po->getOption( 'test_option' ) ); |
| 326 |
$this->assertTrue( $loaded ); |
| 327 |
$this->assertSame( |
| 328 |
'canonical', |
| 329 |
$po->optionsHash( [ 'test_option' ], Title::makeTitle( NS_MAIN, 'Test' ) ) |
| 330 |
); |
| 331 |
} |
| 332 |
|
| 333 |
public static function onPageRenderingHash( &$confstr ) { |
| 334 |
$confstr .= '!onPageRenderingHash'; |
| 335 |
} |
| 336 |
|
| 337 |
public function testGetInvalidOption() { |
| 338 |
$popt = ParserOptions::newFromAnon(); |
| 339 |
$this->expectException( InvalidArgumentException::class ); |
| 340 |
$this->expectExceptionMessage( "Unknown parser option bogus" ); |
| 341 |
$popt->getOption( 'bogus' ); |
| 342 |
} |
| 343 |
|
| 344 |
public function testSetInvalidOption() { |
| 345 |
$popt = ParserOptions::newFromAnon(); |
| 346 |
$this->expectException( InvalidArgumentException::class ); |
| 347 |
$this->expectExceptionMessage( "Unknown parser option bogus" ); |
| 348 |
$popt->setOption( 'bogus', true ); |
| 349 |
} |
| 350 |
|
| 351 |
public function testMatches() { |
| 352 |
$popt1 = ParserOptions::newFromAnon(); |
| 353 |
$popt2 = ParserOptions::newFromAnon(); |
| 354 |
$this->assertTrue( $popt1->matches( $popt2 ) ); |
| 355 |
|
| 356 |
$popt2->setInterfaceMessage( !$popt2->getInterfaceMessage() ); |
| 357 |
$this->assertFalse( $popt1->matches( $popt2 ) ); |
| 358 |
|
| 359 |
$ctr = 0; |
| 360 |
$this->setTemporaryHook( 'ParserOptionsRegister', |
| 361 |
static function ( &$defaults, &$inCacheKey, &$lazyOptions ) use ( &$ctr ) { |
| 362 |
$defaults['testMatches'] = null; |
| 363 |
$lazyOptions['testMatches'] = static function () use ( &$ctr ) { |
| 364 |
return ++$ctr; |
| 365 |
}; |
| 366 |
} |
| 367 |
); |
| 368 |
ParserOptions::clearStaticCache(); |
| 369 |
|
| 370 |
$popt1 = ParserOptions::newFromAnon(); |
| 371 |
$popt2 = ParserOptions::newFromAnon(); |
| 372 |
$this->assertFalse( $popt1->matches( $popt2 ) ); |
| 373 |
|
| 374 |
ScopedCallback::consume( $reset ); |
| 375 |
} |
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
public function testTeardownClearedCache() { |
| 382 |
$popt1 = ParserOptions::newFromAnon(); |
| 383 |
$popt2 = ParserOptions::newFromAnon(); |
| 384 |
$this->assertTrue( $popt1->matches( $popt2 ) ); |
| 385 |
} |
| 386 |
|
| 387 |
public function testMatchesForCacheKey() { |
| 388 |
$user = new UserIdentityValue( 0, '127.0.0.1' ); |
| 389 |
$cOpts = ParserOptions::newCanonical( |
| 390 |
$user, |
| 391 |
$this->getServiceContainer()->getLanguageFactory()->getLanguage( 'en' ) |
| 392 |
); |
| 393 |
|
| 394 |
$uOpts = ParserOptions::newFromAnon(); |
| 395 |
$this->assertTrue( $cOpts->matchesForCacheKey( $uOpts ) ); |
| 396 |
|
| 397 |
$uOpts = ParserOptions::newFromUser( $user ); |
| 398 |
$this->assertTrue( $cOpts->matchesForCacheKey( $uOpts ) ); |
| 399 |
|
| 400 |
$this->getServiceContainer() |
| 401 |
->getUserOptionsManager() |
| 402 |
->setOption( $user, 'thumbsize', 251 ); |
| 403 |
$uOpts = ParserOptions::newFromUser( $user ); |
| 404 |
$this->assertFalse( $cOpts->matchesForCacheKey( $uOpts ) ); |
| 405 |
|
| 406 |
$this->getServiceContainer() |
| 407 |
->getUserOptionsManager() |
| 408 |
->setOption( $user, 'stubthreshold', 800 ); |
| 409 |
$uOpts = ParserOptions::newFromUser( $user ); |
| 410 |
$this->assertFalse( $cOpts->matchesForCacheKey( $uOpts ) ); |
| 411 |
|
| 412 |
$uOpts = ParserOptions::newFromUserAndLang( |
| 413 |
$user, |
| 414 |
$this->getServiceContainer()->getLanguageFactory()->getLanguage( 'zh' ) |
| 415 |
); |
| 416 |
$this->assertFalse( $cOpts->matchesForCacheKey( $uOpts ) ); |
| 417 |
} |
| 418 |
|
| 419 |
public function testAllCacheVaryingOptions() { |
| 420 |
$this->setTemporaryHook( 'ParserOptionsRegister', HookContainer::NOOP ); |
| 421 |
$this->assertSame( [ |
| 422 |
'collapsibleSections', |
| 423 |
'dateformat', 'printable', 'suppressSectionEditLinks', |
| 424 |
'thumbsize', 'useParsoid', 'userlang', |
| 425 |
], ParserOptions::allCacheVaryingOptions() ); |
| 426 |
|
| 427 |
ParserOptions::clearStaticCache(); |
| 428 |
|
| 429 |
$this->setTemporaryHook( 'ParserOptionsRegister', static function ( &$defaults, &$inCacheKey ) { |
| 430 |
$defaults += [ |
| 431 |
'foo' => 'foo', |
| 432 |
'bar' => 'bar', |
| 433 |
'baz' => 'baz', |
| 434 |
]; |
| 435 |
$inCacheKey += [ |
| 436 |
'foo' => true, |
| 437 |
'bar' => false, |
| 438 |
]; |
| 439 |
} ); |
| 440 |
$this->assertSame( [ |
| 441 |
'collapsibleSections', |
| 442 |
'dateformat', 'foo', 'printable', 'suppressSectionEditLinks', |
| 443 |
'thumbsize', 'useParsoid', 'userlang', |
| 444 |
], ParserOptions::allCacheVaryingOptions() ); |
| 445 |
} |
| 446 |
|
| 447 |
public function testGetSpeculativeRevid() { |
| 448 |
$options = ParserOptions::newFromAnon(); |
| 449 |
|
| 450 |
$this->assertFalse( $options->getSpeculativeRevId() ); |
| 451 |
|
| 452 |
$counter = 0; |
| 453 |
$options->setSpeculativeRevIdCallback( static function () use( &$counter ) { |
| 454 |
return ++$counter; |
| 455 |
} ); |
| 456 |
|
| 457 |
|
| 458 |
$this->assertSame( 1, $options->getSpeculativeRevId() ); |
| 459 |
$this->assertSame( 1, $options->getSpeculativeRevId() ); |
| 460 |
} |
| 461 |
|
| 462 |
public function testSetupFakeRevision() { |
| 463 |
$options = ParserOptions::newFromAnon(); |
| 464 |
|
| 465 |
$page = Title::newFromText( __METHOD__ ); |
| 466 |
$content = new DummyContentForTesting( '12345' ); |
| 467 |
$user = UserIdentityValue::newRegistered( 123, 'TestTest' ); |
| 468 |
$fakeRevisionScope = $options->setupFakeRevision( $page, $content, $user ); |
| 469 |
|
| 470 |
$fakeRevision = $options->getCurrentRevisionRecordCallback()( $page ); |
| 471 |
$this->assertNotNull( $fakeRevision ); |
| 472 |
$this->assertSame( '12345', $fakeRevision->getContent( SlotRecord::MAIN )->getNativeData() ); |
| 473 |
$this->assertSame( $user, $fakeRevision->getUser() ); |
| 474 |
$this->assertTrue( $fakeRevision->getPage()->exists() ); |
| 475 |
|
| 476 |
ScopedCallback::consume( $fakeRevisionScope ); |
| 477 |
$this->assertFalse( $options->getCurrentRevisionRecordCallback()( $page ) ); |
| 478 |
} |
| 479 |
|
| 480 |
public function testRenderReason() { |
| 481 |
$options = ParserOptions::newFromAnon(); |
| 482 |
|
| 483 |
$this->assertIsString( $options->getRenderReason() ); |
| 484 |
|
| 485 |
$options->setRenderReason( 'just a test' ); |
| 486 |
$this->assertIsString( 'just a test', $options->getRenderReason() ); |
| 487 |
} |
| 488 |
|
| 489 |
public function testSuppressSectionEditLinks() { |
| 490 |
$options = ParserOptions::newFromAnon(); |
| 491 |
|
| 492 |
$this->assertFalse( $options->getSuppressSectionEditLinks() ); |
| 493 |
|
| 494 |
$options->setSuppressSectionEditLinks(); |
| 495 |
$this->assertTrue( $options->getSuppressSectionEditLinks() ); |
| 496 |
} |
| 497 |
|
| 498 |
public function testCollapsibleSections() { |
| 499 |
$options = ParserOptions::newFromAnon(); |
| 500 |
|
| 501 |
$this->assertFalse( $options->getCollapsibleSections() ); |
| 502 |
|
| 503 |
$options->setCollapsibleSections(); |
| 504 |
$this->assertTrue( $options->getCollapsibleSections() ); |
| 505 |
} |
| 506 |
} |