-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_test.php
More file actions
94 lines (82 loc) · 2.24 KB
/
db_test.php
File metadata and controls
94 lines (82 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
require_once('class.db.php');
require_once('class.record.php');
/**
* Tests the \Module\DB\Record() class
*
* @internal
* @date August 13, 2014
* @author Jaime A. Rodriguez <hi.i.am.jaime@gmail.com>
* @version 1.8
* @license http://opensource.org/licenses/MIT
*/
class Log extends \Module\DB\Record {
public $table = 'log';
}
/**
* @internal
*/
class TestOfDB extends UnitTestCase {
function setup() {
$this->log = new Log();
}
// Make sure DB is setup
function testDBsetup() {
}
// Check singleton pattern
function testSingleton() {
// Assert that the class is abstract
$abstractClass = new ReflectionClass('\Module\DB\DB');
$this->assertTrue($abstractClass->isAbstract());
}
// Extend \DB\Record, check for load, save, delete methods
function testRecord() {
$this->assertTrue(method_exists($this->log, 'load'));
$this->assertTrue(method_exists($this->log, 'save'));
$this->assertTrue(method_exists($this->log, 'delete'));
$this->assertTrue(method_exists($this->log, 'form'));
}
function testCRUD() {
// Create
$this->log->columns['message'] = "Testing, testing, 123.";
$id = $this->log->save();
unset($this->log);
// Read
$this->log = new Log($id);
$this->assertEqual($this->log->columns['id'], $id);
// Update
$this->log->columns['message'] = "Testing";
$this->log->save();
unset($this->log);
// Read
$this->log = new Log($id);
$this->assertEqual($this->log->columns['message'], "Testing");
unset($this->log);
// Delete
$this->log = new Log($id);
$this->assertTrue($this->log->delete());
}
// Check for correct meta data
// Use alternative primary key
// Check that form is correctly displayed
// Check for load hook
// Check for before/failure/success save hook
// Check for before/failure/success delete hook
// Check for form label filter
// Check for form value filter
// Check for form <li> buffer filter
// Check form for LONG
// Check form for FLOAT
// Check form for STRING
// Check form for VARSTRING
// Check form for PASSWORD
// Check form for DATETIME
// Check form for TIMESTAMP
// Check form for NEWDECIMAL
// Check form for BLOB
// Check filter for submit button value
// test Create method
// test Save method
// test Update method
// test delete method
}