Remove mergeExpected and assertResultRecursive
authorsaper <saper@saper.info>
Thu, 5 Dec 2013 09:46:18 +0000 (10:46 +0100)
committersaper <saper@saper.info>
Thu, 5 Dec 2013 23:12:40 +0000 (00:12 +0100)
These ApiQueryBasicTest methods are no longer used
and we have a better alternatives in the parent ApiQueryTestBase.

Change-Id: I7a81ad3dd6e880be151c1901037bab4018493bcf

tests/phpunit/includes/api/query/ApiQueryBasicTest.php

index 9c5b3ca..e486c4f 100644 (file)
@@ -350,52 +350,4 @@ class ApiQueryBasicTest extends ApiQueryTestBase {
                        )
                ) );
        }
-
-       /**
-        * Recursively merges the expected values in the $item into the $all
-        */
-       private function mergeExpected( &$all, $item ) {
-               foreach ( $item as $k => $v ) {
-                       if ( array_key_exists( $k, $all ) ) {
-                               if ( is_array( $all[$k] ) ) {
-                                       $this->mergeExpected( $all[$k], $v );
-                               } else {
-                                       $this->assertEquals( $all[$k], $v );
-                               }
-                       } else {
-                               $all[$k] = $v;
-                       }
-               }
-       }
-
-       /**
-        * Recursively compare arrays, ignoring mismatches in numeric key and pageids.
-        *
-        * @param $expectedArray array expected values
-        * @param $resultArray array returned values
-        */
-       private function assertQueryResults( $expectedArray, $resultArray ) {
-               reset( $expectedArray );
-               reset( $resultArray );
-               while ( true ) {
-                       $expectedValue = each( $expectedArray );
-                       $resultValue = each( $resultArray );
-                       // If either of the arrays is shorter, abort. If both are done, success.
-                       $this->assertEquals( (bool)$expectedValue, (bool)$resultValue );
-                       if ( !$expectedValue ) {
-                               break; // done
-                       }
-                       // continue only if keys are identical or both keys are numeric
-                       $this->assertTrue( $expectedValue['key'] === $resultValue['key'] || ( is_numeric( $expectedValue['key'] ) && is_numeric( $resultValue['key'] ) ) );
-                       // don't compare pageids
-                       if ( $expectedValue['key'] !== 'pageid' ) {
-                               // If values are arrays, compare recursively, otherwise compare with ===
-                               if ( is_array( $expectedValue['value'] ) && is_array( $resultValue['value'] ) ) {
-                                       $this->assertQueryResults( $expectedValue['value'], $resultValue['value'] );
-                               } else {
-                                       $this->assertEquals( $expectedValue['value'], $resultValue['value'] );
-                               }
-                       }
-               }
-       }
 }