- private function assertResultRecursive( $expected, $result ) {
- reset( $expected );
- reset( $result );
- while ( true ) {
- $e = each( $expected );
- $r = each( $result );
- // If either of the arrays is shorter, abort. If both are done, success.
- $this->assertEquals( (bool)$e, (bool)$r );
- if ( !$e ) {
- break; // done
- }
- // continue only if keys are identical or both keys are numeric
- $this->assertTrue( $e['key'] === $r['key'] || ( is_numeric( $e['key'] ) && is_numeric( $r['key'] ) ) );
- // don't compare pageids
- if ( $e['key'] !== 'pageid' ) {
- // If values are arrays, compare recursively, otherwise compare with ===
- if ( is_array( $e['value'] ) && is_array( $r['value'] ) ) {
- $this->assertResultRecursive( $e['value'], $r['value'] );
- } else {
- $this->assertEquals( $e['value'], $r['value'] );
- }
+ private static function sanitizeResultArray( $result ) {
+ unset( $result['pageid'] );
+ foreach ( $result as $key => $value ) {
+ if ( is_array( $value ) ) {
+ $result[$key] = self::sanitizeResultArray( $value );