mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 14:36:51 +00:00
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
(cherry picked from commit fc5f22b32e
)
This commit is contained in:
parent
eedab71049
commit
08793295f8
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue