jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/401934 )
Change subject: Accept path array to prepend to statement diff
......................................................................
Accept path array to prepend to statement diff
Bug: T182424
Change-Id: Ia4bebd82b013eaddca6cb9b988caf7328e260a1a
---
M repo/includes/Diff/ClaimDifferenceVisualizer.php
M repo/includes/Diff/DifferencesSnakVisualizer.php
M repo/tests/phpunit/includes/Diff/ClaimDifferenceVisualizerTest.php
M repo/tests/phpunit/includes/Diff/DifferencesSnakVisualizerTest.php
4 files changed, 152 insertions(+), 64 deletions(-)
Approvals:
WMDE-leszek: Looks good to me, approved
jenkins-bot: Verified
Thiemo Kreuz (WMDE): Looks good to me, but someone else must approve
diff --git a/repo/includes/Diff/ClaimDifferenceVisualizer.php
b/repo/includes/Diff/ClaimDifferenceVisualizer.php
index bafc1ab..d75f9a6 100644
--- a/repo/includes/Diff/ClaimDifferenceVisualizer.php
+++ b/repo/includes/Diff/ClaimDifferenceVisualizer.php
@@ -46,10 +46,15 @@
*
* @param ClaimDifference $claimDifference
* @param Statement $baseStatement The new statement, if it exists.
Otherwise the old statement.
+ * @param string[] $path The path to prepend in the header
*
* @return string HTML
*/
- public function visualizeClaimChange( ClaimDifference $claimDifference,
Statement $baseStatement ) {
+ public function visualizeClaimChange(
+ ClaimDifference $claimDifference,
+ Statement $baseStatement,
+ array $path = []
+ ) {
$newestMainSnak = $baseStatement->getMainSnak();
$oldestMainSnak = $newestMainSnak;
$html = '';
@@ -57,7 +62,12 @@
$mainSnakChange = $claimDifference->getMainSnakChange();
if ( $mainSnakChange !== null ) {
$oldestMainSnak = $mainSnakChange->getOldValue() ?:
$newestMainSnak;
- $html .= $this->visualizeMainSnakChange(
$mainSnakChange, $oldestMainSnak, $newestMainSnak );
+ $html .= $this->visualizeMainSnakChange(
+ $mainSnakChange,
+ $oldestMainSnak,
+ $newestMainSnak,
+ $path
+ );
}
$rankChange = $claimDifference->getRankChange();
@@ -65,7 +75,8 @@
$html .= $this->visualizeRankChange(
$rankChange,
$oldestMainSnak,
- $newestMainSnak
+ $newestMainSnak,
+ $path
);
}
@@ -74,7 +85,8 @@
$html .= $this->visualizeQualifierChanges(
$qualifierChanges,
$oldestMainSnak,
- $newestMainSnak
+ $newestMainSnak,
+ $path
);
}
@@ -83,7 +95,8 @@
$html .= $this->visualizeReferenceChanges(
$referenceChanges,
$oldestMainSnak,
- $newestMainSnak
+ $newestMainSnak,
+ $path
);
}
@@ -94,43 +107,47 @@
* Get diff html for a new claim
*
* @param Statement $statement
+ * @param string[] $path The path to prepend in the header
*
* @return string HTML
*/
- public function visualizeNewClaim( Statement $statement ) {
+ public function visualizeNewClaim( Statement $statement, array $path =
[] ) {
$claimDiffer = new ClaimDiffer( new ListDiffer() );
$claimDifference = $claimDiffer->diffClaims( null, $statement );
- return $this->visualizeClaimChange( $claimDifference,
$statement );
+ return $this->visualizeClaimChange( $claimDifference,
$statement, $path );
}
/**
* Get diff html for a removed claim
*
* @param Statement $statement
+ * @param string[] $path The path to prepend in the header
*
* @return string HTML
*/
- public function visualizeRemovedClaim( Statement $statement ) {
+ public function visualizeRemovedClaim( Statement $statement, array
$path = [] ) {
$claimDiffer = new ClaimDiffer( new ListDiffer() );
$claimDifference = $claimDiffer->diffClaims( $statement, null );
- return $this->visualizeClaimChange( $claimDifference,
$statement );
+ return $this->visualizeClaimChange( $claimDifference,
$statement, $path );
}
/**
* @param DiffOpChange $mainSnakChange
* @param Snak $oldestMainSnak The old main snak, if present;
otherwise, the new main snak
* @param Snak $newestMainSnak The new main snak, if present;
otherwise, the old main snak
+ * @param string[] $path The path to prepend in the header
*
* @return string HTML
*/
private function visualizeMainSnakChange(
DiffOpChange $mainSnakChange,
Snak $oldestMainSnak,
- Snak $newestMainSnak
+ Snak $newestMainSnak,
+ array $path
) {
$valueFormatter = new DiffOpValueFormatter(
- $this->snakVisualizer->getPropertyHeader(
$oldestMainSnak ),
- $this->snakVisualizer->getPropertyHeader(
$newestMainSnak ),
+ $this->snakVisualizer->getPropertyHeader(
$oldestMainSnak, $path ),
+ $this->snakVisualizer->getPropertyHeader(
$newestMainSnak, $path ),
// TODO: How to highlight the actual changes inside the
snak?
$this->snakVisualizer->getDetailedValue(
$mainSnakChange->getOldValue() ),
$this->snakVisualizer->getDetailedValue(
$mainSnakChange->getNewValue() )
@@ -143,16 +160,24 @@
* @param DiffOpChange $rankChange
* @param Snak $oldestMainSnak The old main snak, if present;
otherwise, the new main snak
* @param Snak $newestMainSnak The new main snak, if present;
otherwise, the old main snak
+ * @param string[] $path The path to prepend in the header
*
* @return string HTML
*/
- private function visualizeRankChange( DiffOpChange $rankChange, Snak
$oldestMainSnak, Snak $newestMainSnak ) {
+ private function visualizeRankChange(
+ DiffOpChange $rankChange,
+ Snak $oldestMainSnak,
+ Snak $newestMainSnak,
+ array $path
+ ) {
$msg = wfMessage( 'wikibase-diffview-rank' )->inLanguage(
$this->languageCode );
$header = $msg->parse();
$valueFormatter = new DiffOpValueFormatter(
- $this->snakVisualizer->getPropertyAndValueHeader(
$oldestMainSnak ) . ' / ' . $header,
- $this->snakVisualizer->getPropertyAndValueHeader(
$newestMainSnak ) . ' / ' . $header,
+ $this->snakVisualizer->getPropertyAndValueHeader(
$oldestMainSnak, $path ) . ' / ' .
+ $header,
+ $this->snakVisualizer->getPropertyAndValueHeader(
$newestMainSnak, $path ) . ' / ' .
+ $header,
$this->getRankHtml( $rankChange->getOldValue() ),
$this->getRankHtml( $rankChange->getNewValue() )
);
@@ -187,18 +212,24 @@
* @param Diff $changes
* @param Snak $oldestMainSnak The old main snak, if present;
otherwise, the new main snak
* @param Snak $newestMainSnak The new main snak, if present;
otherwise, the old main snak
+ * @param string[] $path The path to prepend in the header
*
* @return string HTML
*/
- private function visualizeReferenceChanges( Diff $changes, Snak
$oldestMainSnak, Snak $newestMainSnak ) {
+ private function visualizeReferenceChanges(
+ Diff $changes,
+ Snak $oldestMainSnak,
+ Snak $newestMainSnak,
+ array $path
+ ) {
$html = '';
$msg = wfMessage( 'wikibase-diffview-reference' )->inLanguage(
$this->languageCode );
$header = $msg->parse();
- $oldClaimHeader =
$this->snakVisualizer->getPropertyAndValueHeader( $oldestMainSnak )
+ $oldClaimHeader =
$this->snakVisualizer->getPropertyAndValueHeader( $oldestMainSnak, $path )
. ' / ' . $header;
- $newClaimHeader =
$this->snakVisualizer->getPropertyAndValueHeader( $newestMainSnak )
+ $newClaimHeader =
$this->snakVisualizer->getPropertyAndValueHeader( $newestMainSnak, $path )
. ' / ' . $header;
foreach ( $changes as $change ) {
@@ -253,18 +284,24 @@
* @param Diff $changes
* @param Snak $oldestMainSnak The old main snak, if present;
otherwise, the new main snak
* @param Snak $newestMainSnak The new main snak, if present;
otherwise, the old main snak
+ * @param string[] $path The path to prepend in the header
*
* @return string HTML
*/
- private function visualizeQualifierChanges( Diff $changes, Snak
$oldestMainSnak, Snak $newestMainSnak ) {
+ private function visualizeQualifierChanges(
+ Diff $changes,
+ Snak $oldestMainSnak,
+ Snak $newestMainSnak,
+ array $path
+ ) {
$html = '';
$msg = wfMessage( 'wikibase-diffview-qualifier' )->inLanguage(
$this->languageCode );
$header = $msg->parse();
- $oldClaimHeader =
$this->snakVisualizer->getPropertyAndValueHeader( $oldestMainSnak )
+ $oldClaimHeader =
$this->snakVisualizer->getPropertyAndValueHeader( $oldestMainSnak, $path )
. ' / ' . $header;
- $newClaimHeader =
$this->snakVisualizer->getPropertyAndValueHeader( $newestMainSnak )
+ $newClaimHeader =
$this->snakVisualizer->getPropertyAndValueHeader( $newestMainSnak, $path )
. ' / ' . $header;
foreach ( $changes as $change ) {
diff --git a/repo/includes/Diff/DifferencesSnakVisualizer.php
b/repo/includes/Diff/DifferencesSnakVisualizer.php
index d613e68..e537181 100644
--- a/repo/includes/Diff/DifferencesSnakVisualizer.php
+++ b/repo/includes/Diff/DifferencesSnakVisualizer.php
@@ -110,11 +110,17 @@
* Get formatted header for a snak, including the snak's property
label, but not the snak's value.
*
* @param Snak|null $snak
+ * @param string[] $path The path to prepend in the header
*
* @return string HTML
*/
- public function getPropertyHeader( Snak $snak = null ) {
- $headerText = wfMessage( 'wikibase-entity-property'
)->inLanguage( $this->languageCode )->escaped();
+ public function getPropertyHeader( Snak $snak = null, array $path = []
) {
+ $headerText = '';
+ if ( $path !== [] ) {
+ $headerText = implode( ' / ', $path ) . ' / ';
+ }
+ $headerText .= wfMessage( 'wikibase-entity-property' )
+ ->inLanguage( $this->languageCode )->escaped();
if ( $snak !== null ) {
$propertyId = $snak->getPropertyId();
@@ -128,11 +134,12 @@
* Get formatted header for a snak, including the snak's property label
and value.
*
* @param Snak $snak
+ * @param string[] $path The path to prepend in the header
*
* @return string HTML
*/
- public function getPropertyAndValueHeader( Snak $snak ) {
- $before = $this->getPropertyHeader( $snak );
+ public function getPropertyAndValueHeader( Snak $snak, array $path = []
) {
+ $before = $this->getPropertyHeader( $snak, $path );
try {
$after = $this->snakBreadCrumbFormatter->formatSnak(
$snak );
diff --git a/repo/tests/phpunit/includes/Diff/ClaimDifferenceVisualizerTest.php
b/repo/tests/phpunit/includes/Diff/ClaimDifferenceVisualizerTest.php
index e7eebf8..57bcbb2 100644
--- a/repo/tests/phpunit/includes/Diff/ClaimDifferenceVisualizerTest.php
+++ b/repo/tests/phpunit/includes/Diff/ClaimDifferenceVisualizerTest.php
@@ -53,15 +53,16 @@
$instance->expects( $this->any() )
->method( 'getPropertyHeader' )
- ->will( $this->returnCallback( function( Snak $snak ) {
- return 'property / ' .
$snak->getPropertyId()->getSerialization();
+ ->will( $this->returnCallback( function( Snak $snak,
array $path ) {
+ return implode( ' / ', $path ) . 'property / '
. $snak->getPropertyId()
+ ->getSerialization();
} ) );
$instance->expects( $this->any() )
->method( 'getPropertyAndValueHeader' )
- ->will( $this->returnCallback( function(
PropertyValueSnak $snak ) {
- return 'property / ' .
$snak->getPropertyId()->getSerialization() . ': ' .
- $snak->getDataValue()->getValue();
+ ->will( $this->returnCallback( function(
PropertyValueSnak $snak, array $path ) {
+ return implode( ' / ', $path ) . 'property / '
. $snak->getPropertyId()->getSerialization()
+ . ': '
.$snak->getDataValue()->getValue();
} ) );
return $instance;
@@ -87,7 +88,8 @@
'no change' => [
new ClaimDifference(),
new Statement( new PropertyValueSnak( new
PropertyId( 'P1' ), new StringValue( 'foo' ) ) ),
- ''
+ '',
+ []
],
'mainsnak' => [
new ClaimDifference(
@@ -102,7 +104,8 @@
'<tr><td class="diff-marker">-</td><td
class="diff-deletedline">'.
'<div><del class="diffchange
diffchange-inline"><span>bar (DETAILED)</span></del></div></td>'.
'<td class="diff-marker">+</td><td
class="diff-addedline">'.
- '<div><ins class="diffchange
diffchange-inline"><span>foo (DETAILED)</span></ins></div></td></tr>'
+ '<div><ins class="diffchange
diffchange-inline"><span>foo (DETAILED)</span></ins></div></td></tr>',
+ []
],
'+qualifiers' => [
new ClaimDifference(
@@ -115,7 +118,8 @@
'<tr><td colspan="2" class="diff-lineno"></td>'
.
'<td colspan="2" class="diff-lineno">property /
P1: foo / qualifier</td></tr>' .
'<tr><td colspan="2"> </td><td
class="diff-marker">+</td><td class="diff-addedline">'.
- '<div><ins class="diffchange
diffchange-inline"><span>P44: v (DETAILED)</span></ins></div></td></tr>'
+ '<div><ins class="diffchange
diffchange-inline"><span>P44: v (DETAILED)</span></ins></div></td></tr>',
+ []
],
'+references' =>
[
@@ -133,7 +137,8 @@
'<td colspan="2"
class="diff-lineno"></td></tr>' .
'<tr><td class="diff-marker">-</td><td
class="diff-deletedline">'.
'<div><del class="diffchange
diffchange-inline"><span>P50: v (DETAILED)</span>' .
- '</del></div></td><td
colspan="2"> </td></tr>'
+ '</del></div></td><td
colspan="2"> </td></tr>',
+ []
],
'ranks' => [
new ClaimDifference(
@@ -154,7 +159,8 @@
. '<td class="diff-marker">+</td><td
class="diff-addedline"><div>'
. '<ins class="diffchange
diffchange-inline"><span>Preferred rank</span></ins>'
. '</div></td>'
- . '</tr>'
+ . '</tr>',
+ []
],
'mainsnak and qualifiers' => [
new ClaimDifference(
@@ -205,7 +211,8 @@
. '<td class="diff-deletedline"><div><del
class="diffchange diffchange-inline">'
. '<span>P44: oldqualifiervalue
(DETAILED)</span></del></div></td>'
. '<td colspan="2"> </td>'
- . '</tr>'
+ . '</tr>',
+ []
],
'mainsnak and references' => [
new ClaimDifference(
@@ -257,7 +264,8 @@
. '<td class="diff-deletedline"><div><del
class="diffchange diffchange-inline">'
. '<span>P44: oldreferencevalue
(DETAILED)</span></del></div></td>'
. '<td colspan="2"> </td>'
- . '</tr>'
+ . '</tr>',
+ []
],
'mainsnak and rank' => [
new ClaimDifference(
@@ -284,7 +292,36 @@
'<tr><td class="diff-marker">-</td><td
class="diff-deletedline">'.
'<div><del class="diffchange
diffchange-inline"><span>Normal rank</span></del></div></td>'.
'<td class="diff-marker">+</td><td
class="diff-addedline">'.
- '<div><ins class="diffchange
diffchange-inline"><span>Preferred rank</span></ins></div></td></tr>'
+ '<div><ins class="diffchange
diffchange-inline"><span>Preferred rank</span></ins></div></td></tr>',
+ []
+ ],
+ 'mainsnak and rank with path' => [
+ new ClaimDifference(
+ new DiffOpChange(
+ new PropertyValueSnak( new
PropertyId( 'P1' ), new StringValue( 'oldmainsnakvalue' ) ),
+ new PropertyValueSnak( new
PropertyId( 'P1' ), new StringValue( 'newmainsnakvalue' ) )
+ ),
+ null,
+ null,
+ new DiffOpChange(
Statement::RANK_NORMAL, Statement::RANK_PREFERRED )
+ ),
+ new Statement( new PropertyValueSnak( new
PropertyId( 'P1' ), new StringValue( 'newmainsnakvalue' ) ) ),
+ // mainsnak change
+ '<tr><td colspan="2" class="diff-lineno">foo /
barproperty / P1</td><td colspan="2" class="diff-lineno">'.
+ 'foo / barproperty / P1</td></tr><tr><td
class="diff-marker">-</td><td class="diff-deletedline">'.
+ '<div><del class="diffchange
diffchange-inline"><span>oldmainsnakvalue (DETAILED)</span></del></div></td>'.
+ '<td class="diff-marker">+</td><td
class="diff-addedline">'.
+ '<div><ins class="diffchange
diffchange-inline"><span>newmainsnakvalue
(DETAILED)</span></ins></div></td></tr>'.
+ // rank change
+ '<tr>' .
+ '<td colspan="2" class="diff-lineno">foo /
barproperty / P1: oldmainsnakvalue / rank</td>' .
+ '<td colspan="2" class="diff-lineno">foo /
barproperty / P1: newmainsnakvalue / rank</td>' .
+ '</tr>' .
+ '<tr><td class="diff-marker">-</td><td
class="diff-deletedline">'.
+ '<div><del class="diffchange
diffchange-inline"><span>Normal rank</span></del></div></td>'.
+ '<td class="diff-marker">+</td><td
class="diff-addedline">'.
+ '<div><ins class="diffchange
diffchange-inline"><span>Preferred rank</span></ins></div></td></tr>',
+ [ 'foo', 'bar' ]
],
];
}
@@ -292,9 +329,14 @@
/**
* @dataProvider provideDifferenceAndClaim
*/
- public function testVisualizeClaimChange( $difference, $baseClaim,
$expectedHtml ) {
+ public function testVisualizeClaimChange(
+ $difference,
+ $baseClaim,
+ $expectedHtml,
+ array $path
+ ) {
$visualizer = $this->newClaimDifferenceVisualizer();
- $html = $visualizer->visualizeClaimChange( $difference,
$baseClaim );
+ $html = $visualizer->visualizeClaimChange( $difference,
$baseClaim, $path );
$this->assertHTMLEquals( $expectedHtml, $html );
}
@@ -302,25 +344,25 @@
$expect =
// main snak
'<tr><td colspan="2" class="diff-lineno"></td>'.
- '<td colspan="2" class="diff-lineno">property /
P12</td></tr>'.
+ '<td colspan="2" class="diff-lineno">foooproperty /
P12</td></tr>'.
'<tr><td colspan="2"> </td><td
class="diff-marker">+</td><td class="diff-addedline">'.
'<div><ins class="diffchange
diffchange-inline"><span>foo (DETAILED)</span></ins></div></td></tr>'.
// rank
'<tr><td colspan="2" class="diff-lineno"></td>'.
- '<td colspan="2" class="diff-lineno">property / P12:
foo / rank</td></tr>'.
+ '<td colspan="2" class="diff-lineno">foooproperty /
P12: foo / rank</td></tr>'.
'<tr><td colspan="2"> </td><td
class="diff-marker">+</td><td class="diff-addedline">'.
'<div><ins class="diffchange
diffchange-inline"><span>Normal rank</span></ins></div></td></tr>'.
// qualifier
'<tr><td colspan="2" class="diff-lineno"></td>'.
- '<td colspan="2" class="diff-lineno">property / P12:
foo / qualifier</td></tr>'.
+ '<td colspan="2" class="diff-lineno">foooproperty /
P12: foo / qualifier</td></tr>'.
'<tr><td colspan="2"> </td><td
class="diff-marker">+</td><td class="diff-addedline">'.
'<div><ins class="diffchange
diffchange-inline"><span>P50: v (DETAILED)</span></ins></div></td></tr>'.
// reference
'<tr><td colspan="2" class="diff-lineno"></td>'.
- '<td colspan="2" class="diff-lineno">property / P12:
foo / reference</td></tr>'.
+ '<td colspan="2" class="diff-lineno">foooproperty /
P12: foo / reference</td></tr>'.
'<tr><td colspan="2"> </td><td
class="diff-marker">+</td><td class="diff-addedline">'.
'<div><ins class="diffchange
diffchange-inline"><span>P44: referencevalue
(DETAILED)</span></ins></div></td></tr>';
@@ -333,7 +375,7 @@
new SnakList( [
new PropertyValueSnak( new
PropertyId( 'P44' ), new StringValue( 'referencevalue' ) )
] ) ) ] ) );
- $html = $visualizer->visualizeNewClaim( $claim );
+ $html = $visualizer->visualizeNewClaim( $claim, [ 'fooo' ] );
$this->assertHTMLEquals( $expect, $html );
}
@@ -341,28 +383,28 @@
public function testVisualizeRemovedClaim() {
$expect =
// main snak
- '<tr><td colspan="2" class="diff-lineno">property /
P12</td>'.
+ '<tr><td colspan="2" class="diff-lineno">barproperty /
P12</td>'.
'<td colspan="2" class="diff-lineno"></td></tr>'.
'<tr><td class="diff-marker">-</td><td
class="diff-deletedline">'.
'<div><del class="diffchange
diffchange-inline"><span>foo (DETAILED)</span></del></div>'.
'</td><td colspan="2"> </td></tr>'.
// rank
- '<tr><td colspan="2" class="diff-lineno">property /
P12: foo / rank</td>'.
+ '<tr><td colspan="2" class="diff-lineno">barproperty /
P12: foo / rank</td>'.
'<td colspan="2" class="diff-lineno"></td></tr>'.
'<tr><td class="diff-marker">-</td><td
class="diff-deletedline">'.
'<div><del class="diffchange
diffchange-inline"><span>Normal rank</span></del></div>'
.'</td><td colspan="2"> </td></tr>'.
// qualifier
- '<tr><td colspan="2" class="diff-lineno">property /
P12: foo / qualifier</td>'.
+ '<tr><td colspan="2" class="diff-lineno">barproperty /
P12: foo / qualifier</td>'.
'<td colspan="2" class="diff-lineno"></td></tr>'.
'<tr><td class="diff-marker">-</td><td
class="diff-deletedline">'.
'<div><del class="diffchange
diffchange-inline"><span>P50: v (DETAILED)</span></del></div>'.
'</td><td colspan="2"> </td></tr>'.
// reference
- '<tr><td colspan="2" class="diff-lineno">property /
P12: foo / reference</td>'.
+ '<tr><td colspan="2" class="diff-lineno">barproperty /
P12: foo / reference</td>'.
'<td colspan="2" class="diff-lineno"></td></tr>'.
'<tr><td class="diff-marker">-</td><td
class="diff-deletedline">'.
'<div><del class="diffchange
diffchange-inline"><span>P44: referencevalue (DETAILED)</span></del></div>'.
@@ -377,7 +419,7 @@
new SnakList( [
new PropertyValueSnak( new
PropertyId( 'P44' ), new StringValue( 'referencevalue' ) )
] ) ) ] ) );
- $html = $visualizer->visualizeRemovedClaim( $claim );
+ $html = $visualizer->visualizeRemovedClaim( $claim, [ 'bar' ] );
$this->assertHTMLEquals( $expect, $html );
}
diff --git a/repo/tests/phpunit/includes/Diff/DifferencesSnakVisualizerTest.php
b/repo/tests/phpunit/includes/Diff/DifferencesSnakVisualizerTest.php
index 8214eb1..60813b9 100644
--- a/repo/tests/phpunit/includes/Diff/DifferencesSnakVisualizerTest.php
+++ b/repo/tests/phpunit/includes/Diff/DifferencesSnakVisualizerTest.php
@@ -131,38 +131,40 @@
/**
* @dataProvider provideGetPropertyAndValueHeader
*/
- public function testGetPropertyAndValueHeader( $snak, $expected ) {
+ public function testGetPropertyAndValueHeader( $snak, $expected, array
$path ) {
$snakVisualizer = $this->newDifferencesSnakVisualizer();
- $result = $snakVisualizer->getPropertyAndValueHeader( $snak );
+ $result = $snakVisualizer->getPropertyAndValueHeader( $snak,
$path );
$this->assertEquals( $expected, $result );
}
public function provideGetPropertyAndValueHeader() {
- $expected = 'property / <a>PID</a>: <i>SNAK</i>';
+ $expected = 'foo / bar / property / <a>PID</a>: <i>SNAK</i>';
+ $path = [ 'foo', 'bar' ];
return [
- [ new PropertySomeValueSnak( new PropertyId( 'P1' ) ),
$expected ],
- [ new PropertyNoValueSnak( new PropertyId( 'P1' ) ),
$expected ],
- [ new PropertyValueSnak( new PropertyId( 'P1' ), new
StringValue( '' ) ), $expected ],
- //array( null, '' ),
+ [ new PropertySomeValueSnak( new PropertyId( 'P1' ) ),
$expected, $path ],
+ [ new PropertyNoValueSnak( new PropertyId( 'P1' ) ),
$expected, $path ],
+ [ new PropertyValueSnak( new PropertyId( 'P1' ), new
StringValue( '' ) ), $expected, $path ],
];
}
/**
* @dataProvider provideGetPropertyHeader
*/
- public function testGetPropertyHeader( $snak, $expected ) {
+ public function testGetPropertyHeader( $snak, $expected, array $path ) {
$snakVisualizer = $this->newDifferencesSnakVisualizer();
- $result = $snakVisualizer->getPropertyHeader( $snak );
+ $result = $snakVisualizer->getPropertyHeader( $snak, $path );
$this->assertEquals( $expected, $result );
}
public function provideGetPropertyHeader() {
- $expected = 'property / <a>PID</a>';
+ $expected = 'foo / bar / property / <a>PID</a>';
+ $path = [ 'foo', 'bar' ];
return [
- [ new PropertySomeValueSnak( new PropertyId( 'P1' ) ),
$expected ],
- [ new PropertyNoValueSnak( new PropertyId( 'P1' ) ),
$expected ],
- [ new PropertyValueSnak( new PropertyId( 'P1' ), new
StringValue( '' ) ), $expected ],
- [ null, 'property' ],
+ [ new PropertySomeValueSnak( new PropertyId( 'P1' ) ),
$expected, $path ],
+ [ new PropertyNoValueSnak( new PropertyId( 'P1' ) ),
$expected, $path ],
+ [ new PropertyValueSnak( new PropertyId( 'P1' ), new
StringValue( '' ) ), $expected, $path ],
+ [ null, 'foo / bar / property', $path ],
+ [ null, 'property', [] ],
];
}
--
To view, visit https://gerrit.wikimedia.org/r/401934
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia4bebd82b013eaddca6cb9b988caf7328e260a1a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Thiemo Kreuz (WMDE) <[email protected]>
Gerrit-Reviewer: WMDE-leszek <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits