+ public function testUsedLazyOptionsInHash() {
+ $this->setTemporaryHook( 'ParserOptionsRegister',
+ function ( &$defaults, &$inCacheKey, &$lazyOptions ) {
+ $lazyFuncs = $this->getMockBuilder( stdClass::class )
+ ->setMethods( [ 'neverCalled', 'calledOnce' ] )
+ ->getMock();
+ $lazyFuncs->expects( $this->never() )->method( 'neverCalled' );
+ $lazyFuncs->expects( $this->once() )->method( 'calledOnce' )->willReturn( 'value' );
+
+ $defaults += [
+ 'opt1' => null,
+ 'opt2' => null,
+ 'opt3' => null,
+ ];
+ $inCacheKey += [
+ 'opt1' => true,
+ 'opt2' => true,
+ ];
+ $lazyOptions += [
+ 'opt1' => [ $lazyFuncs, 'calledOnce' ],
+ 'opt2' => [ $lazyFuncs, 'neverCalled' ],
+ 'opt3' => [ $lazyFuncs, 'neverCalled' ],
+ ];
+ }
+ );
+
+ self::clearCache();
+
+ $popt = ParserOptions::newCanonical();
+ $popt->registerWatcher( function () {
+ $this->fail( 'Watcher should not have been called' );
+ } );
+ $this->assertSame( 'opt1=value', $popt->optionsHash( [ 'opt1', 'opt3' ] ) );
+
+ // Second call to see that opt1 isn't resolved a second time
+ $this->assertSame( 'opt1=value', $popt->optionsHash( [ 'opt1', 'opt3' ] ) );
+ }
+