mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-27 16:30:12 +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
This commit is contained in:
parent
8b21611cef
commit
fc5f22b32e
|
@ -35,7 +35,7 @@ class CiteParserHooks implements
|
||||||
* @param Parser $parser
|
* @param Parser $parser
|
||||||
*/
|
*/
|
||||||
public function onParserClearState( $parser ) {
|
public function onParserClearState( $parser ) {
|
||||||
unset( $parser->extCite );
|
$parser->extCite = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +44,7 @@ class CiteParserHooks implements
|
||||||
* @param Parser $parser
|
* @param Parser $parser
|
||||||
*/
|
*/
|
||||||
public function onParserCloned( $parser ) {
|
public function onParserCloned( $parser ) {
|
||||||
unset( $parser->extCite );
|
$parser->extCite = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,23 +30,23 @@ class CiteParserHooksTest extends \MediaWikiUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOnParserClearState() {
|
public function testOnParserClearState() {
|
||||||
$parser = $this->createNoOpMock( Parser::class );
|
$parser = $this->createNoOpMock( Parser::class, [ '__isset' ] );
|
||||||
$parser->extCite = $this->createMock( Cite::class );
|
$parser->extCite = $this->createMock( Cite::class );
|
||||||
|
|
||||||
$citeParserHooks = new CiteParserHooks();
|
$citeParserHooks = new CiteParserHooks();
|
||||||
$citeParserHooks->onParserClearState( $parser );
|
$citeParserHooks->onParserClearState( $parser );
|
||||||
|
|
||||||
$this->assertObjectNotHasProperty( 'extCite', $parser );
|
$this->assertNull( $parser->extCite ?? null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOnParserCloned() {
|
public function testOnParserCloned() {
|
||||||
$parser = $this->createNoOpMock( Parser::class );
|
$parser = $this->createNoOpMock( Parser::class, [ '__isset' ] );
|
||||||
$parser->extCite = $this->createMock( Cite::class );
|
$parser->extCite = $this->createMock( Cite::class );
|
||||||
|
|
||||||
$citeParserHooks = new CiteParserHooks();
|
$citeParserHooks = new CiteParserHooks();
|
||||||
$citeParserHooks->onParserCloned( $parser );
|
$citeParserHooks->onParserCloned( $parser );
|
||||||
|
|
||||||
$this->assertObjectNotHasProperty( 'extCite', $parser );
|
$this->assertNull( $parser->extCite ?? null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAfterParseHooks() {
|
public function testAfterParseHooks() {
|
||||||
|
|
Loading…
Reference in a new issue