<?php
/**
- *
*
* Created on Feb 6, 2013
*
* @covers ApiQuery
*/
class ApiQueryBasicTest extends ApiQueryTestBase {
+ protected $exceptionFromAddDBData;
+
/**
* Create a set of pages. These must not change, otherwise the tests might give wrong results.
* @see MediaWikiTestCase::addDBData()
) )
);
+ // Although this appears to have no use it is used by testLists()
private static $allcategories = array(
array( 'list' => 'allcategories', 'acprefix' => 'AQBT-' ),
array( 'allcategories' => array(
$this->check( self::$alllinks );
$this->check( self::$alltransclusions );
// This test is temporarily disabled until a sqlite bug is fixed
+ // Confirmed still broken 15-nov-2013
// $this->check( self::$allcategories );
$this->check( self::$backlinks );
$this->check( self::$embeddedin );
)
) );
}
-
- /**
- * 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 $expected array expected values
- * @param $result array returned values
- */
- private function assertQueryResults( $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->assertQueryResults( $e['value'], $r['value'] );
- } else {
- $this->assertEquals( $e['value'], $r['value'] );
- }
- }
- }
- }
}