DashboardNews.php
3.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
95
96
97
98
99
<?php
require_once("../../config/dmsDefaults.php");
require_once("$default->fileSystemRoot/lib/dashboard/DashboardNews.inc");
/**
* $Id$
*
* Unit Tests for lib/dashboard/DashboardNews.inc
* includes tests for:
* o creation of document object
* o setting/getting of values
* o storing of object
* o updating of object
* o deletion of object
*
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* @version $Revision$
* @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa
* @package tests.dashboard
*/
$sTestImage = "c:/test.gif";
if (isset($fViewImage)) {
$oNews = & new DashboardNews("test synopsis", "test body", 1, $sTestImage);
$oNews->displayImage();
} else {
// test creation of a dashboard news item
echo "<b>Testing dashboard news creation</b><br>";
$oNews = & new DashboardNews("test synopsis", "test body", 1);
if (isset($oNews)) {
echo "Passed dashboard news creation test<br><br>";
echo "<b>Testing image retrieval</b><br>";
echo "<img src=\"" . $_SERVER['PHP_SELF'] . "?fViewImage\"><br>";
echo "<b>Testing setting and getting of dashboard news values</b><br>";
echo "Current dashboard synopsis: " . $oNews->getSynopsis() . "<br>";
echo "Setting synopsis to: blah<br>";
$oNews->setSynopsis("blah");
echo "New synopsis: " . $oNews->getSynopsis() . "<br><br>";
echo "Current news body: " . $oNews->getBody() . "<br>";
echo "Setting news body to: 'blurg'<br>";
$oNews->setBody("blurg");
echo "New news body: " . $oNews->getBody() . "<br><br>";
echo "Current news rank: " . $oNews->getRank() . "<br>";
echo "Set new rank to 5<br>";
$oNews->setRank(5);
echo "New new rank: " . $oNews->getRank() . "<br><br>";
echo "Current image size: " . $oNews->getImageSize() . "<br>";
echo "Current image mime type id: " . $oNews->getImageMimeTypeID() . "<br>";
echo "<b>Testing dashboard news storage</b><br>";
if ($oNews->create()) {
echo "Passed dashboard news storage test<br><br>";
echo "<b>Testing dashboard news update</b><br>";
echo "setting attributes to ('a','b','c:\sample.jpg',10)";
$oNews->setSynopsis("a");
$oNews->setBody("b");
//$oNews->setImageFile("c:/test.gif");
$oNews->setRank(10);
if ($oNews->update()) {
echo "Passed dashboard news update test<br>";
echo "<b>Testing dashboard news retrieval</b><br>";
$oRetrievedNews = DashboardNews::get($oNews->getID());
if ($oRetrievedNews) {
echo "Passed dashboard news retrieval test<br><br>";
echo "id=" . $oRetrievedNews->getID() . "<br>";
}
} else {
echo "Failed dashboard news update test: " . $_SESSION["errorMessage"];
}
/*
echo "<b>Testing dashboard news deletion</b><br>";
if ($oNews->delete()) {
echo "Passed dashboard news deletion test<br>";
} else {
echo "Failed dashboard news deletion test: " . $_SESSION["errorMessage"];
}
*/
} else {
echo "Failed dashboard news storage test: " . $_SESSION["errorMessage"] . "<br>";
echo "Tests NOT run: (a)dashboard news deletion (b) dashboard news update<br>";
}
} else {
echo "Failed dashboard news creation test<br>";
echo "Tests NOT run: (a)getting and setting (b)dashboard news storage (c)dashboard news deletion<br>";
}
}
?>