From e63720653aec663c1acc30d985b860a6cb8f6a45 Mon Sep 17 00:00:00 2001 From: Ricardo Rodriguez Date: Fri, 14 Aug 2009 11:28:49 -0500 Subject: [PATCH 1/4] Added new require_once to the test function survey with the api_get_path(SYS_CODE_PATH) --- tests/all.test2.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/all.test2.php b/tests/all.test2.php index c2897dc4e9..e4878d1e0d 100644 --- a/tests/all.test2.php +++ b/tests/all.test2.php @@ -8,6 +8,9 @@ require_once('simpletest/mock_objects.php'); require_once('simpletest/autorun.php'); require_once(api_get_path(SYS_CODE_PATH).'admin/calendar.lib.php'); require_once(api_get_path(SYS_CODE_PATH).'admin/statistics/statistics.lib.php'); +require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php'); +require_once(api_get_path(SYS_CODE_PATH).'/survey/survey.lib.php'); + $_SESSION['_user']['user_id'] = 1; $_user= 1; @@ -23,10 +26,12 @@ class AllTests2 extends TestSuite { //$this->addTestFile(dirname(__FILE__).'/main/auth/openid/openid.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/chat/chat_functions.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/conference/get_translation.lib.test.php'); + //$this->addTestFile(dirname(__FILE__).'/main/install/install_upgrade_.lib.test.php'); + $this->addTestFile(dirname(__FILE__).'/main/survey/survey.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/exercice/hotpotatoes.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/newscorm/scorm.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/user/userInfoLib.test.php'); - $this->addTestFile(dirname(__FILE__).'/main/webservices/user_import/import.lib.test.php'); + //$this->addTestFile(dirname(__FILE__).'/main/webservices/user_import/import.lib.test.php'); From 2bebc563e44b2c69cc4861863a3cbaab0ae91bb3 Mon Sep 17 00:00:00 2001 From: Ricardo Rodriguez Date: Fri, 14 Aug 2009 13:07:38 -0500 Subject: [PATCH 2/4] update and refreshing file test function install_upgrade.lib.test.php --- tests/main/install/install_upgrade.lib.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/main/install/install_upgrade.lib.test.php b/tests/main/install/install_upgrade.lib.test.php index 57a9c32bb1..04a143f1f8 100644 --- a/tests/main/install/install_upgrade.lib.test.php +++ b/tests/main/install/install_upgrade.lib.test.php @@ -61,7 +61,7 @@ class TestInstallUpgrade extends UnitTestCase{ * Call to undefined function trueFalse() in * /var/www/dokeos1861/main/install/install_upgrade.lib.php on line 192 */ - /*public function testWriteDokeosConfigFile(){ + /* public function testWriteDokeosConfigFile(){ global $dbHostForm; global $dbUsernameForm; global $dbPassForm; From 28e2fec76f2fc31238634f77f57993a361a9d375 Mon Sep 17 00:00:00 2001 From: Ricardo Rodriguez Date: Fri, 14 Aug 2009 18:04:20 -0500 Subject: [PATCH 3/4] Added new test function with new class --- tests/main/survey/survey.lib.test.php | 94 ++++++++++++++++++++++++--- 1 file changed, 86 insertions(+), 8 deletions(-) diff --git a/tests/main/survey/survey.lib.test.php b/tests/main/survey/survey.lib.test.php index b30af49fd8..7461c689db 100644 --- a/tests/main/survey/survey.lib.test.php +++ b/tests/main/survey/survey.lib.test.php @@ -4,23 +4,36 @@ Mock::generate('Display'); $config['survey']['debug'] = false; require_once(api_get_path(LIBRARY_PATH).'add_course.lib.inc.php'); + class TestSurvey extends UnitTestCase { public $smanager; public $squestion; + public $syesno; + public $multiplechoice; + public $personality; + public $multipleresponse; public function TestSurvey() { $this->UnitTestCase(''); } public function setUp() { - $this-> smanager = new survey_manager(); - $this-> squestion = new question(); + $this->smanager = new survey_manager(); + $this->squestion = new question(); + $this->syesno = new yesno(); + $this->smultiplechoice = new multiplechoice(); + $this->spersonality = new personality(); + $this->smultipleresponse = new multipleresponse(); } public function tearDown() { $this-> smanager = null; $this-> squestion = null; + $this-> syesno = null; + $this->smultiplechoice = null; + $this->personality = null; + $this->multipleresponse = null; } /* public function testGetSurvey() { @@ -275,7 +288,7 @@ class TestSurvey extends UnitTestCase { //var_dump($result); //var_dump($res); } - + /* public function testDeleteSharedSurveyQuestion(){ $instans = new MockDatabase(); $survey_id=1; @@ -394,7 +407,7 @@ class TestSurvey extends UnitTestCase { //var_dump($result); //var_dump($sql); } - +*/ public function testCreateForm(){ $instans = new MockDisplay(); global $charset; @@ -412,10 +425,9 @@ class TestSurvey extends UnitTestCase { public function testRenderForm(){ ob_start(); - $res = $this->squestion->render_form(); + $this->squestion->render_form(); ob_end_clean(); - $this->assertTrue(is_null($res)); - $this->assertNull($res); + $this->assertNotNull($this->squestion->html); //var_dump($res); } @@ -437,10 +449,76 @@ class TestSurvey extends UnitTestCase { $form_content['answers'] =array(); $res = $this->squestion->add_remove_buttons($form_content); $this->assertTrue($res); + //var_dump($res); } - + public function testRenderQuestion(){ + $form_content=array(''); + $res = $this->squestion->render_question($form_content); + $this->assertNull($res); + $this->assertTrue(is_null($res)); + //var_dump($res); + } + public function testCreateForm1(){ + $form_content=array(''); + $this->syesno->create_form($form_content); + $this->assertNotNull($this->syesno->html); + } + + public function testRenderQuestion1(){ + ob_start(); + $form_content['options']=array(''); + $answers=array(); + $this->syesno->render_question($form_content,$answers); + ob_end_clean(); + $this->assertNotNull($this->syesno->html); + } + + public function testCreateForm2(){ + global $charset; + $form_content=array(''); + $this->smultiplechoice->create_form($form_content); + $this->assertNotNull($this->smultiplechoice->html); + $this->assertTrue(!is_null(html)); + } + /** + * @todo it would make more sense to consider yesno as a + * special case of multiplechoice and not the other way + * around + */ + + public function testRenderQuestion2(){ + $form_content= array(''); + $answers=array(''); + $this->smultiplechoice->render_question($form_content, $answers); + $this->assertNull($this->smultiplechoice->html); + } + + public function testCreateForm3(){ + $form_content['answers']=array(); + $count= 0; + $this->spersonality; + $this->spersonality->create_form($form_content); + $this->assertNotNull($this->spersonality->html); + $this->assertTrue($this->spersonality->html); + } + + public function testRenderQuestion3(){ + $form_content=array(); + $answers=array(); + $this->spersonality->render_question($form_content,$answers); + $this->assertNull($this->spersonality->html); + $this->assertFalse($this->spersonality->html); + } + + public function testCreateForm4(){ + global $charset; + $form_content=array(); + $this->smultipleresponse->create_form($form_content); + $this->assertNotNull($this->smultipleresponse->html); + $this->assertTrue($this->smultipleresponse->html); + } } From 8dcaa9af8e5ac5cd34963fb6c5c1686a9ae5184e Mon Sep 17 00:00:00 2001 From: Ricardo Rodriguez Date: Fri, 14 Aug 2009 18:09:20 -0500 Subject: [PATCH 4/4] Addes new files test --- tests/all.test2.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/all.test2.php b/tests/all.test2.php index e4878d1e0d..5ee934d169 100644 --- a/tests/all.test2.php +++ b/tests/all.test2.php @@ -10,6 +10,7 @@ require_once(api_get_path(SYS_CODE_PATH).'admin/calendar.lib.php'); require_once(api_get_path(SYS_CODE_PATH).'admin/statistics/statistics.lib.php'); require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php'); require_once(api_get_path(SYS_CODE_PATH).'/survey/survey.lib.php'); +require_once(api_get_path(SYS_CODE_PATH).'/install/install_upgrade.lib.php'); $_SESSION['_user']['user_id'] = 1; @@ -26,18 +27,13 @@ class AllTests2 extends TestSuite { //$this->addTestFile(dirname(__FILE__).'/main/auth/openid/openid.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/chat/chat_functions.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/conference/get_translation.lib.test.php'); - //$this->addTestFile(dirname(__FILE__).'/main/install/install_upgrade_.lib.test.php'); + //$this->addTestFile(dirname(__FILE__).'/main/install/install_upgrade.lib.test.php'); $this->addTestFile(dirname(__FILE__).'/main/survey/survey.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/exercice/hotpotatoes.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/newscorm/scorm.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/user/userInfoLib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/webservices/user_import/import.lib.test.php'); - - - - - - } + } } $test = &new AllTests2(); //$test-> run( new HtmlReporter());