Kaynağa Gözat

Removed the require_once not used CT#191

Arthur Portugal 15 yıl önce
ebeveyn
işleme
fe5ada5207
2 değiştirilmiş dosya ile 39 ekleme ve 39 silme
  1. 5 7
      tests/setup.inc.php
  2. 34 32
      tests/teardown.inc.php

+ 5 - 7
tests/setup.inc.php

@@ -8,9 +8,8 @@
 *
 *
 *	It load:
 *	It load:
 *	- require_once
 *	- require_once
-*	- constructs
 *   - creation course
 *   - creation course
-*	- session
+*	- sessions
 *	- api_allow_edit
 *	- api_allow_edit
 *	- api_session
 *	- api_session
 *
 *
@@ -25,6 +24,7 @@
  * 		 if these are really configuration then we can make require_once in each tests.
  * 		 if these are really configuration then we can make require_once in each tests.
  * @todo use this file to load the setup in each file test.
  * @todo use this file to load the setup in each file test.
  * @todo check for duplication of require with test_suite.php
  * @todo check for duplication of require with test_suite.php
+ * @author aportugal
  */
  */
 /*
 /*
 ==============================================================================
 ==============================================================================
@@ -95,9 +95,9 @@ ob_end_clean();
 	Table definitions
 	Table definitions
 -----------------------------------------------------------
 -----------------------------------------------------------
 */
 */
-$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
-$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
-$course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY);
+$table_course 		= Database::get_main_table(TABLE_MAIN_COURSE);
+$course_table 		= Database::get_main_table(TABLE_MAIN_COURSE);
+$course_cat_table 	= Database::get_main_table(TABLE_MAIN_CATEGORY);
 
 
 /*
 /*
 ==============================================================================
 ==============================================================================
@@ -193,5 +193,3 @@ $_SESSION['show'] = showall;
 -----------------------------------------------------------
 -----------------------------------------------------------
 */  
 */  
 $_user['user_id'] = $_SESSION['_user']['user_id'];
 $_user['user_id'] = $_SESSION['_user']['user_id'];
-
-

+ 34 - 32
tests/teardown.inc.php

@@ -17,6 +17,7 @@
 *
 *
 *	@todo rewrite code to separate display, logic, database code
 *	@todo rewrite code to separate display, logic, database code
 *	@package chamilo.main
 *	@package chamilo.main
+*	@author aportugal
 ==============================================================================
 ==============================================================================
 */
 */
 
 
@@ -27,19 +28,19 @@
  * @todo check for duplication of require with test_suite.php
  * @todo check for duplication of require with test_suite.php
  */
  */
  
  
-/*
------------------------------------------------------------
-	Included libraries
------------------------------------------------------------
-*/
-require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
-
 /*
 /*
 ==============================================================================
 ==============================================================================
 		MAIN CODE
 		MAIN CODE
 ==============================================================================
 ==============================================================================
 */
 */
 $code = 'COURSETEST';
 $code = 'COURSETEST';
+
+/*
+-----------------------------------------------------------
+	Delete the course
+-----------------------------------------------------------
+*/
+
 $res = CourseManager::delete_course($code);
 $res = CourseManager::delete_course($code);
 $path = api_get_path(SYS_PATH).'archive';
 $path = api_get_path(SYS_PATH).'archive';
 if ($handle = opendir($path)) {
 if ($handle = opendir($path)) {
@@ -52,24 +53,31 @@ if ($handle = opendir($path)) {
 	}
 	}
 	closedir($handle);
 	closedir($handle);
 }
 }
-	
-	
-	
-	
-	
-		$dirname = api_get_path(SYS_LANG_PATH);
-		$perm_dir = substr(sprintf('%o', fileperms($dirname)), -4);
-		if ($perm_dir != '0777') {
-			$msg = "Error";
-			$this->assertTrue(is_string($msg));
-		} else {
-			$path = $dirname.'upload';
-			$filemode = '0777';
-			$res = api_chmod_R($path, $filemode);
-			unlink($path);
-			$this->assertTrue($res || IS_WINDOWS_OS); // We know, it does not work for Windows.
-		}
-	/*	
+
+/*
+-----------------------------------------------------------
+	Check api session destroy
+-----------------------------------------------------------
+*/
+
+if (!headers_sent()) {
+	$res=api_session_destroy();
+}
+
+/*
+$dirname = api_get_path(SYS_LANG_PATH);
+$perm_dir = substr(sprintf('%o', fileperms($dirname)), -4);
+if ($perm_dir != '0777') {
+	$msg = "Error";
+	$this->assertTrue(is_string($msg));
+} else {
+	$path = $dirname.'upload';
+	$filemode = '0777';
+	$res = api_chmod_R($path, $filemode);
+	unlink($path);
+	}
+
+		
 		function testApiIsAllowed(){
 		function testApiIsAllowed(){
 	    global $_course, $_user;
 	    global $_course, $_user;
 	  	$tool= 'full';
 	  	$tool= 'full';
@@ -147,13 +155,7 @@ if ($handle = opendir($path)) {
 		ob_end_clean();
 		ob_end_clean();
 	}
 	}
 	
 	
-	function testApiSessionDestroy(){
-		 if (!headers_sent()) {
-			$res=api_session_destroy();
-		 }
-		$this->assertTrue(is_null($res));
-		//var_dump($res);
-	}
+	
 	
 	
 		function testApiSessionStart(){
 		function testApiSessionStart(){
 		if (!headers_sent()) {
 		if (!headers_sent()) {