107 $used = [
'thumbsize',
'printable' ];
109 $classWrapper = TestingAccessWrapper::newFromClass( ParserOptions::class );
110 $classWrapper->getDefaults();
111 $allUsableOptions = array_diff(
112 array_keys( $classWrapper->inCacheKey ),
113 array_keys( $classWrapper->lazyOptions )
117 'Canonical options, nothing used' => [ [],
'canonical', [] ],
118 'Canonical options, used some options' => [ $used,
'canonical', [] ],
119 'Used some options, non-default values' => [
121 'printable=1!thumbsize=200',
127 'Canonical options, used all non-lazy options' => [ $allUsableOptions,
'canonical', [] ],
128 'Canonical options, nothing used, but with hooks and $wgRenderHashAppend' => [
130 'canonical!wgRenderHashAppend!onPageRenderingHash',
133 'wgRenderHashAppend' =>
'!wgRenderHashAppend',
134 'wgHooks' => [
'PageRenderingHash' => [ [ __CLASS__ .
'::onPageRenderingHash' ] ] ],
163 $classWrapper = TestingAccessWrapper::newFromClass( ParserOptions::class );
164 $oldDefaults = $classWrapper->defaults;
165 $oldLazy = $classWrapper->lazyOptions;
166 $reset =
new ScopedCallback(
function () use ( $classWrapper, $oldDefaults, $oldLazy ) {
167 $classWrapper->defaults = $oldDefaults;
168 $classWrapper->lazyOptions = $oldLazy;
171 $popt1 = ParserOptions::newCanonical();
172 $popt2 = ParserOptions::newCanonical();
173 $this->assertTrue( $popt1->matches( $popt2 ) );
175 $popt1->enableLimitReport(
true );
176 $popt2->enableLimitReport(
false );
177 $this->assertTrue( $popt1->matches( $popt2 ) );
179 $popt2->setTidy( !$popt2->getTidy() );
180 $this->assertFalse( $popt1->matches( $popt2 ) );
183 $classWrapper->defaults += [ __METHOD__ => null ];
184 $classWrapper->lazyOptions += [ __METHOD__ =>
function () use ( &$ctr ) {
187 $popt1 = ParserOptions::newCanonical();
188 $popt2 = ParserOptions::newCanonical();
189 $this->assertFalse( $popt1->matches( $popt2 ) );
191 ScopedCallback::consume( $reset );