Skip to content

Commit bb92121

Browse files
committed
Add EntityRedirect::__toString for easy debugging
1 parent d4fb1fe commit bb92121

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/Entity/EntityRedirect.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,13 @@ public function equals( $that ) {
7171
&& $this->targetId->equals( $that->targetId );
7272
}
7373

74+
/**
75+
* @since 4.4
76+
*
77+
* @return string
78+
*/
79+
public function __toString() {
80+
return $this->entityId . '->' . $this->targetId;
81+
}
82+
7483
}

tests/unit/Entity/EntityRedirectTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,9 @@ public function testEquals( $a, $b, $expected ) {
7777
}
7878
}
7979

80+
public function testToString() {
81+
$redirect = new EntityRedirect( new ItemId( 'Q1' ), new ItemId( 'Q2' ) );
82+
$this->assertSame( 'Q1->Q2', $redirect->__toString() );
83+
}
84+
8085
}

0 commit comments

Comments
 (0)