expectedResourceLoaderWanKeyTouches = ( $this->expectedResourceLoaderWanKeyTouches ?? 0 ) + $wanKeyTouches; // Make sure ResourceLoaderEventIngress is triggered and updates the message $wanObjectCache = $this->getMockBuilder( WANObjectCache::class ) ->setConstructorArgs( [ [ 'cache' => new EmptyBagOStuff() ] ] ) ->onlyMethods( [ 'touchCheckKey' ] ) ->getMock(); // this is the relevant assertion: $wanObjectCache->method( 'touchCheckKey' )->willReturnCallback( function ( $key ) { if ( preg_match( '/\bresourceloader-titleinfo\b/', $key ) ) { $this->actualResourceLoaderWanKeyTouches++; } } ); $this->setService( 'MainWANObjectCache', $wanObjectCache ); } /** * @postCondition */ public function wanKeyTouchCountPostConditions() { if ( $this->expectedResourceLoaderWanKeyTouches !== null ) { $this->assertSame( $this->expectedResourceLoaderWanKeyTouches, $this->actualResourceLoaderWanKeyTouches, 'Expected number of ReasourceLoader module cache resets' ); } } }