ItSpiderman has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/358592 )

Change subject: Add method that defines root node name in results
......................................................................

Add method that defines root node name in results

Some stores do not return their content in 'results' node.
Now subclasses can define name of that node

Needs cherry-picking to REL1_27

Change-Id: I3adadc150f14dab08d214fa8cc2fdc401c04387f
---
M tests/BSApiExtJSStoreTestBase.php
1 file changed, 13 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceFoundation 
refs/changes/92/358592/1

diff --git a/tests/BSApiExtJSStoreTestBase.php 
b/tests/BSApiExtJSStoreTestBase.php
index a9dfb84..ce8aec2 100644
--- a/tests/BSApiExtJSStoreTestBase.php
+++ b/tests/BSApiExtJSStoreTestBase.php
@@ -33,7 +33,7 @@
                );
 
                $response = $results[0];
-               $firstRow = (object)$response['results'][0];
+               $firstRow = (object)$response[ $this->getResultsNodeName() ][0];
                $schema = $this->getStoreSchema();
                foreach( $schema as $schemaFieldName => $config ) {
                        $this->assertObjectHasAttribute( $schemaFieldName, 
$firstRow, "Dataset misses field '$schemaFieldName'' from schema definition!" );
@@ -76,7 +76,7 @@
                        'action' => $this->getModuleName()
                );
                $results = $this->doApiRequest( $aParams );
-               $resultItems = $results[0]["results"];
+               $resultItems = $results[0][ $this->getResultsNodeName() ];
 
                $keyPresent = $this->array_findNestedKeyValuePair( 
$resultItems, $keyItemKey, $keyItemValue );
 
@@ -114,7 +114,7 @@
                        );
                }
 
-               $this->assertLessThanOrEqual( $limit, 
count($response['results']), 'Number of results exceeds limit' );
+               $this->assertLessThanOrEqual( $limit, count($response[ 
$this->getResultsNodeName() ]), 'Number of results exceeds limit' );
        }
 
        public function providePagingData() {
@@ -245,4 +245,14 @@
                }
                return false;
        }
+
+       /**
+        * Allows subclasses to define name of
+        * root node in results
+        * @return string
+        */
+       protected function getResultsNodeName() {
+               return 'results';
+       }
+
 }
\ No newline at end of file

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3adadc150f14dab08d214fa8cc2fdc401c04387f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: ItSpiderman <d.savulje...@gmail.com>

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

Reply via email to