Commit f0d4e0fd663f1e0ea9ff2906761f39416bdbca9c

Authored by michael
1 parent 97b59b4c

initial revision of unit test page


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1757 c91229c3-7414-0410-bfa2-8a42b809f60b
tests/dashboard/DashboardNews.php 0 → 100644
  1 +<?php
  2 +require_once("../../config/dmsDefaults.php");
  3 +require_once("$default->fileSystemRoot/lib/dashboard/DashboardNews.inc");
  4 +
  5 +/**
  6 + * $Id$
  7 + *
  8 + * Unit Tests for lib/dashboard/DashboardNews.inc
  9 + * includes tests for:
  10 + * o creation of document object
  11 + * o setting/getting of values
  12 + * o storing of object
  13 + * o updating of object
  14 + * o deletion of object
  15 + *
  16 + * Licensed under the GNU GPL. For full terms see the file COPYING.
  17 + *
  18 + * @version $Revision$
  19 + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa
  20 + * @package tests.dashboard
  21 + */
  22 +
  23 +//if (checkSession()) {
  24 +
  25 + // test creation of a dashboard news item
  26 + echo "<b>Testing dashboard news creation</b><br>";
  27 + // convert the image to a string
  28 + $sTestImage = "c:\test.jpg";
  29 + // TODO: implement
  30 + //$sImgStr = DashboardNews::imageToString($sTestImage);
  31 + $sImgStr = $sTestImage;
  32 + $oNews = & new DashboardNews("test synopsis", "test body", 1, $sImgStr);
  33 + if (isset($oNews)) {
  34 + echo "Passed dashboard news creation test<br><br>";
  35 +
  36 + echo "<b>Testing setting and getting of dashboard news values</b><br>";
  37 + echo "Current dashboard synopsis: " . $oNews->getSynopsis() . "<br>";
  38 + echo "Setting synopsis to: blah<br>";
  39 + $oNews->setSynopsis("blah");
  40 + echo "New synopsis: " . $oNews->getSynopsis() . "<br><br>";
  41 +
  42 + echo "Current news body: " . $oNews->getBody() . "<br>";
  43 + echo "Setting news body to: 'blurg'<br>";
  44 + $oNews->setBody("blurg");
  45 + echo "New news body: " . $oNews->getBody() . "<br><br>";
  46 +
  47 + echo "Current news img: " . $oNews->getImage() . "<br>";
  48 + echo "Setting news img to 'foo'<br>";
  49 + $oNews->setImage('foo');
  50 + echo "New news img: " . $oNews->getImage() . "<br><br>";
  51 +
  52 + echo "Current new rank: " . $oNews->getRank() . "<br>";
  53 + echo "Set new rank to 5<br>";
  54 + $oNews->setRank(5);
  55 + echo "New new rank: " . $oNews->getRank() . "<br><br>";
  56 +
  57 + echo "<b>Testing dashboard news storage</b><br>";
  58 + if ($oNews->create()) {
  59 + echo "Passed dashboard news storage test<br><br>";
  60 +
  61 + echo "<b>Testing dashboard news update</b><br>";
  62 + echo "setting attributes to ('a','b','c',10)";
  63 + $oNews->setSynopsis("a");
  64 + $oNews->setBody("b");
  65 + $oNews->setImage("c");
  66 + $oNews->setRank(10);
  67 + if ($oNews->update()) {
  68 + echo "Passed dashboard news update test<br>";
  69 + } else {
  70 + echo "Failed dashboard news update test: " . $_SESSION["errorMessage"];
  71 + }
  72 +
  73 + echo "<b>Testing dashboard news deletion</b><br>";
  74 + if ($oNews->delete()) {
  75 + echo "Passed dashboard news deletion test<br>";
  76 + } else {
  77 + echo "Failed dashboard news deletion test: " . $_SESSION["errorMessage"];
  78 + }
  79 +
  80 + } else {
  81 + echo "Failed dashboard news storage test: " . $_SESSION["errorMessage"] . "<br>";
  82 + echo "Tests NOT run: (a)dashboard news deletion (b) dashboard news update<br>";
  83 + }
  84 + } else {
  85 + echo "Failed dashboard news creation test<br>";
  86 + echo "Tests NOT run: (a)getting and setting (b)dashboard news storage (c)dashboard news deletion<br>";
  87 + }
  88 +//}
  89 +?>
... ...