r102411 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102410‎ | r102411 | r102412 >
Date:16:22, 8 November 2011
Author:hashar
Status:resolved (Comments)
Tags:
Comment:
test SQL for our QueryPages objects

Part of bug 32118: test special pages SQL queries against all supported DB

Still need to add all the other non QueryPage special pages and then setup
jenkins to support other databases.
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php (added) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php
@@ -0,0 +1,51 @@
 2+<?php
 3+/**
 4+ * Test class to run the query of most of all our special pages
 5+ *
 6+ * Copyright © 2011, Antoine Musso
 7+ *
 8+ * @author Antoine Musso
 9+ * @group Database
 10+ */
 11+global $IP;
 12+require_once("$IP/includes/QueryPage.php");
 13+class QueryAllSpecialPagesTest extends MediaWikiTestCase {
 14+
 15+ /** List query pages that can not be tested automatically */
 16+ protected $manualTest = array(
 17+ 'LinkSearchPage'
 18+ );
 19+
 20+ /**
 21+ * Initialize all query page objects
 22+ */
 23+ function __construct() {
 24+ parent::__construct();
 25+
 26+ global $wgQueryPages;
 27+ foreach( $wgQueryPages as $page ) {
 28+ $class = $page[0];
 29+ if( ! in_array( $class, $this->manualTest ) ) {
 30+ $this->queryPages[$class] = new $class;
 31+ }
 32+ }
 33+ }
 34+
 35+ /**
 36+ * Test SQL for each of our QueryPages objects
 37+ * @group Database
 38+ */
 39+ function testQuerypageSqlQuery() {
 40+ foreach( $this->queryPages as $page ) {
 41+
 42+ $msg = "SQL query for page {$page->getName()} should give a result wrapper object" ;
 43+
 44+ $result = $page->reallyDoQuery( 50 );
 45+ if( $result instanceof ResultWrapper ) {
 46+ $this->assertTrue( true, $msg );
 47+ } else {
 48+ $this->assertFalse( false, $msg );
 49+ }
 50+ }
 51+ }
 52+}
Property changes on: trunk/phase3/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php
___________________________________________________________________
Added: svn:eol-style
153 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r108331r102411 fixup. Close register globals vuln, and document...platonides22:42, 7 January 2012
r109024Skip BrokenRedirectsPage query test under MySQL...hashar10:33, 16 January 2012

Comments

#Comment by Platonides (talk | contribs)   22:39, 7 January 2012

This fails for mysql, using temporary tables, as it hits [https://bugzilla.wikimedia.org/show_bug.cgi?id=10327 bug 10327]

Query: SELECT p1.page_namespace AS namespace,p1.page_title AS title,p1.page_title AS value,rd_namespace,rd_title FROM `unittest_redirect` JOIN `unittest_page` `p1` ON ((rd_from=p1.page_id)) LEFT JOIN `unittest_page` `p2` ON ((rd_namespace=p2.page_namespace) AND (rd_title=p2.page_title)) WHERE (rd_namespace >= 0) AND (p2.page_namespace IS NULL) ORDER BY rd_namespace, rd_title, rd_from LIMIT 50

Function: BrokenRedirectsPage::reallyDoQuery

Error: 1137 Can't reopen table: 'p1'

#Comment by Hashar (talk | contribs)   11:59, 8 January 2012

Wonderful! Marking rev as fixme since the aim is to test those queries against each DB backends.

#Comment by Hashar (talk | contribs)   10:34, 16 January 2012

I made the test suite to skip that query when using MySQL ( r109024 ).

Ideally, we should run the query against the real database.

#Comment by Aaron Schulz (talk | contribs)   22:46, 7 January 2012

I've complained about this error on IRC a few times. I always have to use use-normal-tables.

Status & tagging log