From d29fcf035fcf2fd1039f69a1b0a88c1729a9742d Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Sun, 4 Apr 2010 18:07:08 -0500 Subject: [PATCH] Testing - Fixed a few tests for main library --- tests/main/inc/lib/main_api.lib.test.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) mode change 100644 => 100755 tests/main/inc/lib/main_api.lib.test.php diff --git a/tests/main/inc/lib/main_api.lib.test.php b/tests/main/inc/lib/main_api.lib.test.php old mode 100644 new mode 100755 index a6afdd95a8..93872c9dd9 --- a/tests/main/inc/lib/main_api.lib.test.php +++ b/tests/main/inc/lib/main_api.lib.test.php @@ -106,8 +106,8 @@ class TestMainApi extends UnitTestCase { } function testApiGetCourseIdReturnFalseWhenOutOfCourseIdContext(){ - $res =api_get_course_id(); - $this->assertTrue($res); + $res = api_get_course_id(); + $this->assertEqual($res,-1); } function testApiGetCoursePathReturnFalseWhenOutOfCoursePathContext(){ @@ -186,11 +186,10 @@ class TestMainApi extends UnitTestCase { //var_dump($res); } - function testApiAddUrlParam() { - global $url , $param ; - $res=api_add_url_param($url, $param, $filter_xss=true); - $this->assertTrue(is_null($res)); - //var_dump($res); + function testApiAddUrlParamReturnsUrlWhenNoParam() { + global $url; + $res=api_add_url_param($url, null, $filter_xss=true); + $this->assertEqual($res,$url); } function testApiGeneratePassword() { @@ -329,11 +328,9 @@ class TestMainApi extends UnitTestCase { } } - function testApiIsCourseAdmin() { + function testApiIsCourseAdminIsFalseWhenNoCourseContextDefined() { $res=api_is_course_admin(); - if(!is_numeric($res)) { - $this->assertTrue(is_null($res)); - } + $this->assertFalse($res); } function testApiIsCourseCoach() { @@ -609,13 +606,12 @@ class TestMainApi extends UnitTestCase { $dirname = api_get_path(SYS_LANG_PATH); $perm_dir = substr(sprintf('%o', fileperms($dirname)), -4); if ($perm_dir != '0777') { + // haha! This one is too good to remove... (for now) $msg = "Error"; $this->assertTrue(is_string($msg)); } else { - $path = $dirname.'upload'; $filemode = '0777'; - $res = api_chmod_R($path, $filemode); - unlink($path); + $res = api_chmod_R($dirname, $filemode); $this->assertTrue($res || IS_WINDOWS_OS); // We know, it does not work for Windows. } }