Merge "Rename appendText() to resolveFollow()"

This commit is contained in:
jenkins-bot 2024-01-04 15:29:44 +00:00 committed by Gerrit Code Review
commit ab20cb3cdf
2 changed files with 9 additions and 9 deletions

View file

@ -124,7 +124,7 @@ class ReferenceStack {
$argv ]; $argv ];
} elseif ( $text !== null ) { } elseif ( $text !== null ) {
// We know the parent already, so just perform the follow="…" and bail out // We know the parent already, so just perform the follow="…" and bail out
$this->appendText( $group, $follow, ' ' . $text ); $this->resolveFollow( $group, $follow, $text );
$this->refSequence--; $this->refSequence--;
} }
// A follow="…" never gets its own footnote marker // A follow="…" never gets its own footnote marker
@ -374,9 +374,9 @@ class ReferenceStack {
return $this->refs[$group] ?? []; return $this->refs[$group] ?? [];
} }
private function appendText( string $group, string $name, string $text ): void { private function resolveFollow( string $group, string $follow, string $text ): void {
$this->refs[$group][$name]['text'] ??= ''; $this->refs[$group][$follow]['text'] ??= '';
$this->refs[$group][$name]['text'] .= $text; $this->refs[$group][$follow]['text'] .= " $text";
} }
public function setText( string $group, string $name, string $text ): void { public function setText( string $group, string $name, string $text ): void {

View file

@ -1023,14 +1023,14 @@ class ReferenceStackTest extends \MediaWikiUnitTestCase {
$this->assertSame( [], $stack->getGroupRefs( 'empty' ) ); $this->assertSame( [], $stack->getGroupRefs( 'empty' ) );
} }
public function testAppendText() { public function testResolveFollow() {
$stack = $this->newStack(); $stack = $this->newStack();
$stack->appendText( 'group', 'name', 'set' ); $stack->resolveFollow( 'group', 'name', 'set' );
$this->assertSame( [ 'text' => 'set' ], $stack->refs['group']['name'] ); $this->assertSame( [ 'text' => ' set' ], $stack->refs['group']['name'] );
$stack->appendText( 'group', 'name', ' and append' ); $stack->resolveFollow( 'group', 'name', 'and append' );
$this->assertSame( [ 'text' => 'set and append' ], $stack->refs['group']['name'] ); $this->assertSame( [ 'text' => ' set and append' ], $stack->refs['group']['name'] );
} }
/** /**