Thiemo Mättig (WMDE) has uploaded a new change for review.

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

Change subject: SetSiteLinkTest finally compatible with DataModel 1.0
......................................................................

SetSiteLinkTest finally compatible with DataModel 1.0

flattenArray? Really? Very ouch.

Change-Id: Ifaf79735f2910982009a6594d3aef9eb323f2ed3
---
M repo/tests/phpunit/includes/api/SetSiteLinkTest.php
1 file changed, 13 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/53/157653/1

diff --git a/repo/tests/phpunit/includes/api/SetSiteLinkTest.php 
b/repo/tests/phpunit/includes/api/SetSiteLinkTest.php
index 8a73e03..2fa7b83 100644
--- a/repo/tests/phpunit/includes/api/SetSiteLinkTest.php
+++ b/repo/tests/phpunit/includes/api/SetSiteLinkTest.php
@@ -193,7 +193,7 @@
        /**
         * @dataProvider provideData
         */
-       public function testSetLiteLink( $params, $expected ) {
+       public function testSetSiteLink( $params, $expected ) {
                // -- set any defaults ------------------------------------
                if ( array_key_exists( 'handle', $params ) ) {
                        $params['id'] = EntityTestHelper::getId( 
$params['handle'] );
@@ -276,16 +276,19 @@
                }
                if ( $expectedInDb ) {
                        $this->assertArrayHasKey( 'sitelinks', $dbEntity );
+                       $this->assertCount( $expectedInDb, 
$dbEntity['sitelinks'] );
 
-                       foreach ( array( 'title', 'badges' ) as $prop ) {
-                               $dbSitelinks = self::flattenArray( 
$dbEntity['sitelinks'], 'site', $prop );
-                               $this->assertEquals( $expectedInDb, count( 
$dbSitelinks ) );
-                               foreach ( $expected['value'] as $valueSite => 
$value ) {
-                                       $this->assertArrayHasKey( $valueSite, 
$dbSitelinks );
-                                       $this->assertEquals( $value[$prop], 
$dbSitelinks[$valueSite],
-                                               "'$prop' value is not correct"
-                                       );
-                               }
+                       foreach ( $expected['value'] as $site => 
$expectedSiteLink ) {
+                               $this->assertArrayHasKey( $site, 
$dbEntity['sitelinks'] );
+                               $dbSiteLink = $dbEntity['sitelinks'][$site];
+
+                               $this->assertArrayHasKey( 'title', $dbSiteLink 
);
+                               $this->assertInternalType( 'string', 
$dbSiteLink['title'] );
+                               $this->assertSame( $expectedSiteLink['title'], 
$dbSiteLink['title'] );
+
+                               $this->assertArrayHasKey( 'badges', $dbSiteLink 
);
+                               $this->assertInternalType( 'array', 
$dbSiteLink['badges'] );
+                               $this->assertArrayEquals( 
$expectedSiteLink['badges'], $dbSiteLink['badges'] );
                        }
                } else {
                        $this->assertArrayNotHasKey( 'sitelinks', $dbEntity );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifaf79735f2910982009a6594d3aef9eb323f2ed3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to