MediaWiki
REL1_32
DbTestRecorder.php
Go to the documentation of this file.
1
<?php
22
use
Wikimedia\Rdbms\IMaintainableDatabase
;
23
24
class
DbTestRecorder
extends
TestRecorder
{
25
public
$version
;
27
private
$db
;
28
29
public
function
__construct
(
IMaintainableDatabase
$db
) {
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"
;
44
$updater
=
DatabaseUpdater::newForDB
( $this->db );
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
}
DatabaseUpdater\newForDB
static newForDB(Database $db, $shared=false, Maintenance $maintenance=null)
Definition
DatabaseUpdater.php:189
DbTestRecorder
Definition
DbTestRecorder.php:24
DbTestRecorder\__construct
__construct(IMaintainableDatabase $db)
Definition
DbTestRecorder.php:29
DbTestRecorder\record
record( $test, ParserTestResult $result)
Record an individual test item's success or failure to the db.
Definition
DbTestRecorder.php:71
DbTestRecorder\start
start()
Set up result recording; insert a record for the run with the date and all that fun stuff.
Definition
DbTestRecorder.php:37
DbTestRecorder\$db
Database $db
Definition
DbTestRecorder.php:27
DbTestRecorder\end
end()
Commit transaction and clean up for result recording.
Definition
DbTestRecorder.php:84
DbTestRecorder\$version
$version
Definition
DbTestRecorder.php:25
ParserTestResult
Represent the result of a parser test.
Definition
ParserTestResult.php:14
TestRecorder
Interface to record parser test results.
Definition
TestRecorder.php:35
print
while(( $__line=Maintenance::readconsole()) !==false) print
Definition
eval.php:64
Wikimedia\Rdbms\IMaintainableDatabase
Advanced database interface for IDatabase handles that include maintenance methods.
Definition
IMaintainableDatabase.php:38
$updater
$page->newPageUpdater($user) $updater
Definition
pageupdater.txt:63
tests
parser
DbTestRecorder.php
Generated on Mon Nov 25 2024 15:58:28 for MediaWiki by
1.10.0