4 * Tests for the TestORMRow class.
5 * TestORMRow is a dummy class to be able to test the abstract ORMRow class.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
29 * The database group has as a side effect that temporal database tables are created. This makes
30 * it possible to test without poisoning a production database.
33 * Some of the tests takes more time, and needs therefor longer time before they can be aborted
34 * as non-functional. The reason why tests are aborted is assumed to be set up of temporal databases
35 * that hold the first tests in a pending state awaiting access to the database.
38 * @licence GNU GPL v2+
39 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
41 class TestORMRowTest
extends ORMRowTest
{
47 protected function getRowClass() {
55 protected function getTableInstance() {
56 return TestORMtable
::singleton();
59 public function setUp() {
62 $dbw = wfGetDB( DB_MASTER
);
64 $isSqlite = $GLOBALS['wgDBtype'] === 'sqlite';
66 $idField = $isSqlite ?
'INTEGER' : 'INT unsigned';
67 $primaryKey = $isSqlite ?
'PRIMARY KEY AUTOINCREMENT' : 'auto_increment PRIMARY KEY';
70 'CREATE TABLE IF NOT EXISTS ' . $dbw->tableName( 'orm_test' ) . '(
71 test_id ' . $idField . ' NOT NULL ' . $primaryKey . ',
72 test_name VARCHAR(255) NOT NULL,
73 test_age TINYINT unsigned NOT NULL,
74 test_height FLOAT NOT NULL,
75 test_awesome TINYINT unsigned NOT NULL,
76 test_stuff BLOB NOT NULL,
77 test_moarstuff BLOB NOT NULL,
78 test_time varbinary(14) NOT NULL
83 public function constructorTestProvider() {
91 'stuff' => array( 13, 11, 7, 5, 3, 2 ),
92 'moarstuff' => (object)array( 'foo' => 'bar', 'bar' => array( 4, 2 ), 'baz' => true )
101 class TestORMRow
extends ORMRow
{}
103 class TestORMTable
extends ORMTable
{
106 * Returns the name of the database table objects of this type are stored in.
112 public function getName() {
117 * Returns the name of a IORMRow implementing class that
118 * represents single rows in this table.
124 public function getRowClass() {
129 * Returns an array with the fields and their types this object contains.
130 * This corresponds directly to the fields in the database, without prefix.
147 public function getFields() {
155 'moarstuff' => 'blob',
156 'time' => 'int', // TS_MW
161 * Gets the db field prefix.
167 protected function getFieldPrefix() {