CiteParserHooksTest: make test compatible with removal of dynamic property

Whether the dynamic property is present or not, it should have a null
value when 'unset' -- and don't use `unset` to delete an *actual*
property when one is present!

Change-Id: Ifcb9492cc5c814d702c6e61e8231abfd8ea0647c
This commit is contained in:
C. Scott Ananian 2024-04-12 13:49:44 -04:00
parent 8b21611cef
commit fc5f22b32e
2 changed files with 6 additions and 6 deletions

View file

@ -35,7 +35,7 @@ class CiteParserHooks implements
* @param Parser $parser
*/
public function onParserClearState( $parser ) {
unset( $parser->extCite );
$parser->extCite = null;
}
/**
@ -44,7 +44,7 @@ class CiteParserHooks implements
* @param Parser $parser
*/
public function onParserCloned( $parser ) {
unset( $parser->extCite );
$parser->extCite = null;
}
/**

View file

@ -30,23 +30,23 @@ class CiteParserHooksTest extends \MediaWikiUnitTestCase {
}
public function testOnParserClearState() {
$parser = $this->createNoOpMock( Parser::class );
$parser = $this->createNoOpMock( Parser::class, [ '__isset' ] );
$parser->extCite = $this->createMock( Cite::class );
$citeParserHooks = new CiteParserHooks();
$citeParserHooks->onParserClearState( $parser );
$this->assertObjectNotHasProperty( 'extCite', $parser );
$this->assertNull( $parser->extCite ?? null );
}
public function testOnParserCloned() {
$parser = $this->createNoOpMock( Parser::class );
$parser = $this->createNoOpMock( Parser::class, [ '__isset' ] );
$parser->extCite = $this->createMock( Cite::class );
$citeParserHooks = new CiteParserHooks();
$citeParserHooks->onParserCloned( $parser );
$this->assertObjectNotHasProperty( 'extCite', $parser );
$this->assertNull( $parser->extCite ?? null );
}
public function testAfterParseHooks() {