Jeroen De Dauw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/74256


Change subject: Added extra tests for MapDiffer to clarify behaviour for 
wikibase sitelink like structures
......................................................................

Added extra tests for MapDiffer to clarify behaviour for wikibase sitelink like 
structures

Change-Id: I5a7640dcadafbdc18de2d616a2defda95ae1250d
---
M tests/phpunit/differ/MapDifferTest.php
1 file changed, 138 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Diff 
refs/changes/56/74256/1

diff --git a/tests/phpunit/differ/MapDifferTest.php 
b/tests/phpunit/differ/MapDifferTest.php
index 8e2642f..37e88f1 100644
--- a/tests/phpunit/differ/MapDifferTest.php
+++ b/tests/phpunit/differ/MapDifferTest.php
@@ -186,6 +186,144 @@
                $argLists[] = array( $old, $new, $expected,
                        'Nested structures with no differences should not 
result in nested empty diffs (these empty diffs should be omitted)', true );
 
+
+               $old = array( 'links' => array(
+                       'enwiki' => array(
+                               'page' => 'Foo',
+                               'badges' => array(),
+                       )
+               ) );
+               $new = array( 'links' => array(
+                       'enwiki' => array(
+                               'page' => 'Foo',
+                               'badges' => array(),
+                       )
+               ) );
+               $expected = array();
+
+               $argLists[] = array( $old, $new, $expected,
+                       'Comparing identical nested structures should not 
result in diff operations',
+                       true );
+
+
+               $old = array( 'links' => array(
+               ) );
+               $new = array( 'links' => array(
+                       'enwiki' => array(
+                               'page' => 'Foo',
+                               'badges' => array(),
+                       )
+               ) );
+               $expected = array( 'links' => new Diff( array(
+                       'enwiki' => new Diff( array(
+                               'page' => new DiffOpAdd( 'Foo' )
+                       ) )
+               ), true ) );
+
+               $argLists[] = array( $old, $new, $expected,
+                       'Adding a sitelink with no badges',
+                       true );
+
+
+               $old = array( 'links' => array(
+               ) );
+               $new = array( 'links' => array(
+                       'enwiki' => array(
+                               'page' => 'Foo',
+                               'badges' => array( 'Bar', 'Baz' ),
+                       )
+               ) );
+               $expected = array( 'links' => new Diff( array(
+                       'enwiki' => new Diff( array(
+                               'page' => new DiffOpAdd( 'Foo' ),
+                               'badges' => new Diff( array(
+                                       new DiffOpAdd( 'Bar' ),
+                                       new DiffOpAdd( 'Baz' ),
+                               ), false )
+                       ), true )
+               ), true ) );
+
+               $argLists[] = array( $old, $new, $expected,
+                       'Adding a sitelink with badges',
+                       true );
+
+
+               $old = array( 'links' => array(
+                       'enwiki' => array(
+                               'page' => 'Foo',
+                               'badges' => array(),
+                       )
+               ) );
+               $new = array( 'links' => array(
+                       'enwiki' => array(
+                               'page' => 'Foo',
+                               'badges' => array( 'Bar', 'Baz' ),
+                       )
+               ) );
+               $expected = array( 'links' => new Diff( array(
+                       'enwiki' => new Diff( array(
+                               'badges' => new Diff( array(
+                                       new DiffOpAdd( 'Bar' ),
+                                       new DiffOpAdd( 'Baz' ),
+                               ), false )
+                       ), true )
+               ), true ) );
+
+               $argLists[] = array( $old, $new, $expected,
+                       'Adding bagdes to a sitelink',
+                       true );
+
+
+               $old = array();
+               $new = array(
+                       'enwiki' => array(
+                               'page' => 'Foo',
+                               'badges' => array( 'Bar', 'Baz' ),
+                       )
+               );
+               $expected = array(
+                       'enwiki' => new DiffOpAdd(
+                               array(
+                                       'page' => 'Foo',
+                                       'badges' => array( 'Bar', 'Baz' ),
+                               )
+                       )
+               );
+
+               $argLists[] = array( $old, $new, $expected,
+                       'Adding a sitelink with non-recursive mode',
+                       false );
+
+
+               $old = array(
+                       'enwiki' => array(
+                               'page' => 'Foo',
+                               'badges' => array(),
+                       )
+               );
+               $new = array(
+                       'enwiki' => array(
+                               'page' => 'Foo',
+                               'badges' => array( 'Bar', 'Baz' ),
+                       )
+               );
+               $expected = array(
+                       'enwiki' => new DiffOpChange(
+                               array(
+                                       'page' => 'Foo',
+                                       'badges' => array(),
+                               ),
+                               array(
+                                       'page' => 'Foo',
+                                       'badges' => array( 'Bar', 'Baz' ),
+                               )
+                       )
+               );
+
+               $argLists[] = array( $old, $new, $expected,
+                       'Adding badges to a sitelink with non-recursive mode',
+                       false );
+
                return $argLists;
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/74256
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a7640dcadafbdc18de2d616a2defda95ae1250d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Diff
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to