blob: c40bffa0f9d41d673a79a6b76a7e8662ac21dbe6 (
plain)
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
|
<?php
class PersonTest extends UnitTestCase
{
function testPersonList()
{
//try it
$people = TMapper::instance()->queryForList("SelectAll");
//test it
$this->assertNotNull($people, "Person list is not returned");
$this->assertTrue(count($people) > 0, "Person list is empty");
$person = $people[0];
$this->assertNotNull($person, "Person not returned");
}
function testPersonUpdate()
{
$expect = "wei";
$edited = "Nah";
//get it;
$person = TMapper::instance()->queryForObject("Select", 1);
//test it
$this->assertNotNull($person);
$this->assertEqual($expect, $person->FirstName);
//change it
$person->FirstName = $edited;
TMapper::instance()->update("Update", $person);
//get it again
$person = TMapper::instance()->queryForObject("Select", 1);
//test it
$this->assertEqual($edited, $person->FirstName);
//change it back
$person->FirstName = $expect;
TMapper::instance()->update("Update", $person);
}
function testPersonDelete()
{
//insert it
$person = new Person;
$person->ID = -1;
TMapper::instance()->insert("Insert", $person);
//delte it
$count = TMapper::instance()->delete("Delete", -1);
$this->assertEqual(1, $count);
}
}
?>
|