forked from PoetOS/moodle-mod_questionnaire
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de2a043
commit a3069f0
Showing
9 changed files
with
231 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,14 +14,7 @@ | |
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* PHPUnit questionnaire generator tests | ||
* | ||
* @package mod_questionnaire | ||
* @copyright 2015 Mike Churchward ([email protected]) | ||
* @author Mike Churchward | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
namespace mod_questionnaire; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
|
@@ -32,10 +25,19 @@ | |
require_once($CFG->dirroot.'/mod/questionnaire/classes/question/question.php'); | ||
|
||
/** | ||
* Unit tests for questionnaire_lib_testcase. | ||
* @group mod_questionnaire | ||
* PHPUnit questionnaire lib tests | ||
* | ||
* @package mod_questionnaire | ||
* @copyright 2015 Mike Churchward ([email protected]) | ||
* @author Mike Churchward | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class mod_questionnaire_lib_testcase extends advanced_testcase { | ||
class lib_test extends \advanced_testcase { | ||
/** | ||
* Test case for the questionnaire_supports function. | ||
* | ||
* @covers ::questionnaire_supports | ||
*/ | ||
public function test_questionnaire_supports() { | ||
$this->assertTrue(questionnaire_supports(FEATURE_BACKUP_MOODLE2)); | ||
$this->assertFalse(questionnaire_supports(FEATURE_COMPLETION_TRACKS_VIEWS)); | ||
|
@@ -49,20 +51,30 @@ public function test_questionnaire_supports() { | |
$this->assertNull(questionnaire_supports('unknown option')); | ||
} | ||
|
||
/** | ||
* Test case for the questionnaire_get_extra_capabilities function. | ||
* | ||
* @covers ::questionnaire_get_extra_capabilities | ||
*/ | ||
public function test_questionnaire_get_extra_capabilities() { | ||
$caps = questionnaire_get_extra_capabilities(); | ||
$this->assertIsArray($caps); | ||
$this->assertEquals(1, count($caps)); | ||
$this->assertEquals('moodle/site:accessallgroups', reset($caps)); | ||
} | ||
|
||
/** | ||
* Test case for the questionnaire_add_instance function. | ||
* | ||
* @covers ::questionnaire_add_instance | ||
*/ | ||
public function test_add_instance() { | ||
$this->resetAfterTest(); | ||
$this->setAdminUser(); | ||
$course = $this->getDataGenerator()->create_course(); | ||
|
||
// Create test data as a record. | ||
$questdata = new stdClass(); | ||
$questdata = new \stdClass(); | ||
$questdata->course = $course->id; | ||
$questdata->coursemodule = ''; | ||
$questdata->name = 'Test questionnaire'; | ||
|
@@ -86,6 +98,11 @@ public function test_add_instance() { | |
$this->assertTrue(questionnaire_add_instance($questdata) > 0); | ||
} | ||
|
||
/** | ||
* Test case for the questionnaire_update_instance function. | ||
* | ||
* @covers ::questionnaire_update_instance | ||
*/ | ||
public function test_update_instance() { | ||
global $DB; | ||
|
||
|
@@ -141,9 +158,10 @@ public function test_update_instance() { | |
$this->assertEquals($qrow->autonum, $questrecord->autonum); | ||
} | ||
|
||
/* | ||
/** | ||
* Need to verify that delete_instance deletes all data associated with a questionnaire. | ||
* | ||
* @covers ::questionnaire_delete_instance | ||
*/ | ||
public function test_delete_instance() { | ||
global $DB; | ||
|
@@ -176,6 +194,11 @@ public function test_delete_instance() { | |
$this->assertEmpty($DB->get_records('event', array("modulename" => 'questionnaire', "instance" => $questionnaire->id))); | ||
} | ||
|
||
/** | ||
* Test case for the questionnaire_user_outline function. | ||
* | ||
* @covers ::questionnaire_user_outline | ||
*/ | ||
public function test_questionnaire_user_outline() { | ||
$this->resetAfterTest(); | ||
$this->setAdminUser(); | ||
|
@@ -196,6 +219,11 @@ public function test_questionnaire_user_outline() { | |
$this->assertEquals('1 '.get_string("response", "questionnaire"), $outline->info); | ||
} | ||
|
||
/** | ||
* Test case for the questionnaire_user_complete function. | ||
* | ||
* @covers ::questionnaire_user_complete | ||
*/ | ||
public function test_questionnaire_user_complete() { | ||
$this->resetAfterTest(); | ||
$this->setAdminUser(); | ||
|
@@ -208,18 +236,33 @@ public function test_questionnaire_user_complete() { | |
$this->expectOutputString(get_string('noresponses', 'questionnaire')); | ||
} | ||
|
||
/** | ||
* Test case for the questionnaire_print_recent_activity function. | ||
* | ||
* @covers ::questionnaire_print_recent_activity | ||
*/ | ||
public function test_questionnaire_print_recent_activity() { | ||
$this->resetAfterTest(); | ||
$this->setAdminUser(); | ||
$this->assertFalse(questionnaire_print_recent_activity(null, null, null)); | ||
} | ||
|
||
/** | ||
* Test case for the questionnaire_grades function. | ||
* | ||
* @covers ::questionnaire_grades | ||
*/ | ||
public function test_questionnaire_grades() { | ||
$this->resetAfterTest(); | ||
$this->setAdminUser(); | ||
$this->assertNull(questionnaire_grades(null)); | ||
} | ||
|
||
/** | ||
* Test case for the questionnaire_get_user_grades function. | ||
* | ||
* @covers ::questionnaire_get_user_grades | ||
*/ | ||
public function test_questionnaire_get_user_grades() { | ||
$this->resetAfterTest(); | ||
$this->setAdminUser(); | ||
|
@@ -238,11 +281,21 @@ public function test_questionnaire_get_user_grades() { | |
$this->assertIsArray($grades); | ||
} | ||
|
||
/** | ||
* Test case for the questionnaire_update_grades function. | ||
* | ||
* @covers ::questionnaire_update_grades | ||
*/ | ||
public function test_questionnaire_update_grades() { | ||
// Don't know how to test this yet! It doesn't return anything. | ||
$this->assertNull(questionnaire_update_grades()); | ||
} | ||
|
||
/** | ||
* Test case for the questionnaire_grade_item_update function. | ||
* | ||
* @covers ::questionnaire_grade_item_update | ||
*/ | ||
public function test_questionnaire_grade_item_update() { | ||
$this->resetAfterTest(); | ||
$this->setAdminUser(); | ||
|
Oops, something went wrong.