From 25fd2a1dcbec03c210cec582dbec774136b9a30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Fri, 19 Jan 2007 01:41:01 +0000 Subject: [PATCH] Unit test for url::update() --- unit_test/run_tests.php | 2 ++ unit_test/test_url.php | 73 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 unit_test/test_url.php diff --git a/unit_test/run_tests.php b/unit_test/run_tests.php index a33e830..1ab140f 100644 --- a/unit_test/run_tests.php +++ b/unit_test/run_tests.php @@ -22,4 +22,6 @@ echo "\n"; include_once("test_error_log.php"); echo "\n"; include_once("test_filter.php"); +echo "\n"; +include_once("test_url.php"); ?> diff --git a/unit_test/test_url.php b/unit_test/test_url.php new file mode 100644 index 0000000..9303e1a --- /dev/null +++ b/unit_test/test_url.php @@ -0,0 +1,73 @@ +login($test_email, $test_password) != SUCCESS) + { + echo "Received '$retval' instead of SUCCESS('".SUCCESS."')."; + return FALSE; + } + + $iAppId = 655000; + $iVersionId = 655000; + + $oUser->addPriv("admin"); + + $oUrl = new Url(); + $oUrl->create("Bad description", "http://www.badurl.com/", $iVersionId, $iAppId, TRUE); + + $sDescriptionNew = "Good description"; + $sUrlNew = "http://www.goodurl.com/"; + $iAppIdNew = $iAppId + 1; + $iVersionIdNew = $iVersionId + 1; + + $oUrl->update($sDescriptionNew, $sUrlNew, $iVersionIdNew, $iAppIdNew, TRUE); + + if($oUrl->sDescription != $sDescriptionNew) + { + echo "Description is '$oUrl->sDescription' instead of '$sDescriptionNew'\n"; + $bSuccess = false; + } + + if($oUrl->sUrl != $sUrlNew) + { + echo "Url is '$oUrl->sUrl' instead of '$sUrlNew'\n"; + $bSuccess = false; + } + + if($oUrl->iVersionId != $iVersionIdNew) + { + echo "VersionId is '$oUrl->iVersionId' instead of '$iVersionIdNew'\n"; + $bSuccess = false; + } + + if($oUrl->iAppId != $iAppIdNew) + { + echo "AppId is '$oUrl->iAppId' instead of '$iAppIdNew'\n"; + $bSuccess = false; + } + + $oUrl->delete(TRUE); + + return $bSuccess; +} + +if(!test_url_update()) + echo "test_url_update() failed!\n"; +else + echo "test_url_update() passed\n"; + +?>