From: saper Date: Thu, 5 Dec 2013 09:46:18 +0000 (+0100) Subject: Remove mergeExpected and assertResultRecursive X-Git-Tag: 1.31.0-rc.0~17745^2 X-Git-Url: http://git.cyclocoop.org/%22.%24image2.%22?a=commitdiff_plain;h=b69d9220b60478624553702464c781df4c395c1e;p=lhc%2Fweb%2Fwiklou.git Remove mergeExpected and assertResultRecursive These ApiQueryBasicTest methods are no longer used and we have a better alternatives in the parent ApiQueryTestBase. Change-Id: I7a81ad3dd6e880be151c1901037bab4018493bcf --- diff --git a/tests/phpunit/includes/api/query/ApiQueryBasicTest.php b/tests/phpunit/includes/api/query/ApiQueryBasicTest.php index 9c5b3ca2ad..e486c4f4bc 100644 --- a/tests/phpunit/includes/api/query/ApiQueryBasicTest.php +++ b/tests/phpunit/includes/api/query/ApiQueryBasicTest.php @@ -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'] ); - } - } - } - } }