MediaWiki REL1_32
DbTestRecorder.php
Go to the documentation of this file.
1<?php
23
25 public $version;
27 private $db;
28
30 $this->db = $db;
31 }
32
37 function start() {
38 $this->db->begin( __METHOD__ );
39
40 if ( !$this->db->tableExists( 'testrun' )
41 || !$this->db->tableExists( 'testitem' )
42 ) {
43 print "WARNING> `testrun` table not found in database. Trying to create table.\n";
45 $this->db->sourceFile( $updater->patchPath( $this->db, 'patch-testrun.sql' ) );
46 echo "OK, resuming.\n";
47 }
48
49 $this->db->insert( 'testrun',
50 [
51 'tr_date' => $this->db->timestamp(),
52 'tr_mw_version' => $this->version,
53 'tr_php_version' => PHP_VERSION,
54 'tr_db_version' => $this->db->getServerVersion(),
55 'tr_uname' => php_uname()
56 ],
57 __METHOD__ );
58 if ( $this->db->getType() === 'postgres' ) {
59 $this->curRun = $this->db->currentSequenceValue( 'testrun_id_seq' );
60 } else {
61 $this->curRun = $this->db->insertId();
62 }
63 }
64
71 function record( $test, ParserTestResult $result ) {
72 $this->db->insert( 'testitem',
73 [
74 'ti_run' => $this->curRun,
75 'ti_name' => $test['desc'],
76 'ti_success' => $result->isSuccess() ? 1 : 0,
77 ],
78 __METHOD__ );
79 }
80
84 function end() {
85 $this->db->commit( __METHOD__ );
86 }
87}
static newForDB(Database $db, $shared=false, Maintenance $maintenance=null)
__construct(IMaintainableDatabase $db)
record( $test, ParserTestResult $result)
Record an individual test item's success or failure to the db.
start()
Set up result recording; insert a record for the run with the date and all that fun stuff.
end()
Commit transaction and clean up for result recording.
Represent the result of a parser test.
Interface to record parser test results.
while(( $__line=Maintenance::readconsole()) !==false) print
Definition eval.php:64
Advanced database interface for IDatabase handles that include maintenance methods.
$page->newPageUpdater($user) $updater