MDL-53000 mod_assign: Unit tests for get_file_areas

This commit is contained in:
Juan Leyva
2016-04-06 12:56:58 +02:00
parent 7d3472a753
commit bc1ded6ef4
+43
View File
@@ -2329,5 +2329,48 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
$this->assertTrue(in_array($this->extrastudents[0]->id, $allgroupmembers));
$this->assertTrue(in_array($this->extrastudents[1]->id , $allgroupmembers));
}
/**
* Test get plugins file areas
*/
public function test_get_plugins_file_areas() {
$this->setUser($this->editingteachers[0]);
$assign = $this->create_instance();
// Test that all the submission and feedback plugins are returning the expected file aras.
$usingfilearea = 0;
foreach ($assign->get_submission_plugins() as $plugin) {
$type = $plugin->get_type();
$fileareas = $plugin->get_file_areas();
if ($type == 'onlinetext') {
$this->assertEquals(array('submissions_onlinetext' => 'Online text'), $fileareas);
$usingfilearea++;
} else if ($type == 'file') {
$this->assertEquals(array('submission_files' => 'File submissions'), $fileareas);
$usingfilearea++;
} else {
$this->assertEmpty($fileareas);
}
}
$this->assertEquals(2, $usingfilearea);
$usingfilearea = 0;
foreach ($assign->get_feedback_plugins() as $plugin) {
$type = $plugin->get_type();
$fileareas = $plugin->get_file_areas();
if ($type == 'editpdf') {
$this->assertEquals(array('download' => 'Annotate PDF'), $fileareas);
$usingfilearea++;
} else if ($type == 'file') {
$this->assertEquals(array('feedback_files' => 'Feedback files'), $fileareas);
$usingfilearea++;
} else {
$this->assertEmpty($fileareas);
}
}
$this->assertEquals(2, $usingfilearea);
}
}