forked from DaoCloud/php-apache-mysql-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DBTest.php
45 lines (37 loc) · 890 Bytes
/
DBTest.php
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
<?php
require_once("DB.php");
class DBTest extends PHPUnit_Framework_TestCase
{
public $db;
function setUp()
{
$this->db = new DB();
}
function tearDown() {
unset($this->db);
}
function exist($name, $phone) {
$contacts = $this->db->all();
foreach ($contacts as $index => $contact) {
if ($contact['name'] == $name && $contact['phone'] == $phone) {
return true;
}
}
return false;
}
function total() {
return count($this->db->all());
}
function test001()
{
$this->db->add("abc", "123");
$this->assertTrue($this->exist("abc", "123"));
}
function test002()
{
$pre = $this->total();
$this->db->add("bcd", "1234");
$post = $this->total();
$this->assertTrue($post - $pre == 1);
}
}