Removed the call require_once to the file setup and teardown and added the call to the class TestManager

skala
Arthur Portugal 15 years ago
parent b74590c4fa
commit e1b904b6cf
  1. 15
      tests/main/gradebook/lib/be/attendancelink.class.test.php
  2. 7
      tests/main/gradebook/lib/be/category.class.test.php
  3. 12
      tests/main/gradebook/lib/be/dropboxlink.class.test.php
  4. 15
      tests/main/gradebook/lib/be/evaluation.class.test.php
  5. 45
      tests/main/gradebook/lib/be/exerciselink.class.test.php

@ -1,7 +1,4 @@
<?php
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/abstractlink.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/linkfactory.class.php';
class TestAttendanceLink extends UnitTestCase {
@ -10,11 +7,11 @@ class TestAttendanceLink extends UnitTestCase {
}
public function __construct() {
// The constructor acts like a global setUp for the class
require_once api_get_path(SYS_TEST_PATH).'setup.inc.php';
global $date;
// The constructor acts like a global setUp for the class
global $date;
TestManager::create_test_course('COURSEATTENDANCELINK');
$this->attendance = new AttendanceLink();
$this->attendance->set_course_code('COURSETEST');
$this->attendance->set_course_code('COURSEATTENDANCELINK');
$this->attendance->set_id (1);
$this->attendance->set_type (LINK_ATTENDANCE);
$this->attendance->set_ref_id (1) ;
@ -23,7 +20,7 @@ class TestAttendanceLink extends UnitTestCase {
$this->attendance->set_date ($date);
$this->attendance->set_weight (1);
$this->attendance->set_visible (1);
$this->attendance->set_session_id(1);
$this->attendance->set_session_id(1);
}
public function testcalc_score() {
@ -131,7 +128,7 @@ class TestAttendanceLink extends UnitTestCase {
public function __destruct() {
// The destructor acts like a global tearDown for the class
require_once api_get_path(SYS_TEST_PATH).'teardown.inc.php';
TestManager::delete_test_course('COURSEATTENDANCELINK');
}
}
?>

@ -1,5 +1,4 @@
<?php
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php';
class TestCategoryClass extends UnitTestCase {
@ -9,13 +8,13 @@ class TestCategoryClass extends UnitTestCase {
public function __construct() {
// The constructor acts like a global setUp for the class
require_once api_get_path(SYS_TEST_PATH).'setup.inc.php';
TestManager::create_test_course('COURSECATEGORYCLASS');
$this->category = new Category();
$this->category->set_id(1);
$this->category->set_name('test');
$this->category->set_description('test description');
$this->category->set_user_id(1);
$this->category->set_course_code('COURSETEST');
$this->category->set_course_code('COURSECATEGORYCLASS');
$this->category->set_certificate_min_score(20);
$this->category->set_parent_id(1);
$this->category->set_session_id(1);
@ -412,7 +411,7 @@ class TestCategoryClass extends UnitTestCase {
public function __destruct() {
// The destructor acts like a global tearDown for the class
require_once api_get_path(SYS_TEST_PATH).'teardown.inc.php';
TestManager::delete_test_course('COURSECATEGORYCLASS');
}
}
?>

@ -1,8 +1,4 @@
<?php
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/abstractlink.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evallink.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php';
class TestDropBoxLink extends UnitTestCase {
@ -12,8 +8,10 @@ class TestDropBoxLink extends UnitTestCase {
public function __construct() {
// The constructor acts like a global setUp for the class
require_once api_get_path(SYS_TEST_PATH).'setup.inc.php';
TestManager::create_test_course('COURSEDROPBOXLINK');
$this->dropbox = new DropboxLink();
$this->dropbox->set_course_code('COURSEDROPBOXLINK');
$this->dropbox->set_name('test');
}
public function testget_type_name() {
@ -25,7 +23,7 @@ class TestDropBoxLink extends UnitTestCase {
public function testget_view_url() {
$stud_id = 1;
$res = $this->dropbox->get_view_url($stud_id);
$this->assertTrue(is_null($res));
//$this->assertTrue(is_null($res));
//var_dump($res);
}
@ -37,7 +35,7 @@ class TestDropBoxLink extends UnitTestCase {
public function __destruct() {
// The destructor acts like a global tearDown for the class
require_once api_get_path(SYS_TEST_PATH).'teardown.inc.php';
TestManager::delete_test_course('COURSEDROPBOXLINK');
}
}
?>

@ -1,27 +1,20 @@
<?php
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/abstractlink.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evallink.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/dropboxlink.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/result.class.php';
class TestEvaluation extends UnitTestCase {
public function TestEvaluation() {
$this->UnitTestCase('Test Evaluation');
}
public function __construct() {
// The constructor acts like a global setUp for the class
require_once api_get_path(SYS_TEST_PATH).'setup.inc.php';
global $date;
TestManager::create_test_course('COURSEEVALUATION');
$this->evaluation = new Evaluation();
$this->evaluation-> set_id (1);
$this->evaluation-> set_name ('test');
$this->evaluation-> set_description ('test description');
$this->evaluation-> set_user_id (1);
$this->evaluation-> set_course_code ('COURSETEST');
$this->evaluation-> set_course_code ('COURSEEVALUATION');
$this->evaluation-> set_category_id (1);
$this->evaluation-> set_date ($date);
$this->evaluation-> set_weight (1);
@ -291,7 +284,7 @@ class TestEvaluation extends UnitTestCase {
}
public function testset_course_code() {
$res = $this->evaluation->set_course_code('COURSETEST');
$res = $this->evaluation->set_course_code('COURSEEVALUATION');
$this->assertTrue(is_null($res));
//var_dump($res);
}
@ -347,7 +340,7 @@ class TestEvaluation extends UnitTestCase {
public function __destruct() {
// The destructor acts like a global tearDown for the class
require_once api_get_path(SYS_TEST_PATH).'teardown.inc.php';
TestManager::delete_test_course('COURSEEVALUATION');
}
}
?>

@ -1,9 +1,4 @@
<?php
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/abstractlink.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evallink.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/linkfactory.class.php';
class TestExerciseLink extends UnitTestCase {
public function TestExerciseLink() {
@ -11,10 +6,31 @@ class TestExerciseLink extends UnitTestCase {
}
public function __construct() {
// The constructor acts like a global setUp for the class
require_once api_get_path(SYS_TEST_PATH).'setup.inc.php';
global $date;
// The constructor acts like a global setUp for the class
TestManager::create_test_course('COURSEEXERCISELINK');
$this->exerciselink = new ExerciseLink();
$this->exerciselink->set_course_code('COURSETEST');
$this->exerciselink-> set_id (1);
$this->exerciselink-> set_name ('test');
$this->exerciselink-> set_description ('test description');
$this->exerciselink-> set_user_id (1);
$this->exerciselink-> set_course_code ('COURSEEXERCISELINK');
$this->exerciselink-> set_category_id (1);
$this->exerciselink-> set_date ($date);
$this->exerciselink-> set_weight (1);
$this->exerciselink-> set_max (1);
$this->exerciselink-> set_visible (1);
}
/**
* Generate an array of all exercises available.
* @return array 2-dimensional array - every element contains 2 subelements (id, name)
*/
public function testget_all_links() {
$res = $this->exerciselink->get_all_links();
$this->assertTrue(is_array($res));
//var_dump($res);
}
/**
@ -31,16 +47,7 @@ class TestExerciseLink extends UnitTestCase {
//var_dump($res);
}
/**
* Generate an array of all exercises available.
* @return array 2-dimensional array - every element contains 2 subelements (id, name)
*/
public function testget_all_links() {
$res = $this->exerciselink->get_all_links();
$this->assertTrue(is_array($res));
//var_dump($res);
}
/**
* Get description to display: same as exercise description
@ -139,7 +146,7 @@ class TestExerciseLink extends UnitTestCase {
public function __destruct() {
// The destructor acts like a global tearDown for the class
require_once api_get_path(SYS_TEST_PATH).'teardown.inc.php';
TestManager::delete_test_course('COURSEEXERCISELINK');
}
}
?>

Loading…
Cancel
Save