3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
22 class DbTestRecorder
extends DbTestPreviewer
{
26 * Set up result recording; insert a record for the run with the date
27 * and all that fun stuff
30 $this->db
->begin( __METHOD__
);
32 if ( !$this->db
->tableExists( 'testrun' )
33 ||
!$this->db
->tableExists( 'testitem' )
35 print "WARNING> `testrun` table not found in database. Trying to create table.\n";
36 $this->db
->sourceFile( $this->db
->patchPath( 'patch-testrun.sql' ) );
37 echo "OK, resuming.\n";
42 $this->db
->insert( 'testrun',
44 'tr_date' => $this->db
->timestamp(),
45 'tr_mw_version' => $this->version
,
46 'tr_php_version' => PHP_VERSION
,
47 'tr_db_version' => $this->db
->getServerVersion(),
48 'tr_uname' => php_uname()
51 if ( $this->db
->getType() === 'postgres' ) {
52 $this->curRun
= $this->db
->currentSequenceValue( 'testrun_id_seq' );
54 $this->curRun
= $this->db
->insertId();
59 * Record an individual test item's success or failure to the db
64 function record( $test, $subtest, $result ) {
65 parent
::record( $test, $subtest, $result );
67 $this->db
->insert( 'testitem',
69 'ti_run' => $this->curRun
,
70 'ti_name' => $this->getName( $test, $subtest ),
71 'ti_success' => $result ?
1 : 0,
77 * Commit transaction and clean up for result recording
80 $this->db
->commit( __METHOD__
);