Repository navigation
Expand file tree
/
Copy pathtest.php
More file actions
66 lines (52 loc) · 1.32 KB
/
Copy pathtest.php
File metadata and controls
66 lines (52 loc) · 1.32 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
<?php
session_start();
include('Classes/database.php');
include('Classes/functions.php');
$bookmarks = new Bookmark();
$test = new test();
$user_bookmark = new User_Bookmark($_SESSION['userid']);
echo "<pre>User ID:";
echo $_SESSION['userid']."\n";
//test fetching an array that doesn't exist
$a = $bookmarks->read(array('title'=>'I SHOULD NOT EXIST'));
$test->equals($a[0]['id'],0);
//test fetching an array that doesn't exist returns an empty array
$a = $bookmarks->read(array('title'=>'I SHOULD NOT EXIST'));
$test->equals(empty($a),TRUE);
//Test 3: User creates a bookmark
$a = $user_bookmark->add('theTitle','http://theURL','aNote');
$test->equals($a,false);
//Test 4: View User Specific Bookamrks
$a = $user_bookmark->read();
var_dump($a);
if(empty($a))$a=false;
else $a = true;
$test->equals($a,true);
$test->report();
echo "</pre>";
class test{
public $tests=0;
public $fails=0;
function equals($a,$b){
//test if $a == $b
$this->tests++;
if ($a == $b){
//you passed!
}else{
$this->fails++;
echo "Test ".$this->tests." failed: $a != $b\n";
}
}
function greater($a,$b){
$this->tests++;
if ($a > $b){
//you passed!
}else{
$this->fails++;
echo "Test ".$this->tests." failed: $a !> $b\n";
}
}
function report(){
echo "Tests Run:\t".$this->tests."\nTests Failed:\t".$this->fails;
}
}