diff --git a/admin/tool/cohortroles/tests/api_test.php b/admin/tool/cohortroles/tests/api_test.php
index 27c4cd8227b..2fa061b4ca0 100644
--- a/admin/tool/cohortroles/tests/api_test.php
+++ b/admin/tool/cohortroles/tests/api_test.php
@@ -62,9 +62,10 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
cohort_add_member($this->cohort->id, $this->userassignover->id);
}
-
+ /**
+ * @expectedException required_capability_exception
+ */
public function test_create_cohort_role_assignment_without_permission() {
- $this->setExpectedException('required_capability_exception');
$this->setUser($this->userassignto);
$params = (object) array(
'userid' => $this->userassignto->id,
@@ -74,8 +75,10 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
api::create_cohort_role_assignment($params);
}
+ /**
+ * @expectedException core_competency\invalid_persistent_exception
+ */
public function test_create_cohort_role_assignment_with_invalid_data() {
- $this->setExpectedException('core_competency\invalid_persistent_exception');
$this->setAdminUser();
$params = (object) array(
'userid' => $this->userassignto->id,
@@ -99,6 +102,9 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
$this->assertEquals($result->get_cohortid(), $this->cohort->id);
}
+ /**
+ * @expectedException required_capability_exception
+ */
public function test_delete_cohort_role_assignment_without_permission() {
$this->setAdminUser();
$params = (object) array(
@@ -107,11 +113,13 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
'cohortid' => $this->cohort->id
);
$result = api::create_cohort_role_assignment($params);
- $this->setExpectedException('required_capability_exception');
$this->setUser($this->userassignto);
api::delete_cohort_role_assignment($result->get_id());
}
+ /**
+ * @expectedException dml_missing_record_exception
+ */
public function test_delete_cohort_role_assignment_with_invalid_data() {
$this->setAdminUser();
$params = (object) array(
@@ -120,7 +128,6 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
'cohortid' => $this->cohort->id
);
$result = api::create_cohort_role_assignment($params);
- $this->setExpectedException('dml_missing_record_exception');
api::delete_cohort_role_assignment($result->get_id() + 1);
}
diff --git a/admin/tool/langimport/tests/events_test.php b/admin/tool/langimport/tests/events_test.php
index 0a75b348720..d2164cf443c 100644
--- a/admin/tool/langimport/tests/events_test.php
+++ b/admin/tool/langimport/tests/events_test.php
@@ -56,8 +56,11 @@ class tool_langimport_events_testcase extends advanced_testcase {
$this->assertEquals(context_system::instance(), $event->get_context());
}
+ /**
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'langcode' value must be set to a valid language code
+ */
public function test_langpack_updated_validation() {
- $this->setExpectedException('coding_exception', 'The \'langcode\' value must be set to a valid language code');
\tool_langimport\event\langpack_updated::event_with_langcode('broken langcode');
}
@@ -75,8 +78,11 @@ class tool_langimport_events_testcase extends advanced_testcase {
$this->assertEquals(context_system::instance(), $event->get_context());
}
+ /**
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'langcode' value must be set to a valid language code
+ */
public function test_langpack_installed_validation() {
- $this->setExpectedException('coding_exception', 'The \'langcode\' value must be set to a valid language code');
\tool_langimport\event\langpack_imported::event_with_langcode('broken langcode');
}
@@ -94,8 +100,11 @@ class tool_langimport_events_testcase extends advanced_testcase {
$this->assertEquals(context_system::instance(), $event->get_context());
}
+ /**
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'langcode' value must be set to a valid language code
+ */
public function test_langpack_removed_validation() {
- $this->setExpectedException('coding_exception', 'The \'langcode\' value must be set to a valid language code');
\tool_langimport\event\langpack_removed::event_with_langcode('broken langcode');
}
diff --git a/admin/tool/monitor/tests/generator_test.php b/admin/tool/monitor/tests/generator_test.php
index ca7f0034d6b..7c4ae86587d 100644
--- a/admin/tool/monitor/tests/generator_test.php
+++ b/admin/tool/monitor/tests/generator_test.php
@@ -89,7 +89,7 @@ class tool_monitor_generator_testcase extends advanced_testcase {
$this->assertEquals(0, $subscription->cmid);
// Make sure rule id is always required.
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
unset($record->ruleid);
$monitorgenerator->create_subscription($record);
}
diff --git a/admin/tool/monitor/tests/subscription_test.php b/admin/tool/monitor/tests/subscription_test.php
index 3548c7f563d..b3511b5e846 100644
--- a/admin/tool/monitor/tests/subscription_test.php
+++ b/admin/tool/monitor/tests/subscription_test.php
@@ -42,7 +42,10 @@ class tool_monitor_subscription_testcase extends advanced_testcase {
$sub->id = 100;
$sub->name = 'My test rule';
$sub->courseid = 20;
- $this->subscription = $this->getMock('\tool_monitor\subscription',null, array($sub));
+ $mockbuilder = $this->getMockBuilder('\tool_monitor\subscription');
+ $mockbuilder->setMethods(null);
+ $mockbuilder->setConstructorArgs(array($sub));
+ $this->subscription = $mockbuilder->getMock();
}
/**
@@ -56,10 +59,11 @@ class tool_monitor_subscription_testcase extends advanced_testcase {
/**
* Test for the magic __get method.
+ *
+ * @expectedException coding_exception
*/
public function test_magic_get() {
$this->assertEquals(20, $this->subscription->courseid);
- $this->setExpectedException('coding_exception');
$this->subscription->ruleid;
}
}
diff --git a/admin/tool/uploadcourse/tests/course_test.php b/admin/tool/uploadcourse/tests/course_test.php
index 0b62e87938b..26dc5568a24 100644
--- a/admin/tool/uploadcourse/tests/course_test.php
+++ b/admin/tool/uploadcourse/tests/course_test.php
@@ -35,16 +35,21 @@ global $CFG;
*/
class tool_uploadcourse_course_testcase extends advanced_testcase {
+ /**
+ * @expectedException coding_exception
+ */
public function test_proceed_without_prepare() {
$this->resetAfterTest(true);
$mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
$updatemode = tool_uploadcourse_processor::UPDATE_NOTHING;
$data = array();
$co = new tool_uploadcourse_course($mode, $updatemode, $data);
- $this->setExpectedException('coding_exception');
$co->proceed();
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_proceed_when_prepare_failed() {
$this->resetAfterTest(true);
$mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
@@ -52,7 +57,6 @@ class tool_uploadcourse_course_testcase extends advanced_testcase {
$data = array();
$co = new tool_uploadcourse_course($mode, $updatemode, $data);
$this->assertFalse($co->prepare());
- $this->setExpectedException('moodle_exception');
$co->proceed();
}
@@ -64,7 +68,7 @@ class tool_uploadcourse_course_testcase extends advanced_testcase {
$co = new tool_uploadcourse_course($mode, $updatemode, $data);
$this->assertTrue($co->prepare());
$co->proceed();
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
$co->proceed();
}
diff --git a/admin/tool/uploadcourse/tests/processor_test.php b/admin/tool/uploadcourse/tests/processor_test.php
index 1dd20dc1927..109c2434c23 100644
--- a/admin/tool/uploadcourse/tests/processor_test.php
+++ b/admin/tool/uploadcourse/tests/processor_test.php
@@ -160,6 +160,9 @@ class tool_uploadcourse_processor_testcase extends advanced_testcase {
$this->assertEquals('ID123: Course 1', $c->shortname);
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_empty_csv() {
$this->resetAfterTest(true);
@@ -171,10 +174,12 @@ class tool_uploadcourse_processor_testcase extends advanced_testcase {
$cir->init();
$options = array('mode' => tool_uploadcourse_processor::MODE_CREATE_NEW);
- $this->setExpectedException('moodle_exception');
$p = new tool_uploadcourse_processor($cir, $options, array());
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_not_enough_columns() {
$this->resetAfterTest(true);
@@ -189,7 +194,6 @@ class tool_uploadcourse_processor_testcase extends advanced_testcase {
$cir->init();
$options = array('mode' => tool_uploadcourse_processor::MODE_CREATE_NEW);
- $this->setExpectedException('moodle_exception');
$p = new tool_uploadcourse_processor($cir, $options, array());
}
diff --git a/backup/converter/moodle1/tests/moodle1_converter_test.php b/backup/converter/moodle1/tests/moodle1_converter_test.php
index 32092872164..88681b80802 100644
--- a/backup/converter/moodle1/tests/moodle1_converter_test.php
+++ b/backup/converter/moodle1/tests/moodle1_converter_test.php
@@ -88,18 +88,22 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase {
$this->assertInstanceOf('moodle1_converter', $converter);
}
+ /**
+ * @expectedException moodle1_convert_storage_exception
+ */
public function test_stash_storage_not_created() {
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
- $this->setExpectedException('moodle1_convert_storage_exception');
$converter->set_stash('tempinfo', 12);
}
+ /**
+ * @expectedException moodle1_convert_empty_storage_exception
+ */
public function test_stash_requiring_empty_stash() {
$this->resetAfterTest(true);
$converter = convert_factory::get_converter('moodle1', $this->tempdir);
$converter->create_stash_storage();
$converter->set_stash('tempinfo', 12);
- $this->setExpectedException('moodle1_convert_empty_storage_exception');
try {
$converter->get_stash('anothertempinfo');
@@ -432,6 +436,9 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase {
$this->assertSame(null, $data['nothing']);
}
+ /**
+ * @expectedException convert_path_exception
+ */
public function test_grouped_data_on_nongrouped_convert_path() {
// prepare some grouped data
$data = array(
@@ -457,10 +464,12 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase {
$path = new convert_path('beer_style', '/ROOT/BEER_STYLES/BEER_STYLE');
// an attempt to apply recipes throws exception because we do not expect grouped data
- $this->setExpectedException('convert_path_exception');
$data = $path->apply_recipes($data);
}
+ /**
+ * @expectedException convert_path_exception
+ */
public function test_grouped_convert_path_with_recipes() {
// prepare some grouped data
$data = array(
@@ -488,7 +497,6 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase {
$this->assertEquals('Heineken', $data['beers'][1]['beer']['name']);
// an attempt to provide explicit recipes on grouped elements throws exception
- $this->setExpectedException('convert_path_exception');
$path = new convert_path(
'beer_style', '/ROOT/BEER_STYLES/BEER_STYLE',
array(
@@ -573,7 +581,7 @@ as it is parsed from the backup file.
add_ref('file', 45);
$inforef->add_refs('file', array(46, 47));
// todo test the write_refs() via some dummy xml_writer
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
$inforef->add_ref('unknown_referenced_item_name', 76);
}
}
diff --git a/backup/util/xml/parser/tests/parser_test.php b/backup/util/xml/parser/tests/parser_test.php
index 39bf2d75a7c..7f9ea28b874 100644
--- a/backup/util/xml/parser/tests/parser_test.php
+++ b/backup/util/xml/parser/tests/parser_test.php
@@ -787,7 +787,7 @@ class progressive_parser_test extends advanced_testcase {
* - equal to "value" attribute of the tag (if present)
* - else, equal to tag name
*
- * We pass the whole UnitTestCase object to the processor in order to be
+ * We pass the whole advanced_testcase object to the processor in order to be
* able to perform the tests in the straight in the process
*/
class mock_auto_parser_processor extends progressive_parser_processor {
diff --git a/calendar/tests/externallib_test.php b/calendar/tests/externallib_test.php
index dc5041a49f4..b25406863a9 100644
--- a/calendar/tests/externallib_test.php
+++ b/calendar/tests/externallib_test.php
@@ -131,6 +131,8 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
/**
* Test delete_calendar_events
+ *
+ * @expectedException moodle_exception
*/
public function test_delete_calendar_events() {
global $DB, $USER;
@@ -247,7 +249,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
$groupevent = $this->create_calendar_event('group', $USER->id, 'group', 0, time(), $record);
$this->setGuestUser();
- $this->setExpectedException('moodle_exception');
+
$events = array(
array('eventid' => $siteevent->id, 'repeat' => 0),
array('eventid' => $courseevent->id, 'repeat' => 0),
diff --git a/calendar/tests/ical_test.php b/calendar/tests/ical_test.php
index cfc5bb3523d..2fc3c02b68c 100644
--- a/calendar/tests/ical_test.php
+++ b/calendar/tests/ical_test.php
@@ -45,6 +45,9 @@ class core_calendar_ical_testcase extends advanced_testcase {
require_once($CFG->dirroot . '/calendar/lib.php');
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_calendar_update_subscription() {
$this->resetAfterTest(true);
@@ -71,7 +74,6 @@ class core_calendar_ical_testcase extends advanced_testcase {
$subscription = new stdClass();
$subscription->name = 'awesome4';
- $this->setExpectedException('coding_exception');
calendar_update_subscription($subscription);
}
diff --git a/calendar/tests/rrule_manager_tests.php b/calendar/tests/rrule_manager_tests.php
index 5232ab70ace..a68d6156733 100644
--- a/calendar/tests/rrule_manager_tests.php
+++ b/calendar/tests/rrule_manager_tests.php
@@ -86,22 +86,24 @@ class core_calendar_rrule_manager_testcase extends advanced_testcase {
/**
* Test exception is thrown for invalid property.
+ *
+ * @expectedException moodle_exception
*/
public function test_parse_rrule_validation() {
$rrule = "RANDOM=PROPERTY;";
- $this->setExpectedException('moodle_exception');
$mang = new core_tests_calendar_rrule_manager($rrule);
$mang->parse_rrule();
}
/**
* Test exception is thrown for invalid frequency.
+ *
+ * @expectedException moodle_exception
*/
public function test_freq_validation() {
$rrule = "FREQ=RANDOMLY;";
- $this->setExpectedException('moodle_exception');
$mang = new core_tests_calendar_rrule_manager($rrule);
$mang->parse_rrule();
}
diff --git a/cohort/tests/cohortlib_test.php b/cohort/tests/cohortlib_test.php
index 7403355493a..04b37b19385 100644
--- a/cohort/tests/cohortlib_test.php
+++ b/cohort/tests/cohortlib_test.php
@@ -64,6 +64,10 @@ class core_cohort_cohortlib_testcase extends advanced_testcase {
$this->assertSame($newcohort->timecreated, $newcohort->timemodified);
}
+ /**
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Missing cohort name in cohort_add_cohort().
+ */
public function test_cohort_add_cohort_missing_name() {
$cohort = new stdClass();
$cohort->contextid = context_system::instance()->id;
@@ -72,7 +76,6 @@ class core_cohort_cohortlib_testcase extends advanced_testcase {
$cohort->description = 'test cohort desc';
$cohort->descriptionformat = FORMAT_HTML;
- $this->setExpectedException('coding_exception', 'Missing cohort name in cohort_add_cohort().');
cohort_add_cohort($cohort);
}
diff --git a/cohort/tests/externallib_test.php b/cohort/tests/externallib_test.php
index 3ca5fa21248..f55eb1fa2c8 100644
--- a/cohort/tests/externallib_test.php
+++ b/cohort/tests/externallib_test.php
@@ -34,6 +34,8 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase {
/**
* Test create_cohorts
+ *
+ * @expectedException required_capability_exception
*/
public function test_create_cohorts() {
global $USER, $CFG, $DB;
@@ -97,12 +99,13 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability.
$this->unassignUserCapability('moodle/cohort:manage', $contextid, $roleid);
- $this->setExpectedException('required_capability_exception');
$createdcohorts = core_cohort_external::create_cohorts(array($cohort3));
}
/**
* Test delete_cohorts
+ *
+ * @expectedException required_capability_exception
*/
public function test_delete_cohorts() {
global $USER, $CFG, $DB;
@@ -129,7 +132,6 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase {
$cohort1 = self::getDataGenerator()->create_cohort();
$cohort2 = self::getDataGenerator()->create_cohort();
$this->unassignUserCapability('moodle/cohort:manage', $contextid, $roleid);
- $this->setExpectedException('required_capability_exception');
core_cohort_external::delete_cohorts(array($cohort1->id, $cohort2->id));
}
@@ -183,6 +185,8 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase {
/**
* Test update_cohorts
+ *
+ * @expectedException required_capability_exception
*/
public function test_update_cohorts() {
global $USER, $CFG, $DB;
@@ -224,7 +228,6 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability.
$this->unassignUserCapability('moodle/cohort:manage', $context->id, $roleid);
- $this->setExpectedException('required_capability_exception');
core_cohort_external::update_cohorts(array($cohort1));
}
@@ -260,6 +263,8 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase {
/**
* Test update_cohorts without permission on the dest category.
+ *
+ * @expectedException required_capability_exception
*/
public function test_update_cohorts_missing_dest() {
global $USER, $CFG, $DB;
@@ -295,12 +300,13 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase {
// Call the external function.
// Should fail because we don't have permission on the dest category
- $this->setExpectedException('required_capability_exception');
core_cohort_external::update_cohorts(array($cohortupdate));
}
/**
* Test update_cohorts without permission on the src category.
+ *
+ * @expectedException required_capability_exception
*/
public function test_update_cohorts_missing_src() {
global $USER, $CFG, $DB;
@@ -336,12 +342,13 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase {
// Call the external function.
// Should fail because we don't have permission on the src category
- $this->setExpectedException('required_capability_exception');
core_cohort_external::update_cohorts(array($cohortupdate));
}
/**
* Test add_cohort_members
+ *
+ * @expectedException required_capability_exception
*/
public function test_add_cohort_members() {
global $DB;
@@ -387,12 +394,13 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase {
'usertype' => array('type' => 'id', 'value' => '2')
);
$this->unassignUserCapability('moodle/cohort:assign', $contextid, $roleid);
- $this->setExpectedException('required_capability_exception');
$addcohortmembers = core_cohort_external::add_cohort_members(array($cohort2));
}
/**
* Test delete_cohort_members
+ *
+ * @expectedException required_capability_exception
*/
public function test_delete_cohort_members() {
global $DB;
@@ -444,7 +452,6 @@ class core_cohort_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability.
$this->unassignUserCapability('moodle/cohort:assign', $context->id, $roleid);
- $this->setExpectedException('required_capability_exception');
core_cohort_external::delete_cohort_members(array($cohortdel1, $cohortdel2));
}
}
diff --git a/competency/tests/api_test.php b/competency/tests/api_test.php
index cc96253ee2d..cb815aaa0e6 100644
--- a/competency/tests/api_test.php
+++ b/competency/tests/api_test.php
@@ -166,6 +166,8 @@ class core_competency_api_testcase extends advanced_testcase {
/**
* Test updating a template.
+ *
+ * @expectedException coding_exception
*/
public function test_update_template() {
$cat = $this->getDataGenerator()->create_category();
@@ -184,7 +186,6 @@ class core_competency_api_testcase extends advanced_testcase {
$this->assertEquals('success', $template->get_shortname());
// Trying to change the context.
- $this->setExpectedException('coding_exception');
api::update_template((object) array('id' => $template->get_id(), 'contextid' => context_coursecat::instance($cat->id)));
}
@@ -510,6 +511,9 @@ class core_competency_api_testcase extends advanced_testcase {
}
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_create_plan_from_template() {
$this->resetAfterTest(true);
$this->setAdminUser();
@@ -531,7 +535,6 @@ class core_competency_api_testcase extends advanced_testcase {
$this->assertFalse($plan);
// Check that api::create_plan cannot be used.
- $this->setExpectedException('coding_exception');
unset($record->id);
$plan = api::create_plan($record);
}
@@ -753,6 +756,8 @@ class core_competency_api_testcase extends advanced_testcase {
/**
* Test that the method to complete a plan.
+ *
+ * @expectedException coding_exception
*/
public function test_complete_plan() {
global $DB;
@@ -833,7 +838,6 @@ class core_competency_api_testcase extends advanced_testcase {
}
// Completing a plan that is completed throws an exception.
- $this->setExpectedException('coding_exception');
api::complete_plan($plan);
}
@@ -4430,6 +4434,9 @@ class core_competency_api_testcase extends advanced_testcase {
$this->assertTrue(evidence::record_exists($ev2->get_id()));
}
+ /**
+ * @expectedException required_capability_exception
+ */
public function test_delete_evidence_without_permissions() {
$this->resetAfterTest();
$dg = $this->getDataGenerator();
@@ -4442,7 +4449,6 @@ class core_competency_api_testcase extends advanced_testcase {
$ev1 = $ccg->create_evidence(['usercompetencyid' => $uc1->get_id()]);
$this->setUser($u1);
- $this->setExpectedException('required_capability_exception');
api::delete_evidence($ev1);
}
diff --git a/competency/tests/course_competency_settings_test.php b/competency/tests/course_competency_settings_test.php
index 1897e8105f6..31f5e486c13 100644
--- a/competency/tests/course_competency_settings_test.php
+++ b/competency/tests/course_competency_settings_test.php
@@ -120,7 +120,7 @@ class core_competency_course_competency_settings_testcase extends advanced_testc
$this->assertEquals(2, $usercompcourse->get_grade());
$this->setUser($u3);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
api::update_course_competency_settings($c1->id, (object) array('pushratingstouserplans' => false));
}
diff --git a/competency/tests/event_test.php b/competency/tests/event_test.php
index 95223a3a88a..4554c29a32d 100644
--- a/competency/tests/event_test.php
+++ b/competency/tests/event_test.php
@@ -1360,6 +1360,9 @@ class core_competency_event_testcase extends advanced_testcase {
/**
* Test evidence_created event by linking an invalid user competency to an evidence.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The user competency linked with this evidence is invalid.
*/
public function test_evidence_created_with_invalid_user_competency() {
$this->resetAfterTest(true);
@@ -1385,7 +1388,6 @@ class core_competency_event_testcase extends advanced_testcase {
'commentincontext', 'core', null, $recommend, null, 1);
// We expect this to fail and throw a coding exception.
- $this->setExpectedException('coding_exception', 'The user competency linked with this evidence is invalid.');
\core\event\competency_evidence_created::create_from_evidence($evidence, $otheruc, $recommend)->trigger();
}
diff --git a/competency/tests/exporter_test.php b/competency/tests/exporter_test.php
index eb4830b882d..101e1b46e66 100644
--- a/competency/tests/exporter_test.php
+++ b/competency/tests/exporter_test.php
@@ -82,18 +82,22 @@ class core_competency_exporter_testcase extends advanced_testcase {
$this->assertArrayNotHasKey('otherstrings', $structure->keys);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_invalid_data() {
global $PAGE;
- $this->setExpectedException('coding_exception');
$exporter = new core_competency_testable_exporter($this->invaliddata, $this->validrelated);
$output = $PAGE->get_renderer('tool_lp');
$result = $exporter->export($output);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_invalid_related() {
global $PAGE;
- $this->setExpectedException('coding_exception');
$exporter = new core_competency_testable_exporter($this->validdata, $this->invalidrelated);
$output = $PAGE->get_renderer('tool_lp');
diff --git a/competency/tests/external_test.php b/competency/tests/external_test.php
index 6be6bf0775d..0b989bfee4a 100644
--- a/competency/tests/external_test.php
+++ b/competency/tests/external_test.php
@@ -303,9 +303,10 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
/**
* Test we can't create a competency framework with only read permissions.
+ *
+ * @expectedException required_capability_exception
*/
public function test_create_competency_frameworks_with_read_permissions() {
- $this->setExpectedException('required_capability_exception');
$this->setUser($this->user);
$result = $this->create_competency_framework(1, true);
@@ -313,9 +314,10 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
/**
* Test we can't create a competency framework with only read permissions.
+ *
+ * @expectedException required_capability_exception
*/
public function test_create_competency_frameworks_with_read_permissions_in_category() {
- $this->setExpectedException('required_capability_exception');
$this->setUser($this->catuser);
$result = $this->create_competency_framework(1, false);
}
@@ -367,10 +369,11 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
/**
* Test we cannot create a competency framework with nasty data.
+ *
+ * @expectedException invalid_parameter_exception
*/
public function test_create_competency_frameworks_with_nasty_data() {
$this->setUser($this->creator);
- $this->setExpectedException('invalid_parameter_exception');
$framework = array(
'shortname' => 'short',
'idnumber' => 'id;"number',
@@ -543,9 +546,10 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
/**
* Test we can delete a competency framework with read permissions.
+ *
+ * @expectedException required_capability_exception
*/
public function test_delete_competency_frameworks_with_read_permissions() {
- $this->setExpectedException('required_capability_exception');
$this->setUser($this->creator);
$result = $this->create_competency_framework(1, true);
@@ -624,9 +628,10 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
/**
* Test we can update a competency framework with read permissions.
+ *
+ * @expectedException required_capability_exception
*/
public function test_update_competency_frameworks_with_read_permissions() {
- $this->setExpectedException('required_capability_exception');
$this->setUser($this->creator);
$result = $this->create_competency_framework(1, true);
@@ -757,9 +762,10 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
/**
* Test we can't create a competency with only read permissions.
+ *
+ * @expectedException required_capability_exception
*/
public function test_create_competency_with_read_permissions() {
- $this->setExpectedException('required_capability_exception');
$framework = $this->getDataGenerator()->get_plugin_generator('core_competency')->create_framework();
$this->setUser($this->user);
$competency = $this->create_competency(1, $framework->get_id());
@@ -818,11 +824,12 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
/**
* Test we cannot create a competency with nasty data.
+ *
+ * @expectedException invalid_parameter_exception
*/
public function test_create_competency_with_nasty_data() {
$this->setUser($this->creator);
$framework = $this->create_competency_framework(1, true);
- $this->setExpectedException('invalid_parameter_exception');
$competency = array(
'shortname' => 'shortname',
'idnumber' => 'id;"number',
@@ -995,9 +1002,10 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
/**
* Test we can delete a competency with read permissions.
+ *
+ * @expectedException required_capability_exception
*/
public function test_delete_competency_with_read_permissions() {
- $this->setExpectedException('required_capability_exception');
$this->setUser($this->creator);
$framework = $this->create_competency_framework(1, true);
$result = $this->create_competency(1, $framework->id);
@@ -1048,9 +1056,10 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
/**
* Test we can update a competency with read permissions.
+ *
+ * @expectedException required_capability_exception
*/
public function test_update_competency_with_read_permissions() {
- $this->setExpectedException('required_capability_exception');
$this->setUser($this->creator);
$framework = $this->create_competency_framework(1, true);
$result = $this->create_competency(1, $framework->id);
@@ -1717,7 +1726,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
$this->assertEquals($competency1->id, $r2->id);
$this->assertEquals($competency2->id, $r3->id);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$this->setUser($this->user);
external::reorder_template_competency($template->id, $competency1->id, $competency2->id);
}
@@ -2694,7 +2703,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
$this->setUser($this->user);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$evidence = external::grade_competency_in_plan($plan->get_id(), $c1->get_id(), 1);
}
@@ -2738,7 +2747,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
$this->assertFalse((bool)$settings->get_pushratingstouserplans());
$this->setUser($compnoob);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$result = external::update_course_competency_settings($course->id, array('pushratingstouserplans' => true));
}
diff --git a/competency/tests/persistent_test.php b/competency/tests/persistent_test.php
index b9dc0fda24b..fc8966c4099 100644
--- a/competency/tests/persistent_test.php
+++ b/competency/tests/persistent_test.php
@@ -178,12 +178,15 @@ class core_competency_persistent_testcase extends advanced_testcase {
$this->assertEquals($data, $p->to_record());
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_from_record_invalid_param() {
$p = new core_competency_testable_persistent();
$data = (object) array(
'invalidparam' => 'abc'
);
- $this->setExpectedException('coding_exception');
+
$p->from_record($data);
}
diff --git a/competency/tests/plan_test.php b/competency/tests/plan_test.php
index 865a5e2cdb5..6e9972fc122 100644
--- a/competency/tests/plan_test.php
+++ b/competency/tests/plan_test.php
@@ -526,6 +526,10 @@ class core_competency_plan_testcase extends advanced_testcase {
$this->assertCount(0, $plans);
}
+ /**
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The competency does not belong to this template:
+ */
public function test_get_competency() {
$this->resetAfterTest();
$this->setAdminUser();
@@ -567,7 +571,6 @@ class core_competency_plan_testcase extends advanced_testcase {
$this->assertEquals($c4->to_record(), $p4->get_competency($c4->get_id())->to_record());
// Getting the competency 4 from the non-completed plan based on a template p4, will throw an exception.
- $this->setExpectedException('coding_exception', 'The competency does not belong to this template: ');
$p3->get_competency($c4->get_id());
}
}
diff --git a/composer.json b/composer.json
index 73e59f111a6..ce55027b1b3 100644
--- a/composer.json
+++ b/composer.json
@@ -5,7 +5,7 @@
"type": "project",
"homepage": "https://moodle.org",
"require-dev": {
- "phpunit/phpunit": "4.8.*",
+ "phpunit/phpunit": "5.4.*",
"phpunit/dbUnit": "1.4.*",
"moodlehq/behat-extension": "3.32.1"
}
diff --git a/composer.lock b/composer.lock
index 4eda2d928e9..6fe831081f5 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "949f8a407958a19e2dba7929b3dc0576",
- "content-hash": "bd742592f8ed4700884f6c651226c961",
+ "hash": "7f0c2a252624902575a3ed1bdc237644",
+ "content-hash": "bcc157487e77ec6ad4163f1661abac97",
"packages": [],
"packages-dev": [
{
@@ -531,29 +531,29 @@
},
{
"name": "fabpot/goutte",
- "version": "v2.0.4",
+ "version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfPHP/Goutte.git",
- "reference": "0ad3ee6dc2d0aaa832a80041a1e09bf394e99802"
+ "reference": "3cbc6ed222422a28400e470050f14928a153207e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/0ad3ee6dc2d0aaa832a80041a1e09bf394e99802",
- "reference": "0ad3ee6dc2d0aaa832a80041a1e09bf394e99802",
+ "url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/3cbc6ed222422a28400e470050f14928a153207e",
+ "reference": "3cbc6ed222422a28400e470050f14928a153207e",
"shasum": ""
},
"require": {
- "guzzlehttp/guzzle": ">=4,<6",
- "php": ">=5.4.0",
- "symfony/browser-kit": "~2.1",
- "symfony/css-selector": "~2.1",
- "symfony/dom-crawler": "~2.1"
+ "guzzlehttp/guzzle": "^6.0",
+ "php": ">=5.5.0",
+ "symfony/browser-kit": "~2.1|~3.0",
+ "symfony/css-selector": "~2.1|~3.0",
+ "symfony/dom-crawler": "~2.1|~3.0"
},
"type": "application",
"extra": {
"branch-alias": {
- "dev-master": "2.0-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -576,38 +576,42 @@
"keywords": [
"scraper"
],
- "time": "2015-05-05 21:14:57"
+ "time": "2015-11-05 12:58:44"
},
{
"name": "guzzlehttp/guzzle",
- "version": "5.3.0",
+ "version": "6.2.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
- "reference": "f3c8c22471cb55475105c14769644a49c3262b93"
+ "reference": "d094e337976dff9d8e2424e8485872194e768662"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f3c8c22471cb55475105c14769644a49c3262b93",
- "reference": "f3c8c22471cb55475105c14769644a49c3262b93",
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662",
+ "reference": "d094e337976dff9d8e2424e8485872194e768662",
"shasum": ""
},
"require": {
- "guzzlehttp/ringphp": "^1.1",
- "php": ">=5.4.0"
+ "guzzlehttp/promises": "~1.0",
+ "guzzlehttp/psr7": "~1.1",
+ "php": ">=5.5.0"
},
"require-dev": {
"ext-curl": "*",
- "phpunit/phpunit": "^4.0",
- "psr/log": "^1.0"
+ "phpunit/phpunit": "~4.0",
+ "psr/log": "~1.0"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "5.0-dev"
+ "dev-master": "6.2-dev"
}
},
"autoload": {
+ "files": [
+ "src/functions_include.php"
+ ],
"psr-4": {
"GuzzleHttp\\": "src/"
}
@@ -623,7 +627,7 @@
"homepage": "https://github.com/mtdowling"
}
],
- "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
+ "description": "Guzzle is a PHP HTTP client library",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
@@ -634,44 +638,41 @@
"rest",
"web service"
],
- "time": "2015-05-20 03:47:55"
+ "time": "2016-03-21 20:02:09"
},
{
- "name": "guzzlehttp/ringphp",
- "version": "1.1.0",
+ "name": "guzzlehttp/promises",
+ "version": "1.2.0",
"source": {
"type": "git",
- "url": "https://github.com/guzzle/RingPHP.git",
- "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b"
+ "url": "https://github.com/guzzle/promises.git",
+ "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
- "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579",
+ "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579",
"shasum": ""
},
"require": {
- "guzzlehttp/streams": "~3.0",
- "php": ">=5.4.0",
- "react/promise": "~2.0"
+ "php": ">=5.5.0"
},
"require-dev": {
- "ext-curl": "*",
"phpunit/phpunit": "~4.0"
},
- "suggest": {
- "ext-curl": "Guzzle will use specific adapters if cURL is present"
- },
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.1-dev"
+ "dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
- "GuzzleHttp\\Ring\\": "src/"
- }
+ "GuzzleHttp\\Promise\\": "src/"
+ },
+ "files": [
+ "src/functions_include.php"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -684,58 +685,69 @@
"homepage": "https://github.com/mtdowling"
}
],
- "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.",
- "time": "2015-05-20 03:37:09"
- },
- {
- "name": "guzzlehttp/streams",
- "version": "3.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/guzzle/streams.git",
- "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
- "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
- "shasum": ""
- },
- "require": {
- "php": ">=5.4.0"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.0-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "GuzzleHttp\\Stream\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Michael Dowling",
- "email": "mtdowling@gmail.com",
- "homepage": "https://github.com/mtdowling"
- }
- ],
- "description": "Provides a simple abstraction over streams of data",
- "homepage": "http://guzzlephp.org/",
+ "description": "Guzzle promises library",
"keywords": [
- "Guzzle",
- "stream"
+ "promise"
],
- "time": "2014-10-12 19:18:40"
+ "time": "2016-05-18 16:56:05"
+ },
+ {
+ "name": "guzzlehttp/psr7",
+ "version": "1.3.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/psr7.git",
+ "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
+ "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.4.0",
+ "psr/http-message": "~1.0"
+ },
+ "provide": {
+ "psr/http-message-implementation": "1.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.4-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\Psr7\\": "src/"
+ },
+ "files": [
+ "src/functions_include.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ }
+ ],
+ "description": "PSR-7 message implementation",
+ "keywords": [
+ "http",
+ "message",
+ "stream",
+ "uri"
+ ],
+ "time": "2016-06-24 23:00:38"
},
{
"name": "instaclick/php-webdriver",
@@ -845,38 +857,129 @@
"time": "2016-06-20 07:56:08"
},
{
- "name": "phpdocumentor/reflection-docblock",
- "version": "2.0.4",
+ "name": "myclabs/deep-copy",
+ "version": "1.5.1",
"source": {
"type": "git",
- "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
- "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8"
+ "url": "https://github.com/myclabs/DeepCopy.git",
+ "reference": "a8773992b362b58498eed24bf85005f363c34771"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8",
- "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8",
+ "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/a8773992b362b58498eed24bf85005f363c34771",
+ "reference": "a8773992b362b58498eed24bf85005f363c34771",
"shasum": ""
},
"require": {
- "php": ">=5.3.3"
+ "php": ">=5.4.0"
},
"require-dev": {
- "phpunit/phpunit": "~4.0"
+ "doctrine/collections": "1.*",
+ "phpunit/phpunit": "~4.1"
},
- "suggest": {
- "dflydev/markdown": "~1.0",
- "erusev/parsedown": "~1.0"
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "DeepCopy\\": "src/DeepCopy/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Create deep copies (clones) of your objects",
+ "homepage": "https://github.com/myclabs/DeepCopy",
+ "keywords": [
+ "clone",
+ "copy",
+ "duplicate",
+ "object",
+ "object graph"
+ ],
+ "time": "2015-11-20 12:04:31"
+ },
+ {
+ "name": "phpdocumentor/reflection-common",
+ "version": "1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpDocumentor/ReflectionCommon.git",
+ "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c",
+ "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.5"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.6"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.0.x-dev"
+ "dev-master": "1.0.x-dev"
}
},
"autoload": {
- "psr-0": {
- "phpDocumentor": [
+ "psr-4": {
+ "phpDocumentor\\Reflection\\": [
+ "src"
+ ]
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Jaap van Otterdijk",
+ "email": "opensource@ijaap.nl"
+ }
+ ],
+ "description": "Common reflection classes used by phpdocumentor to reflect the code structure",
+ "homepage": "http://www.phpdoc.org",
+ "keywords": [
+ "FQSEN",
+ "phpDocumentor",
+ "phpdoc",
+ "reflection",
+ "static analysis"
+ ],
+ "time": "2015-12-27 11:43:31"
+ },
+ {
+ "name": "phpdocumentor/reflection-docblock",
+ "version": "3.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
+ "reference": "9270140b940ff02e58ec577c237274e92cd40cdd"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9270140b940ff02e58ec577c237274e92cd40cdd",
+ "reference": "9270140b940ff02e58ec577c237274e92cd40cdd",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.5",
+ "phpdocumentor/reflection-common": "^1.0@dev",
+ "phpdocumentor/type-resolver": "^0.2.0",
+ "webmozart/assert": "^1.0"
+ },
+ "require-dev": {
+ "mockery/mockery": "^0.9.4",
+ "phpunit/phpunit": "^4.4"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "phpDocumentor\\Reflection\\": [
"src/"
]
}
@@ -888,10 +991,58 @@
"authors": [
{
"name": "Mike van Riel",
- "email": "mike.vanriel@naenius.com"
+ "email": "me@mikevanriel.com"
}
],
- "time": "2015-02-03 12:10:50"
+ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
+ "time": "2016-06-10 09:48:41"
+ },
+ {
+ "name": "phpdocumentor/type-resolver",
+ "version": "0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpDocumentor/TypeResolver.git",
+ "reference": "b39c7a5b194f9ed7bd0dd345c751007a41862443"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/b39c7a5b194f9ed7bd0dd345c751007a41862443",
+ "reference": "b39c7a5b194f9ed7bd0dd345c751007a41862443",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.5",
+ "phpdocumentor/reflection-common": "^1.0"
+ },
+ "require-dev": {
+ "mockery/mockery": "^0.9.4",
+ "phpunit/phpunit": "^5.2||^4.8.24"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "phpDocumentor\\Reflection\\": [
+ "src/"
+ ]
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Mike van Riel",
+ "email": "me@mikevanriel.com"
+ }
+ ],
+ "time": "2016-06-10 07:14:17"
},
{
"name": "phpspec/prophecy",
@@ -1016,39 +1167,40 @@
},
{
"name": "phpunit/php-code-coverage",
- "version": "2.2.4",
+ "version": "4.0.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979"
+ "reference": "900370c81280cc0d942ffbc5912d80464eaee7e9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979",
- "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/900370c81280cc0d942ffbc5912d80464eaee7e9",
+ "reference": "900370c81280cc0d942ffbc5912d80464eaee7e9",
"shasum": ""
},
"require": {
- "php": ">=5.3.3",
+ "php": "^5.6 || ^7.0",
"phpunit/php-file-iterator": "~1.3",
"phpunit/php-text-template": "~1.2",
- "phpunit/php-token-stream": "~1.3",
+ "phpunit/php-token-stream": "^1.4.2",
+ "sebastian/code-unit-reverse-lookup": "~1.0",
"sebastian/environment": "^1.3.2",
- "sebastian/version": "~1.0"
+ "sebastian/version": "~1.0|~2.0"
},
"require-dev": {
"ext-xdebug": ">=2.1.4",
- "phpunit/phpunit": "~4"
+ "phpunit/phpunit": "^5.4"
},
"suggest": {
"ext-dom": "*",
- "ext-xdebug": ">=2.2.1",
+ "ext-xdebug": ">=2.4.0",
"ext-xmlwriter": "*"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.2.x-dev"
+ "dev-master": "4.0.x-dev"
}
},
"autoload": {
@@ -1074,7 +1226,7 @@
"testing",
"xunit"
],
- "time": "2015-10-06 15:47:00"
+ "time": "2016-06-03 05:03:56"
},
{
"name": "phpunit/php-file-iterator",
@@ -1259,16 +1411,16 @@
},
{
"name": "phpunit/phpunit",
- "version": "4.8.26",
+ "version": "5.4.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "fc1d8cd5b5de11625979125c5639347896ac2c74"
+ "reference": "2f1fc94b77ea6418bd6a06c64a1dac0645fbce59"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fc1d8cd5b5de11625979125c5639347896ac2c74",
- "reference": "fc1d8cd5b5de11625979125c5639347896ac2c74",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2f1fc94b77ea6418bd6a06c64a1dac0645fbce59",
+ "reference": "2f1fc94b77ea6418bd6a06c64a1dac0645fbce59",
"shasum": ""
},
"require": {
@@ -1277,21 +1429,27 @@
"ext-pcre": "*",
"ext-reflection": "*",
"ext-spl": "*",
- "php": ">=5.3.3",
+ "myclabs/deep-copy": "~1.3",
+ "php": "^5.6 || ^7.0",
"phpspec/prophecy": "^1.3.1",
- "phpunit/php-code-coverage": "~2.1",
+ "phpunit/php-code-coverage": "^4.0",
"phpunit/php-file-iterator": "~1.4",
"phpunit/php-text-template": "~1.2",
"phpunit/php-timer": "^1.0.6",
- "phpunit/phpunit-mock-objects": "~2.3",
+ "phpunit/phpunit-mock-objects": "^3.2",
"sebastian/comparator": "~1.1",
"sebastian/diff": "~1.2",
- "sebastian/environment": "~1.3",
+ "sebastian/environment": "^1.3 || ^2.0",
"sebastian/exporter": "~1.2",
"sebastian/global-state": "~1.0",
- "sebastian/version": "~1.0",
+ "sebastian/object-enumerator": "~1.0",
+ "sebastian/resource-operations": "~1.0",
+ "sebastian/version": "~1.0|~2.0",
"symfony/yaml": "~2.1|~3.0"
},
+ "conflict": {
+ "phpdocumentor/reflection-docblock": "3.0.2"
+ },
"suggest": {
"phpunit/php-invoker": "~1.1"
},
@@ -1301,7 +1459,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "4.8.x-dev"
+ "dev-master": "5.4.x-dev"
}
},
"autoload": {
@@ -1327,30 +1485,33 @@
"testing",
"xunit"
],
- "time": "2016-05-17 03:09:28"
+ "time": "2016-06-16 06:01:15"
},
{
"name": "phpunit/phpunit-mock-objects",
- "version": "2.3.8",
+ "version": "3.2.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
- "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983"
+ "reference": "b13d0d9426ced06958bd32104653526a6c998a52"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983",
- "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/b13d0d9426ced06958bd32104653526a6c998a52",
+ "reference": "b13d0d9426ced06958bd32104653526a6c998a52",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
- "php": ">=5.3.3",
- "phpunit/php-text-template": "~1.2",
- "sebastian/exporter": "~1.2"
+ "php": "^5.6 || ^7.0",
+ "phpunit/php-text-template": "^1.2",
+ "sebastian/exporter": "^1.2"
+ },
+ "conflict": {
+ "phpunit/phpunit": "<5.4.0"
},
"require-dev": {
- "phpunit/phpunit": "~4.4"
+ "phpunit/phpunit": "^5.4"
},
"suggest": {
"ext-soap": "*"
@@ -1358,7 +1519,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.3.x-dev"
+ "dev-master": "3.2.x-dev"
}
},
"autoload": {
@@ -1383,38 +1544,35 @@
"mock",
"xunit"
],
- "time": "2015-10-02 06:51:40"
+ "time": "2016-06-12 07:37:26"
},
{
- "name": "react/promise",
- "version": "v2.4.1",
+ "name": "psr/http-message",
+ "version": "1.0",
"source": {
"type": "git",
- "url": "https://github.com/reactphp/promise.git",
- "reference": "8025426794f1944de806618671d4fa476dc7626f"
+ "url": "https://github.com/php-fig/http-message.git",
+ "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/reactphp/promise/zipball/8025426794f1944de806618671d4fa476dc7626f",
- "reference": "8025426794f1944de806618671d4fa476dc7626f",
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
+ "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
"shasum": ""
},
"require": {
- "php": ">=5.4.0"
+ "php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.0-dev"
+ "dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
- "React\\Promise\\": "src/"
- },
- "files": [
- "src/functions_include.php"
- ]
+ "Psr\\Http\\Message\\": "src/"
+ }
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -1422,12 +1580,65 @@
],
"authors": [
{
- "name": "Jan Sorgalla",
- "email": "jsorgalla@gmail.com"
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
}
],
- "description": "A lightweight implementation of CommonJS Promises/A for PHP",
- "time": "2016-05-03 17:50:52"
+ "description": "Common interface for HTTP messages",
+ "keywords": [
+ "http",
+ "http-message",
+ "psr",
+ "psr-7",
+ "request",
+ "response"
+ ],
+ "time": "2015-05-04 20:22:00"
+ },
+ {
+ "name": "sebastian/code-unit-reverse-lookup",
+ "version": "1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
+ "reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/c36f5e7cfce482fde5bf8d10d41a53591e0198fe",
+ "reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.6"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~5"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "description": "Looks up which function or method a line of code belongs to",
+ "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
+ "time": "2016-02-13 06:45:14"
},
{
"name": "sebastian/comparator",
@@ -1713,6 +1924,52 @@
],
"time": "2015-10-12 03:26:01"
},
+ {
+ "name": "sebastian/object-enumerator",
+ "version": "1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/object-enumerator.git",
+ "reference": "d4ca2fb70344987502567bc50081c03e6192fb26"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/d4ca2fb70344987502567bc50081c03e6192fb26",
+ "reference": "d4ca2fb70344987502567bc50081c03e6192fb26",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.6",
+ "sebastian/recursion-context": "~1.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~5"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "description": "Traverses array structures and object graphs to enumerate all referenced objects",
+ "homepage": "https://github.com/sebastianbergmann/object-enumerator/",
+ "time": "2016-01-28 13:25:10"
+ },
{
"name": "sebastian/recursion-context",
"version": "1.0.2",
@@ -1767,20 +2024,70 @@
"time": "2015-11-11 19:50:13"
},
{
- "name": "sebastian/version",
- "version": "1.0.6",
+ "name": "sebastian/resource-operations",
+ "version": "1.0.0",
"source": {
"type": "git",
- "url": "https://github.com/sebastianbergmann/version.git",
- "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6"
+ "url": "https://github.com/sebastianbergmann/resource-operations.git",
+ "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
- "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
+ "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52",
+ "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52",
"shasum": ""
},
+ "require": {
+ "php": ">=5.6.0"
+ },
"type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de"
+ }
+ ],
+ "description": "Provides a list of PHP built-in functions that operate on resources",
+ "homepage": "https://www.github.com/sebastianbergmann/resource-operations",
+ "time": "2015-07-28 20:34:47"
+ },
+ {
+ "name": "sebastian/version",
+ "version": "2.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/version.git",
+ "reference": "c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5",
+ "reference": "c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.6"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0.x-dev"
+ }
+ },
"autoload": {
"classmap": [
"src/"
@@ -1799,29 +2106,29 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
- "time": "2015-06-21 13:59:46"
+ "time": "2016-02-04 12:56:52"
},
{
"name": "symfony/browser-kit",
- "version": "v2.8.7",
+ "version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/browser-kit.git",
- "reference": "2508ecbfc98b007bc1b670cef40ff821b827c61c"
+ "reference": "dcf41ed026b0499254385b5c88f03247b2ba010b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/browser-kit/zipball/2508ecbfc98b007bc1b670cef40ff821b827c61c",
- "reference": "2508ecbfc98b007bc1b670cef40ff821b827c61c",
+ "url": "https://api.github.com/repos/symfony/browser-kit/zipball/dcf41ed026b0499254385b5c88f03247b2ba010b",
+ "reference": "dcf41ed026b0499254385b5c88f03247b2ba010b",
"shasum": ""
},
"require": {
- "php": ">=5.3.9",
- "symfony/dom-crawler": "~2.1|~3.0.0"
+ "php": ">=5.5.9",
+ "symfony/dom-crawler": "~2.8|~3.0"
},
"require-dev": {
- "symfony/css-selector": "~2.0,>=2.0.5|~3.0.0",
- "symfony/process": "~2.3.34|~2.7,>=2.7.6|~3.0.0"
+ "symfony/css-selector": "~2.8|~3.0",
+ "symfony/process": "~2.8|~3.0"
},
"suggest": {
"symfony/process": ""
@@ -1829,7 +2136,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.8-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -1856,33 +2163,36 @@
],
"description": "Symfony BrowserKit Component",
"homepage": "https://symfony.com",
- "time": "2016-06-06 15:06:25"
+ "time": "2016-06-29 05:41:56"
},
{
"name": "symfony/class-loader",
- "version": "v2.8.7",
+ "version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/class-loader.git",
- "reference": "f1cf312c81c7b4f0f11431e6fd37b66890f5e27b"
+ "reference": "0d0ac77c336eb73f35bebdf3e1f3695ac741bbc9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/class-loader/zipball/f1cf312c81c7b4f0f11431e6fd37b66890f5e27b",
- "reference": "f1cf312c81c7b4f0f11431e6fd37b66890f5e27b",
+ "url": "https://api.github.com/repos/symfony/class-loader/zipball/0d0ac77c336eb73f35bebdf3e1f3695ac741bbc9",
+ "reference": "0d0ac77c336eb73f35bebdf3e1f3695ac741bbc9",
"shasum": ""
},
"require": {
- "php": ">=5.3.9",
- "symfony/polyfill-apcu": "~1.1"
+ "php": ">=5.5.9"
},
"require-dev": {
- "symfony/finder": "~2.0,>=2.0.5|~3.0.0"
+ "symfony/finder": "~2.8|~3.0",
+ "symfony/polyfill-apcu": "~1.1"
+ },
+ "suggest": {
+ "symfony/polyfill-apcu": "For using ApcClassLoader on HHVM"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.8-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -1909,25 +2219,25 @@
],
"description": "Symfony ClassLoader Component",
"homepage": "https://symfony.com",
- "time": "2016-03-30 10:37:34"
+ "time": "2016-06-29 05:41:56"
},
{
"name": "symfony/config",
- "version": "v2.8.7",
+ "version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
- "reference": "a2edd59c2163c65747fc3f35d132b5a39266bd05"
+ "reference": "bcf5aebabc95b56e370e13d78565f74c7d8726dc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/config/zipball/a2edd59c2163c65747fc3f35d132b5a39266bd05",
- "reference": "a2edd59c2163c65747fc3f35d132b5a39266bd05",
+ "url": "https://api.github.com/repos/symfony/config/zipball/bcf5aebabc95b56e370e13d78565f74c7d8726dc",
+ "reference": "bcf5aebabc95b56e370e13d78565f74c7d8726dc",
"shasum": ""
},
"require": {
- "php": ">=5.3.9",
- "symfony/filesystem": "~2.3|~3.0.0"
+ "php": ">=5.5.9",
+ "symfony/filesystem": "~2.8|~3.0"
},
"suggest": {
"symfony/yaml": "To use the yaml reference dumper"
@@ -1935,7 +2245,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.8-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -1962,30 +2272,30 @@
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
- "time": "2016-06-06 11:11:27"
+ "time": "2016-06-29 05:41:56"
},
{
"name": "symfony/console",
- "version": "v2.8.7",
+ "version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "5ac8bc9aa77bb2edf06af3a1bb6bc1020d23acd3"
+ "reference": "747154aa69b0f83cd02fc9aa554836dee417631a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/5ac8bc9aa77bb2edf06af3a1bb6bc1020d23acd3",
- "reference": "5ac8bc9aa77bb2edf06af3a1bb6bc1020d23acd3",
+ "url": "https://api.github.com/repos/symfony/console/zipball/747154aa69b0f83cd02fc9aa554836dee417631a",
+ "reference": "747154aa69b0f83cd02fc9aa554836dee417631a",
"shasum": ""
},
"require": {
- "php": ">=5.3.9",
+ "php": ">=5.5.9",
"symfony/polyfill-mbstring": "~1.0"
},
"require-dev": {
"psr/log": "~1.0",
- "symfony/event-dispatcher": "~2.1|~3.0.0",
- "symfony/process": "~2.1|~3.0.0"
+ "symfony/event-dispatcher": "~2.8|~3.0",
+ "symfony/process": "~2.8|~3.0"
},
"suggest": {
"psr/log": "For using the console logger",
@@ -1995,7 +2305,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.8-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -2022,29 +2332,29 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
- "time": "2016-06-06 15:06:25"
+ "time": "2016-06-29 07:02:31"
},
{
"name": "symfony/css-selector",
- "version": "v2.8.7",
+ "version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
- "reference": "9a0b2649328297fb6acd0c823789d92efcbd36ad"
+ "reference": "2851e1932d77ce727776154d659b232d061e816a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/css-selector/zipball/9a0b2649328297fb6acd0c823789d92efcbd36ad",
- "reference": "9a0b2649328297fb6acd0c823789d92efcbd36ad",
+ "url": "https://api.github.com/repos/symfony/css-selector/zipball/2851e1932d77ce727776154d659b232d061e816a",
+ "reference": "2851e1932d77ce727776154d659b232d061e816a",
"shasum": ""
},
"require": {
- "php": ">=5.3.9"
+ "php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.8-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -2075,32 +2385,29 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
- "time": "2016-06-06 11:11:27"
+ "time": "2016-06-29 05:41:56"
},
{
"name": "symfony/dependency-injection",
- "version": "v2.8.7",
+ "version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/dependency-injection.git",
- "reference": "2d05009d890cf1139988ff059b5b2e0eb280ed13"
+ "reference": "b7272b65f2f46cbe77def7d33916f2613669c508"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/2d05009d890cf1139988ff059b5b2e0eb280ed13",
- "reference": "2d05009d890cf1139988ff059b5b2e0eb280ed13",
+ "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/b7272b65f2f46cbe77def7d33916f2613669c508",
+ "reference": "b7272b65f2f46cbe77def7d33916f2613669c508",
"shasum": ""
},
"require": {
- "php": ">=5.3.9"
- },
- "conflict": {
- "symfony/expression-language": "<2.6"
+ "php": ">=5.5.9"
},
"require-dev": {
- "symfony/config": "~2.2|~3.0.0",
- "symfony/expression-language": "~2.6|~3.0.0",
- "symfony/yaml": "~2.1|~3.0.0"
+ "symfony/config": "~2.8|~3.0",
+ "symfony/expression-language": "~2.8|~3.0",
+ "symfony/yaml": "~2.8|~3.0"
},
"suggest": {
"symfony/config": "",
@@ -2111,7 +2418,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.8-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -2138,28 +2445,28 @@
],
"description": "Symfony DependencyInjection Component",
"homepage": "https://symfony.com",
- "time": "2016-06-06 11:11:27"
+ "time": "2016-06-29 05:42:25"
},
{
"name": "symfony/dom-crawler",
- "version": "v2.8.7",
+ "version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
- "reference": "f282b08f6bbbc72e7af2e9e0c2f896221053f791"
+ "reference": "99ec4a23330fcd0c8667095f3ef7aa204ffd9dc0"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/f282b08f6bbbc72e7af2e9e0c2f896221053f791",
- "reference": "f282b08f6bbbc72e7af2e9e0c2f896221053f791",
+ "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/99ec4a23330fcd0c8667095f3ef7aa204ffd9dc0",
+ "reference": "99ec4a23330fcd0c8667095f3ef7aa204ffd9dc0",
"shasum": ""
},
"require": {
- "php": ">=5.3.9",
+ "php": ">=5.5.9",
"symfony/polyfill-mbstring": "~1.0"
},
"require-dev": {
- "symfony/css-selector": "~2.8|~3.0.0"
+ "symfony/css-selector": "~2.8|~3.0"
},
"suggest": {
"symfony/css-selector": ""
@@ -2167,7 +2474,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.8-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -2194,31 +2501,31 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
- "time": "2016-04-12 18:01:21"
+ "time": "2016-06-29 05:41:56"
},
{
"name": "symfony/event-dispatcher",
- "version": "v2.8.7",
+ "version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
- "reference": "2a6b8713f8bdb582058cfda463527f195b066110"
+ "reference": "7f9839ede2070f53e7e2f0849b9bd14748c434c5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/2a6b8713f8bdb582058cfda463527f195b066110",
- "reference": "2a6b8713f8bdb582058cfda463527f195b066110",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/7f9839ede2070f53e7e2f0849b9bd14748c434c5",
+ "reference": "7f9839ede2070f53e7e2f0849b9bd14748c434c5",
"shasum": ""
},
"require": {
- "php": ">=5.3.9"
+ "php": ">=5.5.9"
},
"require-dev": {
"psr/log": "~1.0",
- "symfony/config": "~2.0,>=2.0.5|~3.0.0",
- "symfony/dependency-injection": "~2.6|~3.0.0",
- "symfony/expression-language": "~2.6|~3.0.0",
- "symfony/stopwatch": "~2.3|~3.0.0"
+ "symfony/config": "~2.8|~3.0",
+ "symfony/dependency-injection": "~2.8|~3.0",
+ "symfony/expression-language": "~2.8|~3.0",
+ "symfony/stopwatch": "~2.8|~3.0"
},
"suggest": {
"symfony/dependency-injection": "",
@@ -2227,7 +2534,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.8-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -2254,29 +2561,29 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
- "time": "2016-06-06 11:11:27"
+ "time": "2016-06-29 05:41:56"
},
{
"name": "symfony/filesystem",
- "version": "v2.8.7",
+ "version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
- "reference": "dee379131dceed90a429e951546b33edfe7dccbb"
+ "reference": "322da5f0910d8aa0b25fa65ffccaba68dbddb890"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/filesystem/zipball/dee379131dceed90a429e951546b33edfe7dccbb",
- "reference": "dee379131dceed90a429e951546b33edfe7dccbb",
+ "url": "https://api.github.com/repos/symfony/filesystem/zipball/322da5f0910d8aa0b25fa65ffccaba68dbddb890",
+ "reference": "322da5f0910d8aa0b25fa65ffccaba68dbddb890",
"shasum": ""
},
"require": {
- "php": ">=5.3.9"
+ "php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.8-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -2303,60 +2610,7 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
- "time": "2016-04-12 18:01:21"
- },
- {
- "name": "symfony/polyfill-apcu",
- "version": "v1.2.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-apcu.git",
- "reference": "6d58bceaeea2c2d3eb62503839b18646e161cd6b"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-apcu/zipball/6d58bceaeea2c2d3eb62503839b18646e161cd6b",
- "reference": "6d58bceaeea2c2d3eb62503839b18646e161cd6b",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.2-dev"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill backporting apcu_* functions to lower PHP versions",
- "homepage": "https://symfony.com",
- "keywords": [
- "apcu",
- "compatibility",
- "polyfill",
- "portable",
- "shim"
- ],
- "time": "2016-05-18 14:26:46"
+ "time": "2016-06-29 05:41:56"
},
{
"name": "symfony/polyfill-mbstring",
@@ -2419,16 +2673,16 @@
},
{
"name": "symfony/process",
- "version": "v2.8.7",
+ "version": "v2.8.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
- "reference": "115347d00c342198cdc52a7bd8bc15b5ab43500c"
+ "reference": "89f33c16796415ccfd8bb3cf8d520cbb79899bfe"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/process/zipball/115347d00c342198cdc52a7bd8bc15b5ab43500c",
- "reference": "115347d00c342198cdc52a7bd8bc15b5ab43500c",
+ "url": "https://api.github.com/repos/symfony/process/zipball/89f33c16796415ccfd8bb3cf8d520cbb79899bfe",
+ "reference": "89f33c16796415ccfd8bb3cf8d520cbb79899bfe",
"shasum": ""
},
"require": {
@@ -2464,34 +2718,34 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
- "time": "2016-06-06 11:11:27"
+ "time": "2016-06-29 05:29:29"
},
{
"name": "symfony/translation",
- "version": "v2.8.7",
+ "version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
- "reference": "8a1648d2e165ba87c759ba57d7f4c13d95fdf4a1"
+ "reference": "d63a94528530c3ea5ff46924c8001cec4a398609"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/translation/zipball/8a1648d2e165ba87c759ba57d7f4c13d95fdf4a1",
- "reference": "8a1648d2e165ba87c759ba57d7f4c13d95fdf4a1",
+ "url": "https://api.github.com/repos/symfony/translation/zipball/d63a94528530c3ea5ff46924c8001cec4a398609",
+ "reference": "d63a94528530c3ea5ff46924c8001cec4a398609",
"shasum": ""
},
"require": {
- "php": ">=5.3.9",
+ "php": ">=5.5.9",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
- "symfony/config": "<2.7"
+ "symfony/config": "<2.8"
},
"require-dev": {
"psr/log": "~1.0",
- "symfony/config": "~2.8",
- "symfony/intl": "~2.4|~3.0.0",
- "symfony/yaml": "~2.2|~3.0.0"
+ "symfony/config": "~2.8|~3.0",
+ "symfony/intl": "~2.8|~3.0",
+ "symfony/yaml": "~2.8|~3.0"
},
"suggest": {
"psr/log": "To use logging capability in translator",
@@ -2501,7 +2755,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.8-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -2528,29 +2782,29 @@
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
- "time": "2016-06-06 11:11:27"
+ "time": "2016-06-29 05:41:56"
},
{
"name": "symfony/yaml",
- "version": "v2.8.7",
+ "version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
- "reference": "815fabf3f48c7d1df345a69d1ad1a88f59757b34"
+ "reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/yaml/zipball/815fabf3f48c7d1df345a69d1ad1a88f59757b34",
- "reference": "815fabf3f48c7d1df345a69d1ad1a88f59757b34",
+ "url": "https://api.github.com/repos/symfony/yaml/zipball/2884c26ce4c1d61aebf423a8b912950fe7c764de",
+ "reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de",
"shasum": ""
},
"require": {
- "php": ">=5.3.9"
+ "php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.8-dev"
+ "dev-master": "3.1-dev"
}
},
"autoload": {
@@ -2577,7 +2831,56 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
- "time": "2016-06-06 11:11:27"
+ "time": "2016-06-29 05:41:56"
+ },
+ {
+ "name": "webmozart/assert",
+ "version": "1.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/webmozart/assert.git",
+ "reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/webmozart/assert/zipball/30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde",
+ "reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.6"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Webmozart\\Assert\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Bernhard Schussek",
+ "email": "bschussek@gmail.com"
+ }
+ ],
+ "description": "Assertions to validate method input/output with nice error messages.",
+ "keywords": [
+ "assert",
+ "check",
+ "validate"
+ ],
+ "time": "2015-08-24 13:29:44"
}
],
"aliases": [],
diff --git a/course/tests/externallib_test.php b/course/tests/externallib_test.php
index 21c38bd22de..4c863da5f59 100644
--- a/course/tests/externallib_test.php
+++ b/course/tests/externallib_test.php
@@ -120,7 +120,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability
$this->unassignUserCapability('moodle/category:manage', $contextid, $roleid);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$createdsubcats = core_course_external::create_categories($subcategories);
}
@@ -163,7 +163,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability
$this->unassignUserCapability('moodle/category:manage', $contextid, $roleid);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$createdsubcats = core_course_external::delete_categories(
array(array('id' => $category3->id)));
}
@@ -261,7 +261,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability (it will fail cause of the search on idnumber).
$this->unassignUserCapability('moodle/category:manage', $context->id, $roleid);
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$categories = core_course_external::get_categories(array(
array('key' => 'id', 'value' => $category1->id),
array('key' => 'idnumber', 'value' => $category1->idnumber),
@@ -327,7 +327,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability.
$this->unassignUserCapability('moodle/category:manage', $contextid, $roleid);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
core_course_external::update_categories($categories);
}
@@ -457,7 +457,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability
$this->unassignUserCapability('moodle/course:create', $contextid, $roleid);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$createdsubcats = core_course_external::create_courses($courses);
}
@@ -515,7 +515,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
// Fail when the user is not allow to access the course (enrolled) or is not admin.
$this->setGuestUser();
- $this->setExpectedException('require_login_exception');
+ $this->expectException('require_login_exception');
$result = core_course_external::delete_courses(array($course3->id));
$result = external_api::clean_returnvalue(core_course_external::delete_courses_returns(), $result);
@@ -690,7 +690,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
$this->assertEquals($coursedata2['fullname'], $results['courses'][0]['fullname']);
// Search by block (use news_items default block). Should fail (only admins allowed).
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$results = core_course_external::search_courses('blocklist', $blockid);
}
@@ -1519,7 +1519,8 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
$course1 = self::getDataGenerator()->create_course();
$course2 = self::getDataGenerator()->create_course();
- $this->setExpectedException('moodle_exception', get_string('invalidextparam', 'webservice', -1));
+ $this->expectException('moodle_exception');
+ $this->expectExceptionMessage(get_string('invalidextparam', 'webservice', -1));
// Import from course1 to course2, with invalid option
core_course_external::import_course($course1->id, $course2->id, -1);;
}
diff --git a/enrol/tests/externallib_test.php b/enrol/tests/externallib_test.php
index a7d35ad4a38..7695e3c7bc7 100644
--- a/enrol/tests/externallib_test.php
+++ b/enrol/tests/externallib_test.php
@@ -316,7 +316,8 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase {
}
} else if (isset($expectations['exception'])) {
$exception = $expectations['exception'];
- $this->setExpectedException($exception['type'], $exception['message']);
+ $this->expectException($exception['type']);
+ $this->expectExceptionMessage($exception['message']);
} else {
// Failed, only canview and exception are supported.
$this->markTestIncomplete('Incomplete, only canview and exception are supported');
@@ -565,6 +566,8 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase {
/**
* Test get_enrolled_users from core_enrol_external with capability to
* viewparticipants removed.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_enrolled_users_without_capability() {
$capability = 'moodle/course:viewparticipants';
@@ -572,7 +575,6 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability.
$this->unassignUserCapability($capability, $data->context->id, $data->roleid);
- $this->setExpectedException('moodle_exception');
$categories = core_enrol_external::get_enrolled_users($data->course->id);
}
diff --git a/enrol/tests/role_external_test.php b/enrol/tests/role_external_test.php
index 2a8c4a877eb..4009101fbf5 100644
--- a/enrol/tests/role_external_test.php
+++ b/enrol/tests/role_external_test.php
@@ -84,7 +84,7 @@ class core_enrol_role_external_testcase extends externallib_advanced_testcase {
// Call without required capability.
$this->unassignUserCapability('moodle/role:assign', $context->id, $roleid);
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$categories = core_role_external::assign_roles(
array('roleid' => 3, 'userid' => $USER->id, 'contextid' => $context->id));
}
@@ -138,7 +138,7 @@ class core_enrol_role_external_testcase extends externallib_advanced_testcase {
// Call without required capability.
$this->unassignUserCapability('moodle/role:assign', $context->id, $roleid);
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$categories = core_role_external::unassign_roles(
array('roleid' => 3, 'userid' => $USER->id, 'contextid' => $context->id));
}
diff --git a/files/tests/externallib_test.php b/files/tests/externallib_test.php
index c464856ac28..4f197775f31 100644
--- a/files/tests/externallib_test.php
+++ b/files/tests/externallib_test.php
@@ -95,7 +95,7 @@ class core_files_externallib_testcase extends advanced_testcase {
$this->assertNotEmpty($file);
// Make sure the same file cannot be created again.
- $this->setExpectedException("moodle_exception");
+ $this->expectException("moodle_exception");
core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath,
$filename, $filecontent, $contextlevel, $instanceid);
}
@@ -120,7 +120,7 @@ class core_files_externallib_testcase extends advanced_testcase {
$instanceid = null;
// Make sure exception is thrown.
- $this->setExpectedException("coding_exception");
+ $this->expectException("coding_exception");
core_files_external::upload($contextid, $component, $filearea, $itemid,
$filepath, $filename, $filecontent, $contextlevel, $instanceid);
}
diff --git a/grade/grading/tests/grading_manager_test.php b/grade/grading/tests/grading_manager_test.php
index 0e806e812e8..b4907241312 100644
--- a/grade/grading/tests/grading_manager_test.php
+++ b/grade/grading/tests/grading_manager_test.php
@@ -67,6 +67,8 @@ class core_grade_grading_manager_testcase extends advanced_testcase {
/**
* Unit test to set and get grading areas
+ *
+ * @expectedException moodle_exception
*/
public function test_set_and_get_grading_area() {
global $DB;
@@ -103,7 +105,6 @@ class core_grade_grading_manager_testcase extends advanced_testcase {
$this->assertEquals('rubric', $gradingman->get_active_method());
// attempting to set an invalid method
- $this->setExpectedException('moodle_exception');
$gradingman->set_active_method('no_one_should_ever_try_to_implement_a_method_with_this_silly_name');
}
diff --git a/group/tests/externallib_test.php b/group/tests/externallib_test.php
index 547437925a9..97a6cf93184 100644
--- a/group/tests/externallib_test.php
+++ b/group/tests/externallib_test.php
@@ -36,6 +36,8 @@ class core_group_externallib_testcase extends externallib_advanced_testcase {
/**
* Test create_groups
+ *
+ * @expectedException required_capability_exception
*/
public function test_create_groups() {
global $DB;
@@ -111,12 +113,13 @@ class core_group_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability
$this->unassignUserCapability('moodle/course:managegroups', $context->id, $roleid);
- $this->setExpectedException('required_capability_exception');
$froups = core_group_external::create_groups(array($group4));
}
/**
* Test get_groups
+ *
+ * @expectedException required_capability_exception
*/
public function test_get_groups() {
global $DB;
@@ -175,12 +178,13 @@ class core_group_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability
$this->unassignUserCapability('moodle/course:managegroups', $context->id, $roleid);
- $this->setExpectedException('required_capability_exception');
$groups = core_group_external::get_groups(array($group1->id, $group2->id));
}
/**
* Test delete_groups
+ *
+ * @expectedException required_capability_exception
*/
public function test_delete_groups() {
global $DB;
@@ -223,7 +227,6 @@ class core_group_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability
$this->unassignUserCapability('moodle/course:managegroups', $context->id, $roleid);
- $this->setExpectedException('required_capability_exception');
$froups = core_group_external::delete_groups(array($group3->id));
}
diff --git a/lib/external/tests/external_test.php b/lib/external/tests/external_test.php
index 4ff82b0282c..2ceec659215 100644
--- a/lib/external/tests/external_test.php
+++ b/lib/external/tests/external_test.php
@@ -72,7 +72,7 @@ class core_external_testcase extends externallib_advanced_testcase {
$this->assertSame($corestring, $returnedstring);
// String with two parameter but one is invalid (not named).
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$returnedstring = core_external::get_string('addservice', 'webservice', null,
array(array('value' => $service->name),
array('name' => 'id', 'value' => $service->id)));
diff --git a/lib/filestorage/tests/file_storage_test.php b/lib/filestorage/tests/file_storage_test.php
index f453f345171..45b89cbf8a4 100644
--- a/lib/filestorage/tests/file_storage_test.php
+++ b/lib/filestorage/tests/file_storage_test.php
@@ -236,7 +236,7 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertInstanceOf('stored_file', $previewtinyicon);
$this->assertEquals('6b9864ae1536a8eeef54e097319175a8be12f07c', $previewtinyicon->get_filename());
- $this->setExpectedException('file_exception');
+ $this->expectException('file_exception');
$fs->get_file_preview($file, 'amodewhichdoesntexist');
}
@@ -300,8 +300,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertEquals($contenthash, $file->get_contenthash());
// Try break it.
- $this->setExpectedException('file_exception',
- 'Can not create file "1/core/unittest/0/test/newtest.txt" (file exists, cannot rename)');
+ $this->expectException('file_exception');
+ $this->expectExceptionMessage('Can not create file "1/core/unittest/0/test/newtest.txt" (file exists, cannot rename)');
// This shall throw exception.
$originalfile->rename($newpath, $newname);
}
@@ -621,14 +621,14 @@ class core_files_file_storage_testcase extends advanced_testcase {
public function test_create_directory_contextid_negative() {
$fs = get_file_storage();
- $this->setExpectedException('file_exception');
+ $this->expectException('file_exception');
$fs->create_directory(-1, 'core', 'unittest', 0, '/');
}
public function test_create_directory_contextid_invalid() {
$fs = get_file_storage();
- $this->setExpectedException('file_exception');
+ $this->expectException('file_exception');
$fs->create_directory('not an int', 'core', 'unittest', 0, '/');
}
@@ -636,7 +636,7 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs = get_file_storage();
$syscontext = context_system::instance();
- $this->setExpectedException('file_exception');
+ $this->expectException('file_exception');
$fs->create_directory($syscontext->id, 'bad/component', 'unittest', 0, '/');
}
@@ -644,7 +644,7 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs = get_file_storage();
$syscontext = context_system::instance();
- $this->setExpectedException('file_exception');
+ $this->expectException('file_exception');
$fs->create_directory($syscontext->id, 'core', 'bad-filearea', 0, '/');
}
@@ -652,7 +652,7 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs = get_file_storage();
$syscontext = context_system::instance();
- $this->setExpectedException('file_exception');
+ $this->expectException('file_exception');
$fs->create_directory($syscontext->id, 'core', 'unittest', -1, '/');
}
@@ -660,7 +660,7 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs = get_file_storage();
$syscontext = context_system::instance();
- $this->setExpectedException('file_exception');
+ $this->expectException('file_exception');
$fs->create_directory($syscontext->id, 'core', 'unittest', 'notanint', '/');
}
@@ -668,7 +668,7 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs = get_file_storage();
$syscontext = context_system::instance();
- $this->setExpectedException('file_exception');
+ $this->expectException('file_exception');
$fs->create_directory($syscontext->id, 'core', 'unittest', 0, '/not-with-trailing/or-leading-slash');
}
@@ -1062,17 +1062,24 @@ class core_files_file_storage_testcase extends advanced_testcase {
return $filerecord;
}
+ /**
+ * @expectedException file_exception
+ */
public function test_create_file_from_storedfile_file_invalid() {
$this->resetAfterTest(true);
$filerecord = $this->generate_file_record();
$fs = get_file_storage();
- $this->setExpectedException('file_exception');
+
// Create a file from a file id which doesn't exist.
$fs->create_file_from_storedfile($filerecord, 9999);
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid contextid
+ */
public function test_create_file_from_storedfile_contextid_invalid() {
$this->resetAfterTest(true);
@@ -1085,10 +1092,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->filename = 'invalid.txt';
$filerecord->contextid = 'invalid';
- $this->setExpectedException('file_exception', 'Invalid contextid');
$fs->create_file_from_storedfile($filerecord, $file1->get_id());
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid component
+ */
public function test_create_file_from_storedfile_component_invalid() {
$this->resetAfterTest(true);
@@ -1101,10 +1111,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->filename = 'invalid.txt';
$filerecord->component = 'bad/component';
- $this->setExpectedException('file_exception', 'Invalid component');
$fs->create_file_from_storedfile($filerecord, $file1->get_id());
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid filearea
+ */
public function test_create_file_from_storedfile_filearea_invalid() {
$this->resetAfterTest(true);
@@ -1117,10 +1130,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->filename = 'invalid.txt';
$filerecord->filearea = 'bad-filearea';
- $this->setExpectedException('file_exception', 'Invalid filearea');
$fs->create_file_from_storedfile($filerecord, $file1->get_id());
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid itemid
+ */
public function test_create_file_from_storedfile_itemid_invalid() {
$this->resetAfterTest(true);
@@ -1133,10 +1149,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->filename = 'invalid.txt';
$filerecord->itemid = 'bad-itemid';
- $this->setExpectedException('file_exception', 'Invalid itemid');
$fs->create_file_from_storedfile($filerecord, $file1->get_id());
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid file path
+ */
public function test_create_file_from_storedfile_filepath_invalid() {
$this->resetAfterTest(true);
@@ -1149,10 +1168,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->filename = 'invalid.txt';
$filerecord->filepath = 'a-/bad/-filepath';
- $this->setExpectedException('file_exception', 'Invalid file path');
$fs->create_file_from_storedfile($filerecord, $file1->get_id());
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid file name
+ */
public function test_create_file_from_storedfile_filename_invalid() {
$this->resetAfterTest(true);
@@ -1164,10 +1186,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->filename = '';
- $this->setExpectedException('file_exception', 'Invalid file name');
$fs->create_file_from_storedfile($filerecord, $file1->get_id());
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid file timecreated
+ */
public function test_create_file_from_storedfile_timecreated_invalid() {
$this->resetAfterTest(true);
@@ -1180,10 +1205,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->filename = 'invalid.txt';
$filerecord->timecreated = 'today';
- $this->setExpectedException('file_exception', 'Invalid file timecreated');
$fs->create_file_from_storedfile($filerecord, $file1->get_id());
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid file timemodified
+ */
public function test_create_file_from_storedfile_timemodified_invalid() {
$this->resetAfterTest(true);
@@ -1196,10 +1224,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->filename = 'invalid.txt';
$filerecord->timemodified = 'today';
- $this->setExpectedException('file_exception', 'Invalid file timemodified');
$fs->create_file_from_storedfile($filerecord, $file1->get_id());
}
+ /**
+ * @expectedException stored_file_creation_exception
+ * @expectedExceptionMessage Can not create file "1/core/phpunit/0/testfile.txt"
+ */
public function test_create_file_from_storedfile_duplicate() {
$this->resetAfterTest(true);
@@ -1210,7 +1241,6 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertInstanceOf('stored_file', $file1);
// Creating a file validating unique constraint.
- $this->setExpectedException('stored_file_creation_exception', 'Can not create file "1/core/phpunit/0/testfile.txt"');
$fs->create_file_from_storedfile($filerecord, $file1->get_id());
}
@@ -1248,6 +1278,10 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertNotEquals($file3->get_timecreated(), $filerecord->timecreated);
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid contextid
+ */
public function test_create_file_from_string_contextid_invalid() {
$this->resetAfterTest(true);
@@ -1256,10 +1290,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->contextid = 'invalid';
- $this->setExpectedException('file_exception', 'Invalid contextid');
$file1 = $fs->create_file_from_string($filerecord, 'text contents');
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid component
+ */
public function test_create_file_from_string_component_invalid() {
$this->resetAfterTest(true);
@@ -1268,10 +1305,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->component = 'bad/component';
- $this->setExpectedException('file_exception', 'Invalid component');
$file1 = $fs->create_file_from_string($filerecord, 'text contents');
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid filearea
+ */
public function test_create_file_from_string_filearea_invalid() {
$this->resetAfterTest(true);
@@ -1280,10 +1320,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->filearea = 'bad-filearea';
- $this->setExpectedException('file_exception', 'Invalid filearea');
$file1 = $fs->create_file_from_string($filerecord, 'text contents');
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid itemid
+ */
public function test_create_file_from_string_itemid_invalid() {
$this->resetAfterTest(true);
@@ -1292,10 +1335,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->itemid = 'bad-itemid';
- $this->setExpectedException('file_exception', 'Invalid itemid');
$file1 = $fs->create_file_from_string($filerecord, 'text contents');
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid file path
+ */
public function test_create_file_from_string_filepath_invalid() {
$this->resetAfterTest(true);
@@ -1304,10 +1350,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->filepath = 'a-/bad/-filepath';
- $this->setExpectedException('file_exception', 'Invalid file path');
$file1 = $fs->create_file_from_string($filerecord, 'text contents');
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid file name
+ */
public function test_create_file_from_string_filename_invalid() {
$this->resetAfterTest(true);
@@ -1316,10 +1365,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->filename = '';
- $this->setExpectedException('file_exception', 'Invalid file name');
$file1 = $fs->create_file_from_string($filerecord, 'text contents');
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid file timecreated
+ */
public function test_create_file_from_string_timecreated_invalid() {
$this->resetAfterTest(true);
@@ -1328,10 +1380,15 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->timecreated = 'today';
- $this->setExpectedException('file_exception', 'Invalid file timecreated');
+ $this->expectException('file_exception');
+ $this->expectExceptionMessage('Invalid file timecreated');
$file1 = $fs->create_file_from_string($filerecord, 'text contents');
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid file timemodified
+ */
public function test_create_file_from_string_timemodified_invalid() {
$this->resetAfterTest(true);
@@ -1340,7 +1397,6 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->timemodified = 'today';
- $this->setExpectedException('file_exception', 'Invalid file timemodified');
$file1 = $fs->create_file_from_string($filerecord, 'text contents');
}
@@ -1353,10 +1409,14 @@ class core_files_file_storage_testcase extends advanced_testcase {
$file1 = $fs->create_file_from_string($filerecord, 'text contents');
// Creating a file validating unique constraint.
- $this->setExpectedException('stored_file_creation_exception');
+ $this->expectException('stored_file_creation_exception');
$file2 = $fs->create_file_from_string($filerecord, 'text contents');
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid contextid
+ */
public function test_create_file_from_pathname_contextid_invalid() {
global $CFG;
$path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg';
@@ -1368,10 +1428,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->contextid = 'invalid';
- $this->setExpectedException('file_exception', 'Invalid contextid');
$file1 = $fs->create_file_from_pathname($filerecord, $path);
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid component
+ */
public function test_create_file_from_pathname_component_invalid() {
global $CFG;
$path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg';
@@ -1383,10 +1446,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->component = 'bad/component';
- $this->setExpectedException('file_exception', 'Invalid component');
$file1 = $fs->create_file_from_pathname($filerecord, $path);
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid filearea
+ */
public function test_create_file_from_pathname_filearea_invalid() {
global $CFG;
$path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg';
@@ -1398,10 +1464,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->filearea = 'bad-filearea';
- $this->setExpectedException('file_exception', 'Invalid filearea');
$file1 = $fs->create_file_from_pathname($filerecord, $path);
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid itemid
+ */
public function test_create_file_from_pathname_itemid_invalid() {
global $CFG;
$path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg';
@@ -1413,10 +1482,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->itemid = 'bad-itemid';
- $this->setExpectedException('file_exception', 'Invalid itemid');
- $file1 = $fs->create_file_from_pathname($filerecord, $path);
+ $file1 = $fs->create_file_from_pathname($filerecord, $path);
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid file path
+ */
public function test_create_file_from_pathname_filepath_invalid() {
global $CFG;
$path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg';
@@ -1428,10 +1500,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->filepath = 'a-/bad/-filepath';
- $this->setExpectedException('file_exception', 'Invalid file path');
$file1 = $fs->create_file_from_pathname($filerecord, $path);
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid file name
+ */
public function test_create_file_from_pathname_filename_invalid() {
global $CFG;
$path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg';
@@ -1443,10 +1518,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->filename = '';
- $this->setExpectedException('file_exception', 'Invalid file name');
$file1 = $fs->create_file_from_pathname($filerecord, $path);
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid file timecreated
+ */
public function test_create_file_from_pathname_timecreated_invalid() {
global $CFG;
$path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg';
@@ -1458,10 +1536,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->timecreated = 'today';
- $this->setExpectedException('file_exception', 'Invalid file timecreated');
$file1 = $fs->create_file_from_pathname($filerecord, $path);
}
+ /**
+ * @expectedException file_exception
+ * @expectedExceptionMessage Invalid file timemodified
+ */
public function test_create_file_from_pathname_timemodified_invalid() {
global $CFG;
$path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg';
@@ -1473,10 +1554,13 @@ class core_files_file_storage_testcase extends advanced_testcase {
$filerecord->timemodified = 'today';
- $this->setExpectedException('file_exception', 'Invalid file timemodified');
$file1 = $fs->create_file_from_pathname($filerecord, $path);
}
+ /**
+ * @expectedException stored_file_creation_exception
+ * @expectedExceptionMessage Can not create file "1/core/phpunit/0/testfile.txt"
+ */
public function test_create_file_from_pathname_duplicate_file() {
global $CFG;
$this->resetAfterTest(true);
@@ -1490,7 +1574,6 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertInstanceOf('stored_file', $file1);
// Creating a file validating unique constraint.
- $this->setExpectedException('stored_file_creation_exception', 'Can not create file "1/core/phpunit/0/testfile.txt"');
$file2 = $fs->create_file_from_pathname($filerecord, $path);
}
@@ -1515,7 +1598,7 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertInstanceOf('stored_file', $file);
$this->assertFalse($file->is_external_file());
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
$file->delete_reference();
}
@@ -1745,7 +1828,7 @@ class core_files_file_storage_testcase extends advanced_testcase {
$newfilename = $fs->get_unused_filename($contextid, $component, $filearea, $itemid, $filepath, 'Hurray! (1).php');
$this->assertEquals('Hurray! (3).php', $newfilename);
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
$fs->get_unused_filename($contextid, $component, $filearea, $itemid, $filepath, '');
}
}
diff --git a/lib/phpunit/classes/base_testcase.php b/lib/phpunit/classes/base_testcase.php
index dd1dc8f6aa4..231ce1f4198 100644
--- a/lib/phpunit/classes/base_testcase.php
+++ b/lib/phpunit/classes/base_testcase.php
@@ -37,6 +37,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class base_testcase extends PHPUnit_Framework_TestCase {
+ // @codingStandardsIgnoreStart
+ // Following code is legacy code from phpunit to support assertTag
+ // and assertNotTag.
+
/**
* Note: we are overriding this method to remove the deprecated error
* @see https://tracker.moodle.org/browse/MDL-47129
@@ -50,7 +54,7 @@ abstract class base_testcase extends PHPUnit_Framework_TestCase {
*/
public static function assertTag($matcher, $actual, $message = '', $ishtml = true) {
$dom = PHPUnit_Util_XML::load($actual, $ishtml);
- $tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $ishtml);
+ $tags = self::findNodes($dom, $matcher, $ishtml);
$matched = count($tags) > 0 && $tags[0] instanceof DOMNode;
self::assertTrue($matched, $message);
}
@@ -68,8 +72,503 @@ abstract class base_testcase extends PHPUnit_Framework_TestCase {
*/
public static function assertNotTag($matcher, $actual, $message = '', $ishtml = true) {
$dom = PHPUnit_Util_XML::load($actual, $ishtml);
- $tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $ishtml);
+ $tags = self::findNodes($dom, $matcher, $ishtml);
$matched = count($tags) > 0 && $tags[0] instanceof DOMNode;
self::assertFalse($matched, $message);
}
+
+ /**
+ * Validate list of keys in the associative array.
+ *
+ * @param array $hash
+ * @param array $validKeys
+ *
+ * @return array
+ *
+ * @throws PHPUnit_Framework_Exception
+ */
+ public static function assertValidKeys(array $hash, array $validKeys) {
+ $valids = array();
+
+ // Normalize validation keys so that we can use both indexed and
+ // associative arrays.
+ foreach ($validKeys as $key => $val) {
+ is_int($key) ? $valids[$val] = null : $valids[$key] = $val;
+ }
+
+ $validKeys = array_keys($valids);
+
+ // Check for invalid keys.
+ foreach ($hash as $key => $value) {
+ if (!in_array($key, $validKeys)) {
+ $unknown[] = $key;
+ }
+ }
+
+ if (!empty($unknown)) {
+ throw new PHPUnit_Framework_Exception(
+ 'Unknown key(s): ' . implode(', ', $unknown)
+ );
+ }
+
+ // Add default values for any valid keys that are empty.
+ foreach ($valids as $key => $value) {
+ if (!isset($hash[$key])) {
+ $hash[$key] = $value;
+ }
+ }
+
+ return $hash;
+ }
+
+ /**
+ * Parse out the options from the tag using DOM object tree.
+ *
+ * @param DOMDocument $dom
+ * @param array $options
+ * @param bool $isHtml
+ *
+ * @return array
+ */
+ public static function findNodes(DOMDocument $dom, array $options, $isHtml = true) {
+ $valid = array(
+ 'id', 'class', 'tag', 'content', 'attributes', 'parent',
+ 'child', 'ancestor', 'descendant', 'children', 'adjacent-sibling'
+ );
+
+ $filtered = array();
+ $options = self::assertValidKeys($options, $valid);
+
+ // find the element by id
+ if ($options['id']) {
+ $options['attributes']['id'] = $options['id'];
+ }
+
+ if ($options['class']) {
+ $options['attributes']['class'] = $options['class'];
+ }
+
+ $nodes = array();
+
+ // find the element by a tag type
+ if ($options['tag']) {
+ if ($isHtml) {
+ $elements = self::getElementsByCaseInsensitiveTagName(
+ $dom,
+ $options['tag']
+ );
+ } else {
+ $elements = $dom->getElementsByTagName($options['tag']);
+ }
+
+ foreach ($elements as $element) {
+ $nodes[] = $element;
+ }
+
+ if (empty($nodes)) {
+ return false;
+ }
+ } // no tag selected, get them all
+ else {
+ $tags = array(
+ 'a', 'abbr', 'acronym', 'address', 'area', 'b', 'base', 'bdo',
+ 'big', 'blockquote', 'body', 'br', 'button', 'caption', 'cite',
+ 'code', 'col', 'colgroup', 'dd', 'del', 'div', 'dfn', 'dl',
+ 'dt', 'em', 'fieldset', 'form', 'frame', 'frameset', 'h1', 'h2',
+ 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'html', 'i', 'iframe',
+ 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'link',
+ 'map', 'meta', 'noframes', 'noscript', 'object', 'ol', 'optgroup',
+ 'option', 'p', 'param', 'pre', 'q', 'samp', 'script', 'select',
+ 'small', 'span', 'strong', 'style', 'sub', 'sup', 'table',
+ 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title',
+ 'tr', 'tt', 'ul', 'var',
+ // HTML5
+ 'article', 'aside', 'audio', 'bdi', 'canvas', 'command',
+ 'datalist', 'details', 'dialog', 'embed', 'figure', 'figcaption',
+ 'footer', 'header', 'hgroup', 'keygen', 'mark', 'meter', 'nav',
+ 'output', 'progress', 'ruby', 'rt', 'rp', 'track', 'section',
+ 'source', 'summary', 'time', 'video', 'wbr'
+ );
+
+ foreach ($tags as $tag) {
+ if ($isHtml) {
+ $elements = self::getElementsByCaseInsensitiveTagName(
+ $dom,
+ $tag
+ );
+ } else {
+ $elements = $dom->getElementsByTagName($tag);
+ }
+
+ foreach ($elements as $element) {
+ $nodes[] = $element;
+ }
+ }
+
+ if (empty($nodes)) {
+ return false;
+ }
+ }
+
+ // filter by attributes
+ if ($options['attributes']) {
+ foreach ($nodes as $node) {
+ $invalid = false;
+
+ foreach ($options['attributes'] as $name => $value) {
+ // match by regexp if like "regexp:/foo/i"
+ if (preg_match('/^regexp\s*:\s*(.*)/i', $value, $matches)) {
+ if (!preg_match($matches[1], $node->getAttribute($name))) {
+ $invalid = true;
+ }
+ } // class can match only a part
+ elseif ($name == 'class') {
+ // split to individual classes
+ $findClasses = explode(
+ ' ',
+ preg_replace("/\s+/", ' ', $value)
+ );
+
+ $allClasses = explode(
+ ' ',
+ preg_replace("/\s+/", ' ', $node->getAttribute($name))
+ );
+
+ // make sure each class given is in the actual node
+ foreach ($findClasses as $findClass) {
+ if (!in_array($findClass, $allClasses)) {
+ $invalid = true;
+ }
+ }
+ } // match by exact string
+ else {
+ if ($node->getAttribute($name) != $value) {
+ $invalid = true;
+ }
+ }
+ }
+
+ // if every attribute given matched
+ if (!$invalid) {
+ $filtered[] = $node;
+ }
+ }
+
+ $nodes = $filtered;
+ $filtered = array();
+
+ if (empty($nodes)) {
+ return false;
+ }
+ }
+
+ // filter by content
+ if ($options['content'] !== null) {
+ foreach ($nodes as $node) {
+ $invalid = false;
+
+ // match by regexp if like "regexp:/foo/i"
+ if (preg_match('/^regexp\s*:\s*(.*)/i', $options['content'], $matches)) {
+ if (!preg_match($matches[1], self::getNodeText($node))) {
+ $invalid = true;
+ }
+ } // match empty string
+ elseif ($options['content'] === '') {
+ if (self::getNodeText($node) !== '') {
+ $invalid = true;
+ }
+ } // match by exact string
+ elseif (strstr(self::getNodeText($node), $options['content']) === false) {
+ $invalid = true;
+ }
+
+ if (!$invalid) {
+ $filtered[] = $node;
+ }
+ }
+
+ $nodes = $filtered;
+ $filtered = array();
+
+ if (empty($nodes)) {
+ return false;
+ }
+ }
+
+ // filter by parent node
+ if ($options['parent']) {
+ $parentNodes = self::findNodes($dom, $options['parent'], $isHtml);
+ $parentNode = isset($parentNodes[0]) ? $parentNodes[0] : null;
+
+ foreach ($nodes as $node) {
+ if ($parentNode !== $node->parentNode) {
+ continue;
+ }
+
+ $filtered[] = $node;
+ }
+
+ $nodes = $filtered;
+ $filtered = array();
+
+ if (empty($nodes)) {
+ return false;
+ }
+ }
+
+ // filter by child node
+ if ($options['child']) {
+ $childNodes = self::findNodes($dom, $options['child'], $isHtml);
+ $childNodes = !empty($childNodes) ? $childNodes : array();
+
+ foreach ($nodes as $node) {
+ foreach ($node->childNodes as $child) {
+ foreach ($childNodes as $childNode) {
+ if ($childNode === $child) {
+ $filtered[] = $node;
+ }
+ }
+ }
+ }
+
+ $nodes = $filtered;
+ $filtered = array();
+
+ if (empty($nodes)) {
+ return false;
+ }
+ }
+
+ // filter by adjacent-sibling
+ if ($options['adjacent-sibling']) {
+ $adjacentSiblingNodes = self::findNodes($dom, $options['adjacent-sibling'], $isHtml);
+ $adjacentSiblingNodes = !empty($adjacentSiblingNodes) ? $adjacentSiblingNodes : array();
+
+ foreach ($nodes as $node) {
+ $sibling = $node;
+
+ while ($sibling = $sibling->nextSibling) {
+ if ($sibling->nodeType !== XML_ELEMENT_NODE) {
+ continue;
+ }
+
+ foreach ($adjacentSiblingNodes as $adjacentSiblingNode) {
+ if ($sibling === $adjacentSiblingNode) {
+ $filtered[] = $node;
+ break;
+ }
+ }
+
+ break;
+ }
+ }
+
+ $nodes = $filtered;
+ $filtered = array();
+
+ if (empty($nodes)) {
+ return false;
+ }
+ }
+
+ // filter by ancestor
+ if ($options['ancestor']) {
+ $ancestorNodes = self::findNodes($dom, $options['ancestor'], $isHtml);
+ $ancestorNode = isset($ancestorNodes[0]) ? $ancestorNodes[0] : null;
+
+ foreach ($nodes as $node) {
+ $parent = $node->parentNode;
+
+ while ($parent && $parent->nodeType != XML_HTML_DOCUMENT_NODE) {
+ if ($parent === $ancestorNode) {
+ $filtered[] = $node;
+ }
+
+ $parent = $parent->parentNode;
+ }
+ }
+
+ $nodes = $filtered;
+ $filtered = array();
+
+ if (empty($nodes)) {
+ return false;
+ }
+ }
+
+ // filter by descendant
+ if ($options['descendant']) {
+ $descendantNodes = self::findNodes($dom, $options['descendant'], $isHtml);
+ $descendantNodes = !empty($descendantNodes) ? $descendantNodes : array();
+
+ foreach ($nodes as $node) {
+ foreach (self::getDescendants($node) as $descendant) {
+ foreach ($descendantNodes as $descendantNode) {
+ if ($descendantNode === $descendant) {
+ $filtered[] = $node;
+ }
+ }
+ }
+ }
+
+ $nodes = $filtered;
+ $filtered = array();
+
+ if (empty($nodes)) {
+ return false;
+ }
+ }
+
+ // filter by children
+ if ($options['children']) {
+ $validChild = array('count', 'greater_than', 'less_than', 'only');
+ $childOptions = self::assertValidKeys(
+ $options['children'],
+ $validChild
+ );
+
+ foreach ($nodes as $node) {
+ $childNodes = $node->childNodes;
+
+ foreach ($childNodes as $childNode) {
+ if ($childNode->nodeType !== XML_CDATA_SECTION_NODE &&
+ $childNode->nodeType !== XML_TEXT_NODE) {
+ $children[] = $childNode;
+ }
+ }
+
+ // we must have children to pass this filter
+ if (!empty($children)) {
+ // exact count of children
+ if ($childOptions['count'] !== null) {
+ if (count($children) !== $childOptions['count']) {
+ break;
+ }
+ } // range count of children
+ elseif ($childOptions['less_than'] !== null &&
+ $childOptions['greater_than'] !== null) {
+ if (count($children) >= $childOptions['less_than'] ||
+ count($children) <= $childOptions['greater_than']) {
+ break;
+ }
+ } // less than a given count
+ elseif ($childOptions['less_than'] !== null) {
+ if (count($children) >= $childOptions['less_than']) {
+ break;
+ }
+ } // more than a given count
+ elseif ($childOptions['greater_than'] !== null) {
+ if (count($children) <= $childOptions['greater_than']) {
+ break;
+ }
+ }
+
+ // match each child against a specific tag
+ if ($childOptions['only']) {
+ $onlyNodes = self::findNodes(
+ $dom,
+ $childOptions['only'],
+ $isHtml
+ );
+
+ // try to match each child to one of the 'only' nodes
+ foreach ($children as $child) {
+ $matched = false;
+
+ foreach ($onlyNodes as $onlyNode) {
+ if ($onlyNode === $child) {
+ $matched = true;
+ }
+ }
+
+ if (!$matched) {
+ break 2;
+ }
+ }
+ }
+
+ $filtered[] = $node;
+ }
+ }
+
+ $nodes = $filtered;
+
+ if (empty($nodes)) {
+ return;
+ }
+ }
+
+ // return the first node that matches all criteria
+ return !empty($nodes) ? $nodes : array();
+ }
+
+ /**
+ * Recursively get flat array of all descendants of this node.
+ *
+ * @param DOMNode $node
+ *
+ * @return array
+ */
+ protected static function getDescendants(DOMNode $node) {
+ $allChildren = array();
+ $childNodes = $node->childNodes ? $node->childNodes : array();
+
+ foreach ($childNodes as $child) {
+ if ($child->nodeType === XML_CDATA_SECTION_NODE ||
+ $child->nodeType === XML_TEXT_NODE) {
+ continue;
+ }
+
+ $children = self::getDescendants($child);
+ $allChildren = array_merge($allChildren, $children, array($child));
+ }
+
+ return isset($allChildren) ? $allChildren : array();
+ }
+
+ /**
+ * Gets elements by case insensitive tagname.
+ *
+ * @param DOMDocument $dom
+ * @param string $tag
+ *
+ * @return DOMNodeList
+ */
+ protected static function getElementsByCaseInsensitiveTagName(DOMDocument $dom, $tag) {
+ $elements = $dom->getElementsByTagName(strtolower($tag));
+
+ if ($elements->length == 0) {
+ $elements = $dom->getElementsByTagName(strtoupper($tag));
+ }
+
+ return $elements;
+ }
+
+ /**
+ * Get the text value of this node's child text node.
+ *
+ * @param DOMNode $node
+ *
+ * @return string
+ */
+ protected static function getNodeText(DOMNode $node) {
+ if (!$node->childNodes instanceof DOMNodeList) {
+ return '';
+ }
+
+ $result = '';
+
+ foreach ($node->childNodes as $childNode) {
+ if ($childNode->nodeType === XML_TEXT_NODE ||
+ $childNode->nodeType === XML_CDATA_SECTION_NODE) {
+ $result .= trim($childNode->data) . ' ';
+ } else {
+ $result .= self::getNodeText($childNode);
+ }
+ }
+
+ return str_replace(' ', ' ', $result);
+ }
+
+ // @codingStandardsIgnoreEnd
}
diff --git a/lib/phpunit/classes/unittestcase.php b/lib/phpunit/classes/unittestcase.php
deleted file mode 100644
index 6058cc6eb93..00000000000
--- a/lib/phpunit/classes/unittestcase.php
+++ /dev/null
@@ -1,193 +0,0 @@
-.
-
-/**
- * Legacy SimpleTest layer.
- *
- * @deprecated since 2.3
- * @package core
- * @category phpunit
- * @author Petr Skoda
- * @copyright 2012 Petr Skoda {@link http://skodak.org}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-
-/**
- * Simplified emulation test case for legacy SimpleTest.
- *
- * Note: this is supposed to work for very simple tests only.
- *
- * @deprecated since 2.3
- * @package core
- * @category phpunit
- * @author Petr Skoda
- * @copyright 2012 Petr Skoda {@link http://skodak.org}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-abstract class UnitTestCase extends PHPUnit_Framework_TestCase {
-
- /**
- * @deprecated since 2.3
- * @param bool $expected
- * @param string $message
- * @return void
- */
- public function expectException($expected, $message = '') {
- // alternatively use phpdocs: @expectedException ExceptionClassName
- if (!$expected) {
- return;
- }
- $this->setExpectedException('moodle_exception', $message);
- }
-
- /**
- * @deprecated since 2.3
- * @param bool $expected
- * @param string $message
- * @return void
- */
- public function expectError($expected = false, $message = '') {
- // alternatively use phpdocs: @expectedException PHPUnit_Framework_Error
- if (!$expected) {
- return;
- }
- $this->setExpectedException('PHPUnit_Framework_Error', $message);
- }
-
- /**
- * @deprecated since 2.3
- * @static
- * @param mixed $actual
- * @param string $messages
- * @return void
- */
- public static function assertTrue($actual, $messages = '') {
- parent::assertTrue((bool)$actual, $messages);
- }
-
- /**
- * @deprecated since 2.3
- * @static
- * @param mixed $actual
- * @param string $messages
- * @return void
- */
- public static function assertFalse($actual, $messages = '') {
- parent::assertFalse((bool)$actual, $messages);
- }
-
- /**
- * @deprecated since 2.3
- * @static
- * @param mixed $expected
- * @param mixed $actual
- * @param string $message
- * @return void
- */
- public static function assertEqual($expected, $actual, $message = '') {
- parent::assertEquals($expected, $actual, $message);
- }
-
- /**
- * @deprecated since 2.3
- * @static
- * @param mixed $expected
- * @param mixed $actual
- * @param float|int $margin
- * @param string $message
- * @return void
- */
- public static function assertWithinMargin($expected, $actual, $margin, $message = '') {
- parent::assertEquals($expected, $actual, '', $margin, $message);
- }
-
- /**
- * @deprecated since 2.3
- * @static
- * @param mixed $expected
- * @param mixed $actual
- * @param string $message
- * @return void
- */
- public static function assertNotEqual($expected, $actual, $message = '') {
- parent::assertNotEquals($expected, $actual, $message);
- }
-
- /**
- * @deprecated since 2.3
- * @static
- * @param mixed $expected
- * @param mixed $actual
- * @param string $message
- * @return void
- */
- public static function assertIdentical($expected, $actual, $message = '') {
- parent::assertSame($expected, $actual, $message);
- }
-
- /**
- * @deprecated since 2.3
- * @static
- * @param mixed $expected
- * @param mixed $actual
- * @param string $message
- * @return void
- */
- public static function assertNotIdentical($expected, $actual, $message = '') {
- parent::assertNotSame($expected, $actual, $message);
- }
-
- /**
- * @deprecated since 2.3
- * @static
- * @param mixed $actual
- * @param mixed $expected
- * @param string $message
- * @return void
- */
- public static function assertIsA($actual, $expected, $message = '') {
- if ($expected === 'array') {
- parent::assertEquals('array', gettype($actual), $message);
- } else {
- parent::assertInstanceOf($expected, $actual, $message);
- }
- }
-
- /**
- * @deprecated since 2.3
- * @static
- * @param mixed $pattern
- * @param mixed $string
- * @param string $message
- * @return void
- */
- public static function assertPattern($pattern, $string, $message = '') {
- parent::assertRegExp($pattern, $string, $message);
- }
-
- /**
- * @deprecated since 2.3
- * @static
- * @param mixed $pattern
- * @param mixed $string
- * @param string $message
- * @return void
- */
- public static function assertNotPattern($pattern, $string, $message = '') {
- parent::assertNotRegExp($pattern, $string, $message);
- }
-}
diff --git a/lib/phpunit/lib.php b/lib/phpunit/lib.php
index f271690da51..3a70ac0ac3d 100644
--- a/lib/phpunit/lib.php
+++ b/lib/phpunit/lib.php
@@ -35,7 +35,6 @@ require_once(__DIR__.'/classes/basic_testcase.php');
require_once(__DIR__.'/classes/database_driver_testcase.php');
require_once(__DIR__.'/classes/arraydataset.php');
require_once(__DIR__.'/classes/advanced_testcase.php');
-require_once(__DIR__.'/classes/unittestcase.php');
require_once(__DIR__.'/classes/hint_resultprinter.php'); // Loaded here because phpunit.xml does not support relative links for printerFile.
require_once(__DIR__.'/classes/constraint_object_is_equal_with_exceptions.php');
require_once(__DIR__.'/../testing/classes/test_lock.php');
diff --git a/lib/phpunit/phpunit.xsd b/lib/phpunit/phpunit.xsd
index 700f41aa537..1ffa321ef65 100644
--- a/lib/phpunit/phpunit.xsd
+++ b/lib/phpunit/phpunit.xsd
@@ -1,8 +1,8 @@
-
+
-
- This Schema file defines the rules by which the XML configuration file of PHPUnit 4.7 may be structured.
+
+ This Schema file defines the rules by which the XML configuration file of PHPUnit 5.4 may be structured.
@@ -14,7 +14,6 @@
-
@@ -118,20 +117,23 @@
+
+
+
-
+
@@ -160,17 +162,19 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -195,53 +199,46 @@
-
+
-
-
-
-
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/lib/phpunit/tests/advanced_test.php b/lib/phpunit/tests/advanced_test.php
index cf00787a6ab..36fde30f29a 100644
--- a/lib/phpunit/tests/advanced_test.php
+++ b/lib/phpunit/tests/advanced_test.php
@@ -296,7 +296,7 @@ class core_phpunit_advanced_testcase extends advanced_testcase {
} catch (moodle_exception $e) {
$this->assertInstanceOf('dml_exception', $e);
}
- $DB = $this->getMock(get_class($DB));
+ $DB = $this->createMock(get_class($DB));
$this->assertNull($DB->get_record('pokus', array()));
// Rest continues after reset.
}
diff --git a/lib/testing/tests/generator_test.php b/lib/testing/tests/generator_test.php
index c80d600b922..ba6e012edc2 100644
--- a/lib/testing/tests/generator_test.php
+++ b/lib/testing/tests/generator_test.php
@@ -47,9 +47,13 @@ class core_test_generator_testcase extends advanced_testcase {
$this->assertInstanceOf('mod_quiz_generator', $generator);
}
+ /**
+ * Test plugin generator, with no component directory.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Component core_completion does not support generators yet. Missing tests/generator/lib.php.
+ */
public function test_get_plugin_generator_no_component_dir() {
- $this->setExpectedException('coding_exception', 'Component core_completion does not support ' .
- 'generators yet. Missing tests/generator/lib.php.');
$generator = $this->getDataGenerator()->get_plugin_generator('core_completion');
}
diff --git a/lib/tests/ajaxlib_test.php b/lib/tests/ajaxlib_test.php
index f32f84e562f..18b459463a2 100644
--- a/lib/tests/ajaxlib_test.php
+++ b/lib/tests/ajaxlib_test.php
@@ -70,7 +70,7 @@ class core_ajaxlib_testcase extends advanced_testcase {
echo $content;
if ($expectexception) {
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
ajax_check_captured_output();
} else {
$result = ajax_check_captured_output();
diff --git a/lib/tests/completionlib_test.php b/lib/tests/completionlib_test.php
index d9a75de7af5..ee008efa4c5 100644
--- a/lib/tests/completionlib_test.php
+++ b/lib/tests/completionlib_test.php
@@ -40,7 +40,7 @@ class core_completionlib_testcase extends advanced_testcase {
$this->resetAfterTest();
- $DB = $this->getMock(get_class($DB));
+ $DB = $this->createMock(get_class($DB));
$CFG->enablecompletion = COMPLETION_ENABLED;
$USER = (object)array('id' =>314159);
}
@@ -127,7 +127,11 @@ class core_completionlib_testcase extends advanced_testcase {
public function test_update_state() {
$this->mock_setup();
- $c = $this->getMock('completion_info', array('is_enabled', 'get_data', 'internal_get_state', 'internal_set_data'), array((object)array('id'=>42)));
+ $mockbuilder = $this->getMockBuilder('completion_info');
+ $mockbuilder->setMethods(array('is_enabled', 'get_data', 'internal_get_state', 'internal_set_data'));
+ $mockbuilder->setConstructorArgs(array((object)array('id' => 42)));
+ $c = $mockbuilder->getMock();
+
$cm = (object)array('id'=>13, 'course'=>42);
// Not enabled, should do nothing.
@@ -223,7 +227,11 @@ class core_completionlib_testcase extends advanced_testcase {
global $DB;
$this->mock_setup();
- $c = $this->getMock('completion_info', array('internal_get_grade_state'), array((object)array('id'=>42)));
+ $mockbuilder = $this->getMockBuilder('completion_info');
+ $mockbuilder->setMethods(array('internal_get_grade_state'));
+ $mockbuilder->setConstructorArgs(array((object)array('id' => 42)));
+ $c = $mockbuilder->getMock();
+
$cm = (object)array('id'=>13, 'course'=>42, 'completiongradeitemnumber'=>null);
// If view is required, but they haven't viewed it yet.
@@ -256,9 +264,10 @@ class core_completionlib_testcase extends advanced_testcase {
public function test_set_module_viewed() {
$this->mock_setup();
- $c = $this->getMock('completion_info',
- array('delete_all_state', 'get_tracked_users', 'update_state', 'internal_get_grade_state', 'is_enabled', 'get_data', 'internal_get_state', 'internal_set_data'),
- array((object)array('id'=>42)));
+ $mockbuilder = $this->getMockBuilder('completion_info');
+ $mockbuilder->setMethods(array('is_enabled', 'get_data', 'internal_set_data', 'update_state'));
+ $mockbuilder->setConstructorArgs(array((object)array('id' => 42)));
+ $c = $mockbuilder->getMock();
$cm = (object)array('id'=>13, 'course'=>42);
// Not tracking completion, should do nothing.
@@ -341,9 +350,10 @@ class core_completionlib_testcase extends advanced_testcase {
global $DB;
$this->mock_setup();
- $c = $this->getMock('completion_info',
- array('delete_all_state', 'get_tracked_users', 'update_state', 'internal_get_grade_state', 'is_enabled', 'get_data', 'internal_get_state', 'internal_set_data'),
- array((object)array('id'=>42)));
+ $mockbuilder = $this->getMockBuilder('completion_info');
+ $mockbuilder->setMethods(array('delete_all_state', 'get_tracked_users', 'update_state'));
+ $mockbuilder->setConstructorArgs(array((object)array('id' => 42)));
+ $c = $mockbuilder->getMock();
$cm = (object)array('id'=>13, 'course'=>42, 'completion'=>COMPLETION_TRACKING_AUTOMATIC);
@@ -516,9 +526,10 @@ class core_completionlib_testcase extends advanced_testcase {
global $DB;
$this->mock_setup();
- $c = $this->getMock('completion_info',
- array('delete_all_state', 'get_tracked_users', 'update_state', 'internal_get_grade_state', 'is_enabled', 'get_data', 'internal_get_state', 'internal_set_data'),
- array((object)array('id'=>42)));
+ $mockbuilder = $this->getMockBuilder('completion_info');
+ $mockbuilder->setMethods(array('get_tracked_users'));
+ $mockbuilder->setConstructorArgs(array((object)array('id' => 42)));
+ $c = $mockbuilder->getMock();
// 1) Basic usage.
$c->expects($this->at(0))
@@ -593,9 +604,10 @@ class core_completionlib_testcase extends advanced_testcase {
public function test_inform_grade_changed() {
$this->mock_setup();
- $c = $this->getMock('completion_info',
- array('delete_all_state', 'get_tracked_users', 'update_state', 'internal_get_grade_state', 'is_enabled', 'get_data', 'internal_get_state', 'internal_set_data'),
- array((object)array('id'=>42)));
+ $mockbuilder = $this->getMockBuilder('completion_info');
+ $mockbuilder->setMethods(array('is_enabled', 'update_state'));
+ $mockbuilder->setConstructorArgs(array((object)array('id' => 42)));
+ $c = $mockbuilder->getMock();
$cm = (object)array('course'=>42, 'id'=>13, 'completion'=>0, 'completiongradeitemnumber'=>null);
$item = (object)array('itemnumber'=>3, 'gradepass'=>1, 'hidden'=>0);
diff --git a/lib/tests/externallib_test.php b/lib/tests/externallib_test.php
index f67947d75f5..d6a922c0a00 100644
--- a/lib/tests/externallib_test.php
+++ b/lib/tests/externallib_test.php
@@ -258,7 +258,7 @@ class core_externallib_testcase extends advanced_testcase {
$singlestructure['object'] = $object;
$singlestructure['value2'] = 'Some text';
$testdata = array($singlestructure);
- $this->setExpectedException('invalid_response_exception');
+ $this->expectException('invalid_response_exception');
$cleanedvalue = external_api::clean_returnvalue($returndesc, $testdata);
}
/*
@@ -305,7 +305,7 @@ class core_externallib_testcase extends advanced_testcase {
$this->assertEquals($realcontext, $fetchedcontext);
// Passing wrong level.
- $this->setExpectedException('invalid_parameter_exception');
+ $this->expectException('invalid_parameter_exception');
$fetchedcontext = test_exernal_api::get_context_wrapper(array("contextlevel" => "random", "instanceid" => $course->id));
}
@@ -316,7 +316,7 @@ class core_externallib_testcase extends advanced_testcase {
global $USER;
// Call without correct context details.
- $this->setExpectedException('invalid_parameter_exception');
+ $this->expectException('invalid_parameter_exception');
test_exernal_api::get_context_wrapper(array('roleid' => 3, 'userid' => $USER->id));
}
@@ -327,7 +327,7 @@ class core_externallib_testcase extends advanced_testcase {
global $USER;
// Call without correct context details.
- $this->setExpectedException('invalid_parameter_exception');
+ $this->expectException('invalid_parameter_exception');
test_exernal_api::get_context_wrapper(array('roleid' => 3, 'userid' => $USER->id, 'contextlevel' => "course"));
}
@@ -340,7 +340,7 @@ class core_externallib_testcase extends advanced_testcase {
// Call without correct context details.
$this->resetAfterTest(true);
$course = self::getDataGenerator()->create_course();
- $this->setExpectedException('invalid_parameter_exception');
+ $this->expectException('invalid_parameter_exception');
test_exernal_api::get_context_wrapper(array('roleid' => 3, 'userid' => $USER->id, 'instanceid' => $course->id));
}
diff --git a/lib/tests/grading_externallib_test.php b/lib/tests/grading_externallib_test.php
index 300ec24a049..7d2984facd1 100644
--- a/lib/tests/grading_externallib_test.php
+++ b/lib/tests/grading_externallib_test.php
@@ -536,7 +536,7 @@ class core_grading_externallib_testcase extends externallib_advanced_testcase {
$this->assertEquals(2, $DB->count_records('gradingform_rubric_levels', array('criterionid' => $criterion1->id)));
$gradingarea['activemethod'] = 'invalid';
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$results = core_grading_external::save_definitions(array($gradingarea));
}
@@ -637,7 +637,7 @@ class core_grading_externallib_testcase extends externallib_advanced_testcase {
// Test an invalid method in the definition.
$guidedefinition['method'] = 'invalid';
$gradingarea['definitions'] = array($guidedefinition);
- $this->setExpectedException('invalid_parameter_exception');
+ $this->expectException('invalid_parameter_exception');
$results = core_grading_external::save_definitions(array($gradingarea));
}
}
diff --git a/lib/tests/moodle_page_test.php b/lib/tests/moodle_page_test.php
index 8132ac0abff..1f4091e1aef 100644
--- a/lib/tests/moodle_page_test.php
+++ b/lib/tests/moodle_page_test.php
@@ -83,32 +83,38 @@ class core_moodle_page_testcase extends advanced_testcase {
$this->assertSame($originalcourse, $COURSE);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_cannot_set_course_once_theme_set() {
// Setup fixture.
$this->testpage->force_theme(theme_config::DEFAULT_THEME);
$course = $this->getDataGenerator()->create_course();
- // Set expectation.
- $this->setExpectedException('coding_exception');
+
// Exercise SUT.
$this->testpage->set_course($course);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_cannot_set_category_once_theme_set() {
// Setup fixture.
$this->testpage->force_theme(theme_config::DEFAULT_THEME);
- // Set expectation.
- $this->setExpectedException('coding_exception');
+
// Exercise SUT.
$this->testpage->set_category_by_id(123);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_cannot_set_category_once_course_set() {
// Setup fixture.
$course = $this->getDataGenerator()->create_course();
$this->testpage->set_context(context_system::instance()); // Avoid trying to set the context.
$this->testpage->set_course($course);
- // Set expectation.
- $this->setExpectedException('coding_exception');
+
// Exercise SUT.
$this->testpage->set_category_by_id(123);
}
@@ -139,9 +145,10 @@ class core_moodle_page_testcase extends advanced_testcase {
$this->assertEquals(moodle_page::STATE_DONE, $this->testpage->state);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_set_state_cannot_skip_one() {
- // Set expectation.
- $this->setExpectedException('coding_exception');
// Exercise SUT.
$this->testpage->set_state(moodle_page::STATE_IN_BODY);
}
@@ -381,13 +388,14 @@ class core_moodle_page_testcase extends advanced_testcase {
$this->assertEquals($cm->id, $this->testpage->cm->id);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_cannot_set_activity_record_before_cm() {
// Setup fixture.
$course = $this->getDataGenerator()->create_course();
$forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id));
$cm = get_coursemodule_from_id('forum', $forum->cmid);
- // Set expectation.
- $this->setExpectedException('coding_exception');
// Exercise SUT.
$this->testpage->set_activity_record($forum);
}
@@ -428,27 +436,29 @@ class core_moodle_page_testcase extends advanced_testcase {
$this->assertEquals($forum, $this->testpage->activityrecord);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_cannot_set_inconsistent_activity_record_course() {
// Setup fixture.
$course = $this->getDataGenerator()->create_course();
$forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id));
$cm = get_coursemodule_from_id('forum', $forum->cmid);
$this->testpage->set_cm($cm);
- // Set expectation.
- $this->setExpectedException('coding_exception');
// Exercise SUT.
$forum->course = 13;
$this->testpage->set_activity_record($forum);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_cannot_set_inconsistent_activity_record_instance() {
// Setup fixture.
$course = $this->getDataGenerator()->create_course();
$forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id));
$cm = get_coursemodule_from_id('forum', $forum->cmid);
$this->testpage->set_cm($cm);
- // Set expectation.
- $this->setExpectedException('coding_exception');
// Exercise SUT.
$forum->id = 13;
$this->testpage->set_activity_record($forum);
@@ -480,13 +490,14 @@ class core_moodle_page_testcase extends advanced_testcase {
$this->assertEquals($forum, $this->testpage->activityrecord);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_cannot_set_cm_with_inconsistent_course() {
// Setup fixture.
$course = $this->getDataGenerator()->create_course();
$forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id));
$cm = get_coursemodule_from_id('forum', $forum->cmid);
- // Set expectation.
- $this->setExpectedException('coding_exception');
// Exercise SUT.
$cm->course = 13;
$this->testpage->set_cm($cm, $course);
diff --git a/lib/tests/outputrequirementslib_test.php b/lib/tests/outputrequirementslib_test.php
index 717520565e7..a517c5dbdbb 100644
--- a/lib/tests/outputrequirementslib_test.php
+++ b/lib/tests/outputrequirementslib_test.php
@@ -36,7 +36,7 @@ class core_outputrequirementslib_testcase extends advanced_testcase {
$page = new moodle_page();
$page->requires->string_for_js('course', 'moodle', 1);
$page->requires->string_for_js('course', 'moodle', 1);
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
$page->requires->string_for_js('course', 'moodle', 2);
// Note: we can not switch languages in phpunit yet,
@@ -52,7 +52,7 @@ class core_outputrequirementslib_testcase extends advanced_testcase {
public function test_one_time_output_repeat_output_throws() {
$page = new moodle_page();
$page->requires->set_one_time_item_created('test_item');
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
$page->requires->set_one_time_item_created('test_item');
}
diff --git a/lib/tests/setuplib_test.php b/lib/tests/setuplib_test.php
index 10d2cee69e4..5097fd63149 100644
--- a/lib/tests/setuplib_test.php
+++ b/lib/tests/setuplib_test.php
@@ -181,9 +181,8 @@ class core_setuplib_testcase extends advanced_testcase {
$this->assertFalse(make_unique_writable_directory($base, false));
// Now check for exception.
- $this->setExpectedException('invalid_dataroot_permissions',
- $base . ' is not writable. Unable to create a unique directory within it.'
- );
+ $this->expectException('invalid_dataroot_permissions');
+ $this->expectExceptionMessage($base . ' is not writable. Unable to create a unique directory within it.');
make_unique_writable_directory($base);
unlink($base);
diff --git a/lib/tests/update_checker_test.php b/lib/tests/update_checker_test.php
index 4139f18890a..08052c8bf56 100644
--- a/lib/tests/update_checker_test.php
+++ b/lib/tests/update_checker_test.php
@@ -55,12 +55,13 @@ class core_update_checker_testcase extends advanced_testcase {
/**
* If there are no fetched data yet, the first cron should fetch them.
+ *
+ * @expectedException \core\update\testable_checker_cron_executed
*/
public function test_cron_initial_fetch() {
$provider = testable_checker::instance();
$provider->fakerecentfetch = null;
$provider->fakecurrenttimestamp = -1;
- $this->setExpectedException('\core\update\testable_checker_cron_executed');
$provider->cron();
}
@@ -77,12 +78,13 @@ class core_update_checker_testcase extends advanced_testcase {
/**
* If there is an outdated fetch, the cron execution is expected.
+ *
+ * @expectedException \core\update\testable_checker_cron_executed
*/
public function test_cron_has_outdated_fetch() {
$provider = testable_checker::instance();
$provider->fakerecentfetch = time() - 49 * HOURSECS; // Fetched 49 hours ago.
$provider->fakecurrenttimestamp = -1;
- $this->setExpectedException('\core\update\testable_checker_cron_executed');
$provider->cron();
}
@@ -257,12 +259,14 @@ class core_update_checker_testcase extends advanced_testcase {
$this->assertEquals(2011010102, $cmp['mod_foo'][0]['version']);
}
+ /**
+ * @expectedException \core\update\checker_exception
+ */
public function test_compare_responses_invalid_format() {
$provider = testable_checker::instance();
$broken = array(
'status' => 'ERROR' // No 'updates' key here.
);
- $this->setExpectedException('\core\update\checker_exception');
$cmp = $provider->compare_responses($broken, $broken);
}
diff --git a/lib/tests/update_code_manager_test.php b/lib/tests/update_code_manager_test.php
index cbf4717cdee..b127c714a8b 100644
--- a/lib/tests/update_code_manager_test.php
+++ b/lib/tests/update_code_manager_test.php
@@ -111,12 +111,14 @@ class core_update_code_manager_testcase extends advanced_testcase {
$files = $codeman->unzip_plugin_file($zipfilepath, $targetdir, 'bar');
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_unzip_plugin_file_multidir() {
$codeman = new \core\update\testable_code_manager();
$zipfilepath = __DIR__.'/fixtures/update_validator/zips/multidir.zip';
$targetdir = make_request_directory();
// Attempting to rename the root folder if there are multiple ones should lead to exception.
- $this->setExpectedException('moodle_exception');
$files = $codeman->unzip_plugin_file($zipfilepath, $targetdir, 'foo');
}
diff --git a/lib/tests/user_test.php b/lib/tests/user_test.php
index 7aea5a4ec53..626f270ba44 100644
--- a/lib/tests/user_test.php
+++ b/lib/tests/user_test.php
@@ -308,10 +308,11 @@ class core_user_testcase extends advanced_testcase {
// Try to fetch type of a non-existent properties.
$nonexistingproperty = 'userfullname';
- $this->setExpectedException('coding_exception', 'Invalid property requested: ' . $nonexistingproperty);
+ $this->expectException('coding_exception');
+ $this->expectExceptionMessage('Invalid property requested: ' . $nonexistingproperty);
core_user::get_property_type($nonexistingproperty);
$nonexistingproperty = 'mobilenumber';
- $this->setExpectedException('coding_exception', 'Invalid property requested: ' . $nonexistingproperty);
+ $this->expectExceptionMessage('Invalid property requested: ' . $nonexistingproperty);
core_user::get_property_type($nonexistingproperty);
}
@@ -331,10 +332,11 @@ class core_user_testcase extends advanced_testcase {
// Try to fetch type of a non-existent properties.
$nonexistingproperty = 'lastnamefonetic';
- $this->setExpectedException('coding_exception', 'Invalid property requested: ' . $nonexistingproperty);
+ $this->expectException('coding_exception');
+ $this->expectExceptionMessage('Invalid property requested: ' . $nonexistingproperty);
core_user::get_property_null($nonexistingproperty);
$nonexistingproperty = 'midlename';
- $this->setExpectedException('coding_exception', 'Invalid property requested: ' . $nonexistingproperty);
+ $this->expectExceptionMessage('Invalid property requested: ' . $nonexistingproperty);
core_user::get_property_null($nonexistingproperty);
}
@@ -365,15 +367,20 @@ class core_user_testcase extends advanced_testcase {
// Try to fetch type of a non-existent properties.
$nonexistingproperty = 'language';
- $this->setExpectedException('coding_exception', 'Invalid property requested: ' . $nonexistingproperty);
+ $this->expectException('coding_exception');
+ $this->expectExceptionMessage('Invalid property requested: ' . $nonexistingproperty);
core_user::get_property_null($nonexistingproperty);
$nonexistingproperty = 'coutries';
- $this->setExpectedException('coding_exception', 'Invalid property requested: ' . $nonexistingproperty);
+ $this->expectExceptionMessage('Invalid property requested: ' . $nonexistingproperty);
core_user::get_property_null($nonexistingproperty);
}
/**
* Test get_property_default().
+ *
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Invalid property requested, or the property does not has a default value.
*/
public function test_get_property_default() {
global $CFG;
@@ -401,7 +408,6 @@ class core_user_testcase extends advanced_testcase {
$timezone = core_user::get_property_default('timezone');
$this->assertEquals('Pacific/Auckland', $timezone);
- $this->setExpectedException('coding_exception', 'Invalid property requested, or the property does not has a default value.');
core_user::get_property_default('firstname');
}
diff --git a/lib/tests/weblib_test.php b/lib/tests/weblib_test.php
index 73165b37bb4..a8c10f62ad9 100644
--- a/lib/tests/weblib_test.php
+++ b/lib/tests/weblib_test.php
@@ -258,10 +258,11 @@ class core_weblib_testcase extends advanced_testcase {
/**
* Test set bad scheme on Moodle URL objects.
+ *
+ * @expectedException coding_exception
*/
public function test_moodle_url_set_bad_scheme() {
$url = new moodle_url('http://moodle.org/foo/bar');
- $this->setExpectedException('coding_exception');
$url->set_scheme('not a valid $ scheme');
}
diff --git a/lib/upgrade.txt b/lib/upgrade.txt
index 4f353de0571..a88a639d800 100644
--- a/lib/upgrade.txt
+++ b/lib/upgrade.txt
@@ -26,6 +26,10 @@ information provided here is intended especially for developers.
- get_records_csv() Please use csv_import_reader::load_csv_content() instead.
- put_records_csv() Please use download_as_dataformat (lib/dataformatlib.php) instead.
* The password_compat library was removed as it is no longer required.
+* Phpunit has been upgraded to 5.4.x and following has been deprecated and is not used any more:
+ - setExpectedException(), use @expectedException or $this->expectException() and $this->expectExceptionMessage()
+ - getMock(), use createMock() or getMockBuilder()->getMock()
+ - UnitTestCase class is removed.
=== 3.1 ===
diff --git a/message/tests/externallib_test.php b/message/tests/externallib_test.php
index f1e555b0e9f..e2bf202bf68 100644
--- a/message/tests/externallib_test.php
+++ b/message/tests/externallib_test.php
@@ -339,6 +339,7 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
/**
* Test search_contacts.
+ * @expectedException moodle_exception
*/
public function test_search_contacts() {
global $DB;
@@ -400,7 +401,6 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
$this->assertEquals($user5->id, $result['id']);
// Empty query, will throw an exception.
- $this->setExpectedException('moodle_exception');
$results = core_message_external::search_contacts('');
}
diff --git a/mod/assign/tests/externallib_test.php b/mod/assign/tests/externallib_test.php
index 74d480e0a5e..f671bfa2b70 100644
--- a/mod/assign/tests/externallib_test.php
+++ b/mod/assign/tests/externallib_test.php
@@ -517,6 +517,8 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
/**
* Test lock_submissions
+ *
+ * @expectedException moodle_exception
*/
public function test_lock_submissions() {
global $DB, $USER;
@@ -576,7 +578,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
'text'=>'Submission text',
'format'=>FORMAT_MOODLE);
$notices = array();
- $this->setExpectedException('moodle_exception');
$assign->save_submission($data, $notices);
}
@@ -781,6 +782,8 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
/**
* Test reveal_identities
+ *
+ * @expectedException required_capability_exception
*/
public function test_reveal_identities() {
global $DB, $USER;
@@ -814,7 +817,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
$studentrole->id);
$this->setUser($student1);
- $this->setExpectedException('required_capability_exception');
$result = mod_assign_external::reveal_identities($instance->id);
$result = external_api::clean_returnvalue(mod_assign_external::reveal_identities_returns(), $result);
$this->assertEquals(1, count($result));
@@ -1229,6 +1231,8 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
/**
* Test save grades for a team submission
+ *
+ * @expectedException invalid_parameter_exception
*/
public function test_save_grades_with_group_submission() {
global $DB, $USER, $CFG;
@@ -1321,7 +1325,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
$student2gradeinfo['plugindata'] = $feedbackpluginparams;
$grades1[] = $student2gradeinfo;
- $this->setExpectedException('invalid_parameter_exception');
// Expect an exception since 2 grades have been submitted for the same team.
$result = mod_assign_external::save_grades($instance->id, true, $grades1);
$result = external_api::clean_returnvalue(mod_assign_external::save_grades_returns(), $result);
@@ -1533,6 +1536,8 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
/**
* Test view_grading_table
+ *
+ * @expectedException dml_missing_record_exception
*/
public function test_view_grading_table_invalid_instance() {
global $DB;
@@ -1546,12 +1551,13 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
$cm = get_coursemodule_from_instance('assign', $assign->id);
// Test invalid instance id.
- $this->setExpectedExceptionRegexp('dml_missing_record_exception');
mod_assign_external::view_grading_table(0);
}
/**
* Test view_grading_table
+ *
+ * @expectedException require_login_exception
*/
public function test_view_grading_table_not_enrolled() {
global $DB;
@@ -1568,7 +1574,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
$user = self::getDataGenerator()->create_user();
$this->setUser($user);
- $this->setExpectedException('require_login_exception');
mod_assign_external::view_grading_table($assign->id);
}
@@ -1613,6 +1618,9 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
/**
* Test view_grading_table
+ *
+ * @expectedException require_login_exception
+ * @expectedExceptionMessage Course or activity not accessible. (Activity is hidden)
*/
public function test_view_grading_table_without_capability() {
global $DB;
@@ -1638,7 +1646,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
accesslib_clear_all_caches_for_unit_testing();
course_modinfo::clear_instance_cache();
- $this->setExpectedException('require_login_exception', 'Course or activity not accessible. (Activity is hidden)');
mod_assign_external::view_grading_table($assign->id);
}
@@ -2029,6 +2036,8 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
/**
* Test access control for get_submission_status.
+ *
+ * @expectedException required_capability_exception
*/
public function test_get_submission_status_access_control() {
$this->resetAfterTest(true);
@@ -2038,23 +2047,25 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
$this->setUser($student2);
// Access control test.
- $this->setExpectedException('required_capability_exception');
mod_assign_external::get_submission_status($assign->get_instance()->id, $student1->id);
}
/**
* get_participant should throw an excaption if the requested assignment doesn't exist.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_participant_no_assignment() {
$this->resetAfterTest(true);
- $this->setExpectedException('moodle_exception');
mod_assign_external::get_participant('-1', '-1', false);
}
/**
* get_participant should throw a require_login_exception if the user doesn't have access
* to view assignments.
+ *
+ * @expectedException require_login_exception
*/
public function test_get_participant_no_view_capability() {
global $DB;
@@ -2070,13 +2081,14 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
$this->setUser($student);
assign_capability('mod/assign:view', CAP_PROHIBIT, $studentrole->id, $context->id, true);
- $this->setExpectedException('require_login_exception');
mod_assign_external::get_participant($assign->id, $student->id, false);
}
/**
* get_participant should throw a required_capability_exception if the user doesn't have access
* to view assignment grades.
+ *
+ * @expectedException required_capability_exception
*/
public function test_get_participant_no_grade_capability() {
global $DB;
@@ -2095,12 +2107,13 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
assign_capability('mod/assign:grade', CAP_PROHIBIT, $teacherrole->id, $context->id, true);
accesslib_clear_all_caches_for_unit_testing();
- $this->setExpectedException('required_capability_exception');
mod_assign_external::get_participant($assign->id, $student->id, false);
}
/**
* get_participant should throw an exception if the user isn't enrolled in the course.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_participant_no_participant() {
global $DB;
@@ -2113,7 +2126,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
$this->setUser($teacher);
- $this->setExpectedException('moodle_exception');
$result = mod_assign_external::get_participant($assign->id, $student->id, false);
}
diff --git a/mod/assign/tests/locallib_test.php b/mod/assign/tests/locallib_test.php
index 1e0095a444d..e3c3adb5a03 100644
--- a/mod/assign/tests/locallib_test.php
+++ b/mod/assign/tests/locallib_test.php
@@ -85,7 +85,7 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
$nopermission = false;
$this->students[0]->ignoresesskey = true;
$this->setUser($this->students[0]);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$assign->reveal_identities();
$this->students[0]->ignoresesskey = false;
@@ -93,13 +93,13 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
$nopermission = false;
$this->teachers[0]->ignoresesskey = true;
$this->setUser($this->teachers[0]);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$assign->reveal_identities();
$this->teachers[0]->ignoresesskey = false;
// Test sesskey is required.
$this->setUser($this->editingteachers[0]);
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$assign->reveal_identities();
// Test editingteacher can reveal identities if sesskey is ignored.
@@ -2149,8 +2149,9 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
$this->assertNotEquals(true, strpos($output, $this->students[0]->lastname));
}
-
-
+ /**
+ * @expectedException moodle_exception
+ */
public function test_teacher_submit_for_student() {
global $PAGE;
@@ -2229,7 +2230,6 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
'format'=>FORMAT_MOODLE);
$notices = array();
- $this->setExpectedException('moodle_exception');
$assign->save_submission($data, $notices);
$sink->close();
diff --git a/mod/choice/tests/events_test.php b/mod/choice/tests/events_test.php
index d383ed47d8a..febe209d46a 100644
--- a/mod/choice/tests/events_test.php
+++ b/mod/choice/tests/events_test.php
@@ -126,6 +126,8 @@ class mod_choice_events_testcase extends advanced_testcase {
/**
* Test custom validations.
+ *
+ * @expectedException coding_exception
*/
public function test_answer_submitted_other_exception() {
// Generate user data.
@@ -139,7 +141,6 @@ class mod_choice_events_testcase extends advanced_testcase {
$eventdata['other'] = array();
// Make sure content identifier is always set.
- $this->setExpectedException('coding_exception');
$event = \mod_choice\event\answer_submitted::create($eventdata);
$event->trigger();
$this->assertEventContextNotUsed($event);
@@ -180,8 +181,9 @@ class mod_choice_events_testcase extends advanced_testcase {
}
/**
- * Test custom validations
- * for answer_updated event.
+ * Test custom validations for answer_updated event.
+ *
+ * @expectedException coding_exception
*/
public function test_answer_updated_other_exception() {
// Generate user data.
@@ -195,7 +197,6 @@ class mod_choice_events_testcase extends advanced_testcase {
$eventdata['other'] = array();
// Make sure content identifier is always set.
- $this->setExpectedException('coding_exception');
$event = \mod_choice\event\answer_updated::create($eventdata);
$event->trigger();
$this->assertEventContextNotUsed($event);
diff --git a/mod/choice/tests/lib_test.php b/mod/choice/tests/lib_test.php
index dec8a9fdecb..a4d2ec64c24 100644
--- a/mod/choice/tests/lib_test.php
+++ b/mod/choice/tests/lib_test.php
@@ -131,6 +131,9 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_choice_user_submit_response_validation() {
global $USER;
@@ -149,7 +152,6 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
$optionids2 = array_keys($choicewithoptions2->option);
// Make sure we cannot submit options from a different choice instance.
- $this->setExpectedException('moodle_exception');
choice_user_submit_response($optionids2[0], $choice1, $USER->id, $course, $cm);
}
diff --git a/mod/forum/tests/events_test.php b/mod/forum/tests/events_test.php
index 96bd188f25d..9bbd159c7e0 100644
--- a/mod/forum/tests/events_test.php
+++ b/mod/forum/tests/events_test.php
@@ -54,6 +54,9 @@ class mod_forum_events_testcase extends advanced_testcase {
/**
* Ensure course_searched event validates that searchterm is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'searchterm' value must be set in other.
*/
public function test_course_searched_searchterm_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -62,12 +65,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'context' => $coursectx,
);
- $this->setExpectedException('coding_exception', 'The \'searchterm\' value must be set in other.');
\mod_forum\event\course_searched::create($params);
}
/**
* Ensure course_searched event validates that context is the correct level.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_COURSE.
*/
public function test_course_searched_context_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -78,7 +83,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('searchterm' => 'testing'),
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_COURSE.');
\mod_forum\event\course_searched::create($params);
}
@@ -119,6 +123,9 @@ class mod_forum_events_testcase extends advanced_testcase {
/**
* Ensure discussion_created event validates that forumid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumid' value must be set in other.
*/
public function test_discussion_created_forumid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -129,12 +136,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'context' => $context,
);
- $this->setExpectedException('coding_exception', 'The \'forumid\' value must be set in other.');
\mod_forum\event\discussion_created::create($params);
}
/**
* Ensure discussion_created event validates that the context is the correct level.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_discussion_created_context_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -145,7 +154,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('forumid' => $forum->id),
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE.');
\mod_forum\event\discussion_created::create($params);
}
@@ -196,6 +204,9 @@ class mod_forum_events_testcase extends advanced_testcase {
/**
* Ensure discussion_updated event validates that forumid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumid' value must be set in other.
*/
public function test_discussion_updated_forumid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -206,12 +217,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'context' => $context,
);
- $this->setExpectedException('coding_exception', 'The \'forumid\' value must be set in other.');
\mod_forum\event\discussion_updated::create($params);
}
/**
* Ensure discussion_created event validates that the context is the correct level.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_discussion_updated_context_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -222,7 +235,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('forumid' => $forum->id),
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE.');
\mod_forum\event\discussion_updated::create($params);
}
@@ -271,6 +283,9 @@ class mod_forum_events_testcase extends advanced_testcase {
/**
* Ensure discussion_deleted event validates that forumid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumid' value must be set in other.
*/
public function test_discussion_deleted_forumid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -281,12 +296,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'context' => $context,
);
- $this->setExpectedException('coding_exception', 'The \'forumid\' value must be set in other.');
\mod_forum\event\discussion_deleted::create($params);
}
/**
* Ensure discussion_deleted event validates that context is of the correct level.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_discussion_deleted_context_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -297,7 +314,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('forumid' => $forum->id),
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE.');
\mod_forum\event\discussion_deleted::create($params);
}
@@ -347,6 +363,9 @@ class mod_forum_events_testcase extends advanced_testcase {
/**
* Ensure discussion_moved event validates that fromforumid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'fromforumid' value must be set in other.
*/
public function test_discussion_moved_fromforumid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -359,12 +378,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('toforumid' => $toforum->id)
);
- $this->setExpectedException('coding_exception', 'The \'fromforumid\' value must be set in other.');
\mod_forum\event\discussion_moved::create($params);
}
/**
* Ensure discussion_moved event validates that toforumid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'toforumid' value must be set in other.
*/
public function test_discussion_moved_toforumid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -377,12 +398,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('fromforumid' => $fromforum->id)
);
- $this->setExpectedException('coding_exception', 'The \'toforumid\' value must be set in other.');
\mod_forum\event\discussion_moved::create($params);
}
/**
* Ensure discussion_moved event validates that the context level is correct.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_discussion_moved_context_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -403,7 +426,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('fromforumid' => $fromforum->id, 'toforumid' => $toforum->id)
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE.');
\mod_forum\event\discussion_moved::create($params);
}
@@ -455,6 +477,9 @@ class mod_forum_events_testcase extends advanced_testcase {
/**
* Ensure discussion_viewed event validates that the contextlevel is correct.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_discussion_viewed_context_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -473,7 +498,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'objectid' => $discussion->id,
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE.');
\mod_forum\event\discussion_viewed::create($params);
}
@@ -522,6 +546,9 @@ class mod_forum_events_testcase extends advanced_testcase {
/**
* Ensure course_module_viewed event validates that the contextlevel is correct.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_course_module_viewed_context_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -532,7 +559,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'objectid' => $forum->id,
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE.');
\mod_forum\event\course_module_viewed::create($params);
}
@@ -574,6 +600,9 @@ class mod_forum_events_testcase extends advanced_testcase {
/**
* Ensure subscription_created event validates that the forumid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumid' value must be set in other.
*/
public function test_subscription_created_forumid_validation() {
$user = $this->getDataGenerator()->create_user();
@@ -585,12 +614,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'relateduserid' => $user->id,
);
- $this->setExpectedException('coding_exception', 'The \'forumid\' value must be set in other.');
\mod_forum\event\subscription_created::create($params);
}
/**
* Ensure subscription_created event validates that the relateduserid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'relateduserid' must be set.
*/
public function test_subscription_created_relateduserid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -601,12 +632,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'objectid' => $forum->id,
);
- $this->setExpectedException('coding_exception', 'The \'relateduserid\' must be set.');
\mod_forum\event\subscription_created::create($params);
}
/**
* Ensure subscription_created event validates that the contextlevel is correct.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_subscription_created_contextlevel_validation() {
$user = $this->getDataGenerator()->create_user();
@@ -619,7 +652,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'relateduserid' => $user->id,
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE.');
\mod_forum\event\subscription_created::create($params);
}
@@ -671,6 +703,9 @@ class mod_forum_events_testcase extends advanced_testcase {
/**
* Ensure subscription_deleted event validates that the forumid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumid' value must be set in other.
*/
public function test_subscription_deleted_forumid_validation() {
$user = $this->getDataGenerator()->create_user();
@@ -682,12 +717,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'relateduserid' => $user->id,
);
- $this->setExpectedException('coding_exception', 'The \'forumid\' value must be set in other.');
\mod_forum\event\subscription_deleted::create($params);
}
/**
* Ensure subscription_deleted event validates that the relateduserid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'relateduserid' must be set.
*/
public function test_subscription_deleted_relateduserid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -698,12 +735,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'objectid' => $forum->id,
);
- $this->setExpectedException('coding_exception', 'The \'relateduserid\' must be set.');
\mod_forum\event\subscription_deleted::create($params);
}
/**
* Ensure subscription_deleted event validates that the contextlevel is correct.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_subscription_deleted_contextlevel_validation() {
$user = $this->getDataGenerator()->create_user();
@@ -716,7 +755,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'relateduserid' => $user->id,
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE.');
\mod_forum\event\subscription_deleted::create($params);
}
@@ -768,6 +806,9 @@ class mod_forum_events_testcase extends advanced_testcase {
/**
* Ensure readtracking_enabled event validates that the forumid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumid' value must be set in other.
*/
public function test_readtracking_enabled_forumid_validation() {
$user = $this->getDataGenerator()->create_user();
@@ -779,12 +820,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'relateduserid' => $user->id,
);
- $this->setExpectedException('coding_exception', 'The \'forumid\' value must be set in other.');
\mod_forum\event\readtracking_enabled::create($params);
}
/**
* Ensure readtracking_enabled event validates that the relateduserid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'relateduserid' must be set.
*/
public function test_readtracking_enabled_relateduserid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -795,12 +838,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'objectid' => $forum->id,
);
- $this->setExpectedException('coding_exception', 'The \'relateduserid\' must be set.');
\mod_forum\event\readtracking_enabled::create($params);
}
/**
* Ensure readtracking_enabled event validates that the contextlevel is correct.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_readtracking_enabled_contextlevel_validation() {
$user = $this->getDataGenerator()->create_user();
@@ -813,7 +858,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'relateduserid' => $user->id,
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE.');
\mod_forum\event\readtracking_enabled::create($params);
}
@@ -856,6 +900,9 @@ class mod_forum_events_testcase extends advanced_testcase {
/**
* Ensure readtracking_disabled event validates that the forumid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumid' value must be set in other.
*/
public function test_readtracking_disabled_forumid_validation() {
$user = $this->getDataGenerator()->create_user();
@@ -867,12 +914,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'relateduserid' => $user->id,
);
- $this->setExpectedException('coding_exception', 'The \'forumid\' value must be set in other.');
\mod_forum\event\readtracking_disabled::create($params);
}
/**
* Ensure readtracking_disabled event validates that the relateduserid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'relateduserid' must be set.
*/
public function test_readtracking_disabled_relateduserid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -883,12 +932,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'objectid' => $forum->id,
);
- $this->setExpectedException('coding_exception', 'The \'relateduserid\' must be set.');
\mod_forum\event\readtracking_disabled::create($params);
}
/**
* Ensure readtracking_disabled event validates that the contextlevel is correct
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_readtracking_disabled_contextlevel_validation() {
$user = $this->getDataGenerator()->create_user();
@@ -901,7 +952,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'relateduserid' => $user->id,
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE.');
\mod_forum\event\readtracking_disabled::create($params);
}
@@ -944,6 +994,9 @@ class mod_forum_events_testcase extends advanced_testcase {
/**
* Ensure subscribers_viewed event validates that the forumid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumid' value must be set in other.
*/
public function test_subscribers_viewed_forumid_validation() {
$user = $this->getDataGenerator()->create_user();
@@ -955,12 +1008,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'relateduserid' => $user->id,
);
- $this->setExpectedException('coding_exception', 'The \'forumid\' value must be set in other.');
\mod_forum\event\subscribers_viewed::create($params);
}
/**
* Ensure subscribers_viewed event validates that the contextlevel is correct.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_subscribers_viewed_contextlevel_validation() {
$user = $this->getDataGenerator()->create_user();
@@ -973,7 +1028,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'relateduserid' => $user->id,
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE.');
\mod_forum\event\subscribers_viewed::create($params);
}
@@ -1011,7 +1065,10 @@ class mod_forum_events_testcase extends advanced_testcase {
}
/**
- * Ensure user_report_viewed event validates that the reportmode is set.
+ * Ensure user_report_viewed event validates that the reportmode is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'reportmode' value must be set in other.
*/
public function test_user_report_viewed_reportmode_validation() {
$user = $this->getDataGenerator()->create_user();
@@ -1022,12 +1079,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'relateduserid' => $user->id,
);
- $this->setExpectedException('coding_exception', 'The \'reportmode\' value must be set in other.');
\mod_forum\event\user_report_viewed::create($params);
}
/**
- * Ensure user_report_viewed event validates that the contextlevel is correct.
+ * Ensure user_report_viewed event validates that the contextlevel is correct.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be either CONTEXT_SYSTEM, CONTEXT_COURSE or CONTEXT_USER.
*/
public function test_user_report_viewed_contextlevel_validation() {
$user = $this->getDataGenerator()->create_user();
@@ -1040,13 +1099,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'relateduserid' => $user->id,
);
- $this->setExpectedException('coding_exception',
- 'Context level must be either CONTEXT_SYSTEM, CONTEXT_COURSE or CONTEXT_USER.');
\mod_forum\event\user_report_viewed::create($params);
}
/**
* Ensure user_report_viewed event validates that the relateduserid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'relateduserid' must be set.
*/
public function test_user_report_viewed_relateduserid_validation() {
@@ -1055,7 +1115,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('reportmode' => 'posts'),
);
- $this->setExpectedException('coding_exception', 'The \'relateduserid\' must be set.');
\mod_forum\event\user_report_viewed::create($params);
}
@@ -1118,7 +1177,10 @@ class mod_forum_events_testcase extends advanced_testcase {
}
/**
- * Ensure post_created event validates that the discussionid is set.
+ * Ensure post_created event validates that the discussionid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'discussionid' value must be set in other.
*/
public function test_post_created_discussionid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -1144,12 +1206,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type)
);
- $this->setExpectedException('coding_exception', 'The \'discussionid\' value must be set in other.');
\mod_forum\event\post_created::create($params);
}
/**
* Ensure post_created event validates that the forumid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumid' value must be set in other.
*/
public function test_post_created_forumid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -1175,12 +1239,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('discussionid' => $discussion->id, 'forumtype' => $forum->type)
);
- $this->setExpectedException('coding_exception', 'The \'forumid\' value must be set in other.');
\mod_forum\event\post_created::create($params);
}
/**
- * Ensure post_created event validates that the forumtype is set.
+ * Ensure post_created event validates that the forumtype is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumtype' value must be set in other.
*/
public function test_post_created_forumtype_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -1206,12 +1272,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id)
);
- $this->setExpectedException('coding_exception', 'The \'forumtype\' value must be set in other.');
\mod_forum\event\post_created::create($params);
}
/**
* Ensure post_created event validates that the contextlevel is correct.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_post_created_context_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -1237,7 +1305,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type)
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE');
\mod_forum\event\post_created::create($params);
}
@@ -1371,7 +1438,10 @@ class mod_forum_events_testcase extends advanced_testcase {
}
/**
- * Ensure post_deleted event validates that the discussionid is set.
+ * Ensure post_deleted event validates that the discussionid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'discussionid' value must be set in other.
*/
public function test_post_deleted_discussionid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -1397,12 +1467,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type)
);
- $this->setExpectedException('coding_exception', 'The \'discussionid\' value must be set in other.');
\mod_forum\event\post_deleted::create($params);
}
/**
* Ensure post_deleted event validates that the forumid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumid' value must be set in other.
*/
public function test_post_deleted_forumid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -1428,12 +1500,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('discussionid' => $discussion->id, 'forumtype' => $forum->type)
);
- $this->setExpectedException('coding_exception', 'The \'forumid\' value must be set in other.');
\mod_forum\event\post_deleted::create($params);
}
/**
- * Ensure post_deleted event validates that the forumtype is set.
+ * Ensure post_deleted event validates that the forumtype is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumtype' value must be set in other.
*/
public function test_post_deleted_forumtype_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -1459,12 +1533,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id)
);
- $this->setExpectedException('coding_exception', 'The \'forumtype\' value must be set in other.');
\mod_forum\event\post_deleted::create($params);
}
/**
* Ensure post_deleted event validates that the contextlevel is correct.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_post_deleted_context_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -1490,7 +1566,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type)
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE');
\mod_forum\event\post_deleted::create($params);
}
@@ -1622,7 +1697,10 @@ class mod_forum_events_testcase extends advanced_testcase {
}
/**
- * Ensure post_updated event validates that the discussionid is set.
+ * Ensure post_updated event validates that the discussionid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'discussionid' value must be set in other.
*/
public function test_post_updated_discussionid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -1648,12 +1726,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('forumid' => $forum->id, 'forumtype' => $forum->type)
);
- $this->setExpectedException('coding_exception', 'The \'discussionid\' value must be set in other.');
\mod_forum\event\post_updated::create($params);
}
/**
- * Ensure post_updated event validates that the forumid is set.
+ * Ensure post_updated event validates that the forumid is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumid' value must be set in other.
*/
public function test_post_updated_forumid_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -1679,12 +1759,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('discussionid' => $discussion->id, 'forumtype' => $forum->type)
);
- $this->setExpectedException('coding_exception', 'The \'forumid\' value must be set in other.');
\mod_forum\event\post_updated::create($params);
}
/**
- * Ensure post_updated event validates that the forumtype is set.
+ * Ensure post_updated event validates that the forumtype is set.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumtype' value must be set in other.
*/
public function test_post_updated_forumtype_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -1710,12 +1792,14 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id)
);
- $this->setExpectedException('coding_exception', 'The \'forumtype\' value must be set in other.');
\mod_forum\event\post_updated::create($params);
}
/**
* Ensure post_updated event validates that the contextlevel is correct.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_post_updated_context_validation() {
$course = $this->getDataGenerator()->create_course();
@@ -1741,7 +1825,6 @@ class mod_forum_events_testcase extends advanced_testcase {
'other' => array('discussionid' => $discussion->id, 'forumid' => $forum->id, 'forumtype' => $forum->type)
);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE');
\mod_forum\event\post_updated::create($params);
}
@@ -1968,6 +2051,9 @@ class mod_forum_events_testcase extends advanced_testcase {
/**
* Test contextlevel validation of discussion_subscription_created event.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_discussion_subscription_created_validation_contextlevel() {
global $CFG, $DB;
@@ -2016,12 +2102,14 @@ class mod_forum_events_testcase extends advanced_testcase {
);
// Without an invalid context.
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE.');
\mod_forum\event\discussion_subscription_created::create($params);
}
/**
* Test discussion validation of discussion_subscription_created event.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'discussion' value must be set in other.
*/
public function test_discussion_subscription_created_validation_discussion() {
global $CFG, $DB;
@@ -2067,12 +2155,14 @@ class mod_forum_events_testcase extends advanced_testcase {
)
);
- $this->setExpectedException('coding_exception', "The 'discussion' value must be set in other.");
\mod_forum\event\discussion_subscription_created::create($params);
}
/**
* Test forumid validation of discussion_subscription_created event.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumid' value must be set in other.
*/
public function test_discussion_subscription_created_validation_forumid() {
global $CFG, $DB;
@@ -2118,12 +2208,14 @@ class mod_forum_events_testcase extends advanced_testcase {
)
);
- $this->setExpectedException('coding_exception', "The 'forumid' value must be set in other.");
\mod_forum\event\discussion_subscription_created::create($params);
}
/**
* Test relateduserid validation of discussion_subscription_created event.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'relateduserid' must be set.
*/
public function test_discussion_subscription_created_validation_relateduserid() {
global $CFG, $DB;
@@ -2171,7 +2263,6 @@ class mod_forum_events_testcase extends advanced_testcase {
)
);
- $this->setExpectedException('coding_exception', "The 'relateduserid' must be set.");
\mod_forum\event\discussion_subscription_created::create($params);
}
@@ -2291,27 +2382,34 @@ class mod_forum_events_testcase extends advanced_testcase {
// Without an invalid context.
$params['context'] = \context_course::instance($course->id);
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE.');
+ $this->expectException('coding_exception');
+ $this->expectExceptionMessage('Context level must be CONTEXT_MODULE.');
\mod_forum\event\discussion_deleted::create($params);
// Without the discussion.
unset($params['discussion']);
- $this->setExpectedException('coding_exception', 'The \'discussion\' value must be set in other.');
+ $this->expectException('coding_exception');
+ $this->expectExceptionMessage('The \'discussion\' value must be set in other.');
\mod_forum\event\discussion_deleted::create($params);
// Without the forumid.
unset($params['forumid']);
- $this->setExpectedException('coding_exception', 'The \'forumid\' value must be set in other.');
+ $this->expectException('coding_exception');
+ $this->expectExceptionMessage('The \'forumid\' value must be set in other.');
\mod_forum\event\discussion_deleted::create($params);
// Without the relateduserid.
unset($params['relateduserid']);
- $this->setExpectedException('coding_exception', 'The \'relateduserid\' value must be set in other.');
+ $this->expectException('coding_exception');
+ $this->expectExceptionMessage('The \'relateduserid\' value must be set in other.');
\mod_forum\event\discussion_deleted::create($params);
}
/**
* Test contextlevel validation of discussion_subscription_deleted event.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage Context level must be CONTEXT_MODULE.
*/
public function test_discussion_subscription_deleted_validation_contextlevel() {
global $CFG, $DB;
@@ -2360,12 +2458,14 @@ class mod_forum_events_testcase extends advanced_testcase {
);
// Without an invalid context.
- $this->setExpectedException('coding_exception', 'Context level must be CONTEXT_MODULE.');
\mod_forum\event\discussion_subscription_deleted::create($params);
}
/**
* Test discussion validation of discussion_subscription_deleted event.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'discussion' value must be set in other.
*/
public function test_discussion_subscription_deleted_validation_discussion() {
global $CFG, $DB;
@@ -2411,12 +2511,14 @@ class mod_forum_events_testcase extends advanced_testcase {
)
);
- $this->setExpectedException('coding_exception', "The 'discussion' value must be set in other.");
\mod_forum\event\discussion_subscription_deleted::create($params);
}
/**
* Test forumid validation of discussion_subscription_deleted event.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'forumid' value must be set in other.
*/
public function test_discussion_subscription_deleted_validation_forumid() {
global $CFG, $DB;
@@ -2462,12 +2564,14 @@ class mod_forum_events_testcase extends advanced_testcase {
)
);
- $this->setExpectedException('coding_exception', "The 'forumid' value must be set in other.");
\mod_forum\event\discussion_subscription_deleted::create($params);
}
/**
* Test relateduserid validation of discussion_subscription_deleted event.
+ *
+ * @expectedException coding_exception
+ * @expectedExceptionMessage The 'relateduserid' must be set.
*/
public function test_discussion_subscription_deleted_validation_relateduserid() {
global $CFG, $DB;
@@ -2515,7 +2619,6 @@ class mod_forum_events_testcase extends advanced_testcase {
)
);
- $this->setExpectedException('coding_exception', "The 'relateduserid' must be set.");
\mod_forum\event\discussion_subscription_deleted::create($params);
}
diff --git a/mod/forum/tests/lib_test.php b/mod/forum/tests/lib_test.php
index 8e551a584d3..3453534017d 100644
--- a/mod/forum/tests/lib_test.php
+++ b/mod/forum/tests/lib_test.php
@@ -1422,7 +1422,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
$this->assertEmpty($neighbours['next']);
// Querying the neighbours of a discussion passing the wrong CM.
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
forum_get_discussion_neighbours($cm2, $disc11, $forum2);
}
@@ -1622,7 +1622,7 @@ class mod_forum_lib_testcase extends advanced_testcase {
$this->assertEmpty($neighbours['next']);
// Querying the neighbours of a discussion passing the wrong CM.
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
forum_get_discussion_neighbours($cm2, $disc11, $forum2);
}
@@ -3035,12 +3035,14 @@ class mod_forum_lib_testcase extends advanced_testcase {
$this->assertFalse(forum_is_author_hidden($post, $forum));
// Incorrect parameters: $post.
- $this->setExpectedException('coding_exception', '$post->parent must be set.');
+ $this->expectException('coding_exception');
+ $this->expectExceptionMessage('$post->parent must be set.');
unset($post->parent);
forum_is_author_hidden($post, $forum);
// Incorrect parameters: $forum.
- $this->setExpectedException('coding_exception', '$forum->type must be set.');
+ $this->expectException('coding_exception');
+ $this->expectExceptionMessage('$forum->type must be set.');
unset($forum->type);
forum_is_author_hidden($post, $forum);
}
diff --git a/mod/forum/tests/maildigest_test.php b/mod/forum/tests/maildigest_test.php
index b6940078c93..8dbb5e1738f 100644
--- a/mod/forum/tests/maildigest_test.php
+++ b/mod/forum/tests/maildigest_test.php
@@ -229,7 +229,7 @@ class mod_forum_maildigest_testcase extends advanced_testcase {
$this->assertFalse($currentsetting);
// Try with an invalid value.
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
forum_set_user_maildigest($forum1, 42, $user);
}
diff --git a/mod/glossary/tests/external_test.php b/mod/glossary/tests/external_test.php
index f05275b983f..be9c9892ecf 100644
--- a/mod/glossary/tests/external_test.php
+++ b/mod/glossary/tests/external_test.php
@@ -108,6 +108,10 @@ class mod_glossary_external_testcase extends externallib_advanced_testcase {
$sink->close();
}
+ /**
+ * @expectedException require_login_exception
+ * @expectedExceptionMessage Activity is hidden
+ */
public function test_view_glossary_without_permission() {
$this->resetAfterTest(true);
@@ -126,10 +130,13 @@ class mod_glossary_external_testcase extends externallib_advanced_testcase {
// Assertion.
$this->setUser($u1);
- $this->setExpectedException('require_login_exception', 'Activity is hidden');
mod_glossary_external::view_glossary($g1->id, 'letter');
}
+ /**
+ * @expectedException require_login_exception
+ * @expectedExceptionMessage Activity is hidden
+ */
public function test_view_entry() {
$this->resetAfterTest(true);
@@ -177,7 +184,6 @@ class mod_glossary_external_testcase extends externallib_advanced_testcase {
}
// Test non-readable entry.
- $this->setExpectedException('require_login_exception', 'Activity is hidden');
mod_glossary_external::view_entry($e4->id);
}
@@ -1034,7 +1040,7 @@ class mod_glossary_external_testcase extends externallib_advanced_testcase {
// Permissions are checked.
$this->setUser($u1);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
mod_glossary_external::get_entries_to_approve($g1->id, 'ALL', 'CONCEPT', 'ASC', 0, 1);
$this->fail('Do not test anything else after this.');
}
diff --git a/mod/lti/tests/externallib_test.php b/mod/lti/tests/externallib_test.php
index 07fc5b47ce4..ee5ae39e76a 100644
--- a/mod/lti/tests/externallib_test.php
+++ b/mod/lti/tests/externallib_test.php
@@ -299,7 +299,7 @@ class mod_lti_external_testcase extends externallib_advanced_testcase {
* Test create tool proxy with duplicate url
*/
public function test_mod_lti_create_tool_proxy_duplicateurl() {
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$proxy = mod_lti_external::create_tool_proxy('Test proxy 1', $this->getExternalTestFileUrl('/test.html'), array(), array());
$proxy = mod_lti_external::create_tool_proxy('Test proxy 2', $this->getExternalTestFileUrl('/test.html'), array(), array());
}
@@ -309,7 +309,7 @@ class mod_lti_external_testcase extends externallib_advanced_testcase {
*/
public function test_mod_lti_create_tool_proxy_without_capability() {
self::setUser($this->teacher);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$proxy = mod_lti_external::create_tool_proxy('Test proxy', $this->getExternalTestFileUrl('/test.html'), array(), array());
}
@@ -382,7 +382,7 @@ class mod_lti_external_testcase extends externallib_advanced_testcase {
* Test create tool type failure from non existant file
*/
public function test_mod_lti_create_tool_type_nonexistant_file() {
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$type = mod_lti_external::create_tool_type($this->getExternalTestFileUrl('/doesntexist.xml'), '', '');
}
@@ -390,7 +390,7 @@ class mod_lti_external_testcase extends externallib_advanced_testcase {
* Test create tool type failure from xml that is not a cartridge
*/
public function test_mod_lti_create_tool_type_bad_file() {
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$type = mod_lti_external::create_tool_type($this->getExternalTestFileUrl('/rsstest.xml'), '', '');
}
@@ -399,7 +399,7 @@ class mod_lti_external_testcase extends externallib_advanced_testcase {
*/
public function test_mod_lti_create_tool_type_without_capability() {
self::setUser($this->teacher);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$type = mod_lti_external::create_tool_type($this->getExternalTestFileUrl('/ims_cartridge_basic_lti_link.xml'), '', '');
}
@@ -430,7 +430,7 @@ class mod_lti_external_testcase extends externallib_advanced_testcase {
public function test_mod_lti_delete_tool_type_without_capability() {
$type = mod_lti_external::create_tool_type($this->getExternalTestFileUrl('/ims_cartridge_basic_lti_link.xml'), '', '');
$this->assertNotEmpty(lti_get_type($type['id']));
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
self::setUser($this->teacher);
$type = mod_lti_external::delete_tool_type($type['id']);
}
diff --git a/mod/quiz/tests/structure_test.php b/mod/quiz/tests/structure_test.php
index a8e39f82752..dd13daad623 100644
--- a/mod/quiz/tests/structure_test.php
+++ b/mod/quiz/tests/structure_test.php
@@ -259,6 +259,9 @@ class mod_quiz_structure_testcase extends advanced_testcase {
), $structure);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_cannot_remove_first_section() {
$quizobj = $this->create_test_quiz(array(
'Heading 1',
@@ -269,7 +272,6 @@ class mod_quiz_structure_testcase extends advanced_testcase {
$sections = $structure->get_sections();
$section = reset($sections);
- $this->setExpectedException('coding_exception');
$structure->remove_section_heading($section->id);
}
@@ -416,6 +418,9 @@ class mod_quiz_structure_testcase extends advanced_testcase {
), $structure);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_move_slot_too_small_page_number_detected() {
$quizobj = $this->create_test_quiz(array(
array('TF1', 1, 'truefalse'),
@@ -426,10 +431,12 @@ class mod_quiz_structure_testcase extends advanced_testcase {
$idtomove = $structure->get_question_in_slot(3)->slotid;
$idmoveafter = $structure->get_question_in_slot(2)->slotid;
- $this->setExpectedException('coding_exception');
$structure->move_slot($idtomove, $idmoveafter, '1');
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_move_slot_too_large_page_number_detected() {
$quizobj = $this->create_test_quiz(array(
array('TF1', 1, 'truefalse'),
@@ -440,7 +447,6 @@ class mod_quiz_structure_testcase extends advanced_testcase {
$idtomove = $structure->get_question_in_slot(1)->slotid;
$idmoveafter = $structure->get_question_in_slot(2)->slotid;
- $this->setExpectedException('coding_exception');
$structure->move_slot($idtomove, $idmoveafter, '4');
}
@@ -668,6 +674,9 @@ class mod_quiz_structure_testcase extends advanced_testcase {
$this->assertFalse($DB->record_exists('question', array('id' => $randomq->id)));
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_cannot_remove_last_slot_in_a_section() {
$quizobj = $this->create_test_quiz(array(
array('TF1', 1, 'truefalse'),
@@ -677,7 +686,6 @@ class mod_quiz_structure_testcase extends advanced_testcase {
));
$structure = \mod_quiz\structure::create_for_quiz($quizobj);
- $this->setExpectedException('coding_exception');
$structure->remove_slot(3);
}
diff --git a/mod/scorm/tests/events_test.php b/mod/scorm/tests/events_test.php
index a52cb0505fd..bf44adf56bf 100644
--- a/mod/scorm/tests/events_test.php
+++ b/mod/scorm/tests/events_test.php
@@ -57,7 +57,11 @@ class mod_scorm_event_testcase extends advanced_testcase {
$this->eventcm = get_coursemodule_from_instance('scorm', $this->eventscorm->id);
}
- /** Tests for attempt deleted event */
+ /**
+ * Tests for attempt deleted event
+ *
+ * @expectedException coding_exception
+ */
public function test_attempt_deleted_event() {
global $USER;
@@ -83,7 +87,6 @@ class mod_scorm_event_testcase extends advanced_testcase {
$this->assertEventContextNotUsed($event);
// Test event validations.
- $this->setExpectedException('coding_exception');
\mod_scorm\event\attempt_deleted::create(array(
'contextid' => 5,
'relateduserid' => 2
@@ -228,6 +231,8 @@ class mod_scorm_event_testcase extends advanced_testcase {
/** Tests for sco launched event.
*
* There is no api involved so the best we can do is test legacy data and validations by triggering event manually.
+ *
+ * @expectedException coding_exception
*/
public function test_sco_launched_event() {
$this->resetAfterTest();
@@ -251,7 +256,6 @@ class mod_scorm_event_testcase extends advanced_testcase {
$this->assertEventContextNotUsed($event);
// Test validations.
- $this->setExpectedException('coding_exception');
\mod_scorm\event\sco_launched::create(array(
'objectid' => $this->eventscorm->id,
'context' => context_module::instance($this->eventcm->id),
diff --git a/mod/scorm/tests/externallib_test.php b/mod/scorm/tests/externallib_test.php
index 53aaeea1c33..f081ae9d9ab 100644
--- a/mod/scorm/tests/externallib_test.php
+++ b/mod/scorm/tests/externallib_test.php
@@ -172,6 +172,9 @@ class mod_scorm_external_testcase extends externallib_advanced_testcase {
$this->assertEquals(1, $result['attemptscount']);
}
+ /**
+ * @expectedException required_capability_exception
+ */
public function test_mod_scorm_get_scorm_attempt_count_others_as_student() {
// Create a second student.
$student2 = self::getDataGenerator()->create_user();
@@ -181,24 +184,27 @@ class mod_scorm_external_testcase extends externallib_advanced_testcase {
self::setUser($student2);
// I should not be able to view the attempts of another student.
- $this->setExpectedException('required_capability_exception');
mod_scorm_external::get_scorm_attempt_count($this->scorm->id, $this->student->id);
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_mod_scorm_get_scorm_attempt_count_invalid_instanceid() {
// As student.
self::setUser($this->student);
// Test invalid instance id.
- $this->setExpectedException('moodle_exception');
mod_scorm_external::get_scorm_attempt_count(0, $this->student->id);
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_mod_scorm_get_scorm_attempt_count_invalid_userid() {
// As student.
self::setUser($this->student);
- $this->setExpectedException('moodle_exception');
mod_scorm_external::get_scorm_attempt_count($this->scorm->id, -1);
}
diff --git a/mod/scorm/tests/lib_test.php b/mod/scorm/tests/lib_test.php
index e5db5f1a089..174e567636f 100644
--- a/mod/scorm/tests/lib_test.php
+++ b/mod/scorm/tests/lib_test.php
@@ -170,14 +170,16 @@ class mod_scorm_lib_testcase extends externallib_advanced_testcase {
// Check exceptions does not broke anything.
scorm_require_available($this->scorm, true, $this->context);
// Now, expect exceptions.
- $this->setExpectedException('moodle_exception', get_string("notopenyet", "scorm", userdate($this->scorm->timeopen)));
+ $this->expectException('moodle_exception');
+ $this->expectExceptionMessage(get_string("notopenyet", "scorm", userdate($this->scorm->timeopen)));
// Now as student other condition.
self::setUser($this->student);
$this->scorm->timeopen = 0;
$this->scorm->timeclose = time() - DAYSECS;
- $this->setExpectedException('moodle_exception', get_string("expired", "scorm", userdate($this->scorm->timeclose)));
+ $this->expectException('moodle_exception');
+ $this->expectExceptionMessage(get_string("expired", "scorm", userdate($this->scorm->timeclose)));
scorm_require_available($this->scorm, false);
}
diff --git a/mod/wiki/tests/externallib_test.php b/mod/wiki/tests/externallib_test.php
index f1ff9e829c6..2e1660bba59 100644
--- a/mod/wiki/tests/externallib_test.php
+++ b/mod/wiki/tests/externallib_test.php
@@ -448,26 +448,30 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase {
/**
* Test get_subwiki_pages using an invalid wiki instance.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_subwiki_pages_invalid_instance() {
- $this->setExpectedException('moodle_exception');
mod_wiki_external::get_subwiki_pages(0);
}
/**
* Test get_subwiki_pages using a user not enrolled in the course.
+ *
+ * @expectedException require_login_exception
*/
public function test_get_subwiki_pages_unenrolled_user() {
// Create and use the user.
$usernotenrolled = self::getDataGenerator()->create_user();
$this->setUser($usernotenrolled);
- $this->setExpectedException('require_login_exception');
mod_wiki_external::get_subwiki_pages($this->wiki->id);
}
/**
* Test get_subwiki_pages using a hidden wiki as student.
+ *
+ * @expectedException require_login_exception
*/
public function test_get_subwiki_pages_hidden_wiki_as_student() {
// Create a hidden wiki and try to get the list of pages.
@@ -475,12 +479,13 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase {
array('course' => $this->course->id, 'visible' => false));
$this->setUser($this->student);
- $this->setExpectedException('require_login_exception');
mod_wiki_external::get_subwiki_pages($hiddenwiki->id);
}
/**
* Test get_subwiki_pages without the viewpage capability.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_subwiki_pages_without_viewpage_capability() {
// Prohibit capability = mod/wiki:viewpage on the course for students.
@@ -489,35 +494,38 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase {
accesslib_clear_all_caches_for_unit_testing();
$this->setUser($this->student);
- $this->setExpectedException('moodle_exception');
mod_wiki_external::get_subwiki_pages($this->wiki->id);
}
/**
* Test get_subwiki_pages using an invalid userid.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_subwiki_pages_invalid_userid() {
// Create an individual wiki.
$indwiki = $this->getDataGenerator()->create_module('wiki',
array('course' => $this->course->id, 'wikimode' => 'individual'));
- $this->setExpectedException('moodle_exception');
mod_wiki_external::get_subwiki_pages($indwiki->id, 0, -10);
}
/**
* Test get_subwiki_pages using an invalid groupid.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_subwiki_pages_invalid_groupid() {
// Create testing data.
$this->create_collaborative_wikis_with_groups();
- $this->setExpectedException('moodle_exception');
mod_wiki_external::get_subwiki_pages($this->wikisep->id, -111);
}
/**
* Test get_subwiki_pages, check that a student can't see another user pages in an individual wiki without groups.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_subwiki_pages_individual_student_see_other_user() {
// Create an individual wiki.
@@ -525,59 +533,62 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase {
array('course' => $this->course->id, 'wikimode' => 'individual'));
$this->setUser($this->student);
- $this->setExpectedException('moodle_exception');
mod_wiki_external::get_subwiki_pages($indwiki->id, 0, $this->teacher->id);
}
/**
* Test get_subwiki_pages, check that a student can't get the pages from another group in
* a collaborative wiki using separate groups.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_subwiki_pages_collaborative_separate_groups_student_see_other_group() {
// Create testing data.
$this->create_collaborative_wikis_with_groups();
$this->setUser($this->student);
- $this->setExpectedException('moodle_exception');
mod_wiki_external::get_subwiki_pages($this->wikisep->id, $this->group2->id);
}
/**
* Test get_subwiki_pages, check that a student can't get the pages from another group in
* an individual wiki using separate groups.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_subwiki_pages_individual_separate_groups_student_see_other_group() {
// Create testing data.
$this->create_individual_wikis_with_groups();
$this->setUser($this->student);
- $this->setExpectedException('moodle_exception');
mod_wiki_external::get_subwiki_pages($this->wikisepind->id, $this->group2->id, $this->teacher->id);
}
/**
* Test get_subwiki_pages, check that a student can't get the pages from all participants in
* a collaborative wiki using separate groups.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_subwiki_pages_collaborative_separate_groups_student_see_all_participants() {
// Create testing data.
$this->create_collaborative_wikis_with_groups();
$this->setUser($this->student);
- $this->setExpectedException('moodle_exception');
mod_wiki_external::get_subwiki_pages($this->wikisep->id, 0);
}
/**
* Test get_subwiki_pages, check that a student can't get the pages from all participants in
* an individual wiki using separate groups.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_subwiki_pages_individual_separate_groups_student_see_all_participants() {
// Create testing data.
$this->create_individual_wikis_with_groups();
$this->setUser($this->student);
- $this->setExpectedException('moodle_exception');
mod_wiki_external::get_subwiki_pages($this->wikisepind->id, 0, $this->teacher->id);
}
@@ -882,26 +893,30 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase {
/**
* Test get_page_contents using an invalid pageid.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_page_contents_invalid_pageid() {
- $this->setExpectedException('moodle_exception');
mod_wiki_external::get_page_contents(0);
}
/**
* Test get_page_contents using a user not enrolled in the course.
+ *
+ * @expectedException require_login_exception
*/
public function test_get_page_contents_unenrolled_user() {
// Create and use the user.
$usernotenrolled = self::getDataGenerator()->create_user();
$this->setUser($usernotenrolled);
- $this->setExpectedException('require_login_exception');
mod_wiki_external::get_page_contents($this->firstpage->id);
}
/**
* Test get_page_contents using a hidden wiki as student.
+ *
+ * @expectedException require_login_exception
*/
public function test_get_page_contents_hidden_wiki_as_student() {
// Create a hidden wiki and try to get a page contents.
@@ -910,12 +925,13 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase {
$hiddenpage = $this->getDataGenerator()->get_plugin_generator('mod_wiki')->create_page($hiddenwiki);
$this->setUser($this->student);
- $this->setExpectedException('require_login_exception');
mod_wiki_external::get_page_contents($hiddenpage->id);
}
/**
* Test get_page_contents without the viewpage capability.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_page_contents_without_viewpage_capability() {
// Prohibit capability = mod/wiki:viewpage on the course for students.
@@ -924,20 +940,20 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase {
accesslib_clear_all_caches_for_unit_testing();
$this->setUser($this->student);
- $this->setExpectedException('moodle_exception');
mod_wiki_external::get_page_contents($this->firstpage->id);
}
/**
* Test get_page_contents, check that a student can't get a page from another group when
* using separate groups.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_page_contents_separate_groups_student_see_other_group() {
// Create testing data.
$this->create_individual_wikis_with_groups();
$this->setUser($this->student);
- $this->setExpectedException('moodle_exception');
mod_wiki_external::get_page_contents($this->fpsepg2indt->id);
}
@@ -1027,13 +1043,14 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase {
/**
* Test get_subwiki_files, check that a student can't get files from another group's subwiki when
* using separate groups.
+ *
+ * @expectedException moodle_exception
*/
public function test_get_subwiki_files_separate_groups_student_see_other_group() {
// Create testing data.
$this->create_collaborative_wikis_with_groups();
$this->setUser($this->student);
- $this->setExpectedException('moodle_exception');
mod_wiki_external::get_subwiki_files($this->wikisep->id, $this->group2->id);
}
diff --git a/mod/workshop/allocation/random/tests/allocator_test.php b/mod/workshop/allocation/random/tests/allocator_test.php
index 07327f5e20c..9beeff1a7dd 100644
--- a/mod/workshop/allocation/random/tests/allocator_test.php
+++ b/mod/workshop/allocation/random/tests/allocator_test.php
@@ -114,14 +114,15 @@ class workshopallocation_random_testcase extends advanced_testcase {
), $submissions);
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_index_submissions_by_authors_duplicate_author() {
// fixture setup
$submissions = array(
14 => (object)array('id' => 676, 'authorid' => 3),
87 => (object)array('id' => 121, 'authorid' => 3),
);
- // set expectation
- $this->setExpectedException('moodle_exception');
// exercise SUT
$submissions = $this->allocator->index_submissions_by_authors($submissions);
}
diff --git a/mod/workshop/form/accumulative/tests/lib_test.php b/mod/workshop/form/accumulative/tests/lib_test.php
index 97a52ff89a6..e61d73b0402 100644
--- a/mod/workshop/form/accumulative/tests/lib_test.php
+++ b/mod/workshop/form/accumulative/tests/lib_test.php
@@ -78,11 +78,13 @@ class workshop_accumulative_strategy_testcase extends advanced_testcase {
$this->assertEquals(grade_floatval(5/20 * 100), $suggested);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_calculate_peer_grade_negative_weight() {
// fixture set-up
$this->strategy->dimensions[1003] = (object)array('grade' => '20', 'weight' => '-1');
$grades[] = (object)array('dimensionid' => 1003, 'grade' => '20');
- $this->setExpectedException('coding_exception');
// exercise SUT
$suggested = $this->strategy->calculate_peer_grade($grades);
}
@@ -176,6 +178,9 @@ class workshop_accumulative_strategy_testcase extends advanced_testcase {
$this->assertEquals(grade_floatval((1/2*2 + 4/6*3)/5 * 100), $suggested);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_calculate_peer_grade_scale_exception() {
$this->resetAfterTest(true);
// fixture set-up
@@ -183,8 +188,7 @@ class workshop_accumulative_strategy_testcase extends advanced_testcase {
$this->strategy->dimensions[1012] = (object)array('grade' => (-$scale13->id), 'weight' => 1);
$grades[] = (object)array('dimensionid' => 1012, 'grade' => '4.00000'); // exceeds the number of scale items
- // exercise SUT
- $this->setExpectedException('coding_exception');
+ // Exercise SUT.
$suggested = $this->strategy->calculate_peer_grade($grades);
}
}
diff --git a/mod/workshop/tests/locallib_test.php b/mod/workshop/tests/locallib_test.php
index ee4c476cf5f..2c43f63c242 100644
--- a/mod/workshop/tests/locallib_test.php
+++ b/mod/workshop/tests/locallib_test.php
@@ -317,24 +317,28 @@ class mod_workshop_internal_api_testcase extends advanced_testcase {
$this->assertEquals($part, $total * $percent / 100);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_percent_to_value_negative() {
$this->resetAfterTest(true);
// fixture setup
$total = 185;
$percent = -7.098;
- // set expectation
- $this->setExpectedException('coding_exception');
+
// exercise SUT
$part = workshop::percent_to_value($percent, $total);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_percent_to_value_over_hundred() {
$this->resetAfterTest(true);
// fixture setup
$total = 185;
$percent = 121.08;
- // set expectation
- $this->setExpectedException('coding_exception');
+
// exercise SUT
$part = workshop::percent_to_value($percent, $total);
}
@@ -383,7 +387,7 @@ class mod_workshop_internal_api_testcase extends advanced_testcase {
// modify setup
$fakerawrecord->weight = 1;
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
// excersise SUT
$a = $this->workshop->prepare_example_assessment($fakerawrecord);
}
@@ -412,7 +416,7 @@ class mod_workshop_internal_api_testcase extends advanced_testcase {
// modify setup
$fakerawrecord->weight = 0;
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
// excersise SUT
$a = $this->workshop->prepare_example_reference_assessment($fakerawrecord);
}
diff --git a/notes/tests/externallib_test.php b/notes/tests/externallib_test.php
index 62ee5684fd7..353b88c2eae 100644
--- a/notes/tests/externallib_test.php
+++ b/notes/tests/externallib_test.php
@@ -72,7 +72,7 @@ class core_notes_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability.
$this->unassignUserCapability('moodle/notes:manage', $contextid, $roleid);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$creatednotes = core_notes_external::create_notes($notes);
}
@@ -123,7 +123,7 @@ class core_notes_externallib_testcase extends externallib_advanced_testcase {
$dnotes3 = array($creatednotes[0]['noteid']);
$this->unassignUserCapability('moodle/notes:manage', $contextid, $roleid);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$deletednotes = core_notes_external::delete_notes($dnotes3);
$deletednotes = external_api::clean_returnvalue(core_notes_external::delete_notes_returns(), $deletednotes);
}
@@ -178,7 +178,7 @@ class core_notes_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability.
$this->unassignUserCapability('moodle/notes:view', $contextid, $roleid);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$creatednotes = core_notes_external::get_notes($gnotes);
}
@@ -234,7 +234,7 @@ class core_notes_externallib_testcase extends externallib_advanced_testcase {
$creatednotes = core_notes_external::create_notes($notes1);
$creatednotes = external_api::clean_returnvalue(core_notes_external::create_notes_returns(), $creatednotes);
$this->unassignUserCapability('moodle/notes:manage', $contextid, $roleid);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$note2 = array();
$note2["id"] = $creatednotes[0]['noteid'];
$note2['publishstate'] = 'personal';
diff --git a/question/behaviour/informationitem/tests/walkthrough_test.php b/question/behaviour/informationitem/tests/walkthrough_test.php
index 52382b17628..27896e27d5a 100644
--- a/question/behaviour/informationitem/tests/walkthrough_test.php
+++ b/question/behaviour/informationitem/tests/walkthrough_test.php
@@ -88,7 +88,7 @@ class qbehaviour_informationitem_walkthrough_testcase extends qbehaviour_walkthr
new question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/'));
// Check that trying to process a manual comment with a grade causes an exception.
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$this->manual_grade('Not good enough!', 1, FORMAT_HTML);
}
}
diff --git a/question/behaviour/manualgraded/tests/walkthrough_test.php b/question/behaviour/manualgraded/tests/walkthrough_test.php
index 4494d3f5a47..837797cf8e8 100644
--- a/question/behaviour/manualgraded/tests/walkthrough_test.php
+++ b/question/behaviour/manualgraded/tests/walkthrough_test.php
@@ -533,7 +533,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug
$this->quba->get_response_summary($this->slot));
// Try to process a an invalid grade.
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
$this->manual_grade('Comment', 'frog', FORMAT_HTML);
}
@@ -580,7 +580,7 @@ class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthroug
$this->quba->get_response_summary($this->slot));
// Try to process a an invalid grade.
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
$this->manual_grade('Comment', '10.1', FORMAT_HTML);
}
}
diff --git a/question/behaviour/missing/tests/missingbehaviour_test.php b/question/behaviour/missing/tests/missingbehaviour_test.php
index 31328b94346..bf42694f890 100644
--- a/question/behaviour/missing/tests/missingbehaviour_test.php
+++ b/question/behaviour/missing/tests/missingbehaviour_test.php
@@ -39,31 +39,40 @@ require_once(__DIR__ . '/../behaviour.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qbehaviour_missing_test extends advanced_testcase {
+
+ /**
+ * @expectedException moodle_exception
+ */
public function test_missing_cannot_start() {
$qa = new question_attempt(test_question_maker::make_question('truefalse', 'true'), 0);
$behaviour = new qbehaviour_missing($qa, 'deferredfeedback');
- $this->setExpectedException('moodle_exception');
$behaviour->init_first_step(new question_attempt_step(array()), 1);
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_missing_cannot_process() {
$qa = new question_attempt(test_question_maker::make_question('truefalse', 'true'), 0);
$behaviour = new qbehaviour_missing($qa, 'deferredfeedback');
- $this->setExpectedException('moodle_exception');
$behaviour->process_action(new question_attempt_pending_step(array()));
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_missing_cannot_get_min_fraction() {
$qa = new question_attempt(test_question_maker::make_question('truefalse', 'true'), 0);
$behaviour = new qbehaviour_missing($qa, 'deferredfeedback');
- $this->setExpectedException('moodle_exception');
$behaviour->get_min_fraction();
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_missing_cannot_get_max_fraction() {
$qa = new question_attempt(test_question_maker::make_question('truefalse', 'true'), 0);
$behaviour = new qbehaviour_missing($qa, 'deferredfeedback');
- $this->setExpectedException('moodle_exception');
$behaviour->get_max_fraction();
}
diff --git a/question/engine/tests/questionattempt_with_steps_test.php b/question/engine/tests/questionattempt_with_steps_test.php
index 05f745c8b87..e8febb6dfeb 100644
--- a/question/engine/tests/questionattempt_with_steps_test.php
+++ b/question/engine/tests/questionattempt_with_steps_test.php
@@ -57,8 +57,10 @@ class question_attempt_with_steps_test extends advanced_testcase {
$this->qa = null;
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_get_step_before_start() {
- $this->setExpectedException('moodle_exception');
$step = $this->qa->get_step(-1);
}
@@ -72,8 +74,10 @@ class question_attempt_with_steps_test extends advanced_testcase {
$this->assertEquals(2, $step->get_qt_var('i'));
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_get_step_past_end() {
- $this->setExpectedException('moodle_exception');
$step = $this->qa->get_step(3);
}
@@ -151,7 +155,7 @@ class question_attempt_with_steps_test extends advanced_testcase {
public function test_cannot_get_min_fraction_before_start() {
$qa = new question_attempt($this->question, 0);
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$qa->get_min_fraction();
}
@@ -162,7 +166,7 @@ class question_attempt_with_steps_test extends advanced_testcase {
public function test_cannot_get_max_fraction_before_start() {
$qa = new question_attempt($this->question, 0);
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$qa->get_max_fraction();
}
diff --git a/question/engine/tests/questionattemptiterator_test.php b/question/engine/tests/questionattemptiterator_test.php
index 71ed67c3820..81f20cab8e0 100644
--- a/question/engine/tests/questionattemptiterator_test.php
+++ b/question/engine/tests/questionattemptiterator_test.php
@@ -87,8 +87,10 @@ class question_attempt_iterator_test extends advanced_testcase {
$this->assertFalse(isset($this->iterator[3]));
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_offsetGet_before_start() {
- $this->setExpectedException('moodle_exception');
$step = $this->iterator[0];
}
@@ -100,18 +102,24 @@ class question_attempt_iterator_test extends advanced_testcase {
$this->assertSame($this->qas[2], $this->iterator[2]);
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_offsetGet_past_end() {
- $this->setExpectedException('moodle_exception');
$step = $this->iterator[3];
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_cannot_set() {
- $this->setExpectedException('moodle_exception');
$this->iterator[0] = null;
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_cannot_unset() {
- $this->setExpectedException('moodle_exception');
unset($this->iterator[2]);
}
}
\ No newline at end of file
diff --git a/question/engine/tests/questionattemptstep_test.php b/question/engine/tests/questionattemptstep_test.php
index 4c6955dd0b5..9c55790701d 100644
--- a/question/engine/tests/questionattemptstep_test.php
+++ b/question/engine/tests/questionattemptstep_test.php
@@ -85,13 +85,13 @@ class question_attempt_step_test extends advanced_testcase {
public function test_cannot_set_qt_var_without_underscore() {
$step = new question_attempt_step();
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$step->set_qt_var('x', 1);
}
public function test_cannot_set_behaviour_var_without_underscore() {
$step = new question_attempt_step();
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$step->set_behaviour_var('x', 1);
}
diff --git a/question/engine/tests/questionattemptstepiterator_test.php b/question/engine/tests/questionattemptstepiterator_test.php
index c3715af85f4..9d90654b65a 100644
--- a/question/engine/tests/questionattemptstepiterator_test.php
+++ b/question/engine/tests/questionattemptstepiterator_test.php
@@ -104,8 +104,10 @@ class question_attempt_step_iterator_test extends advanced_testcase {
$this->assertFalse(isset($this->iterator[3]));
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_offsetGet_before_start() {
- $this->setExpectedException('moodle_exception');
$step = $this->iterator[-1];
}
@@ -119,18 +121,24 @@ class question_attempt_step_iterator_test extends advanced_testcase {
$this->assertEquals(2, $step->get_qt_var('i'));
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_offsetGet_past_end() {
- $this->setExpectedException('moodle_exception');
$step = $this->iterator[3];
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_cannot_set() {
- $this->setExpectedException('moodle_exception');
$this->iterator[0] = null;
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_cannot_unset() {
- $this->setExpectedException('moodle_exception');
unset($this->iterator[2]);
}
}
\ No newline at end of file
diff --git a/question/engine/tests/questionengine_test.php b/question/engine/tests/questionengine_test.php
index a4f7f2692ad..9e800b194b8 100644
--- a/question/engine/tests/questionengine_test.php
+++ b/question/engine/tests/questionengine_test.php
@@ -45,9 +45,10 @@ class question_engine_test extends advanced_testcase {
$this->assertTrue(class_exists('qbehaviour_deferredfeedback'));
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_load_behaviour_class_missing() {
- // Set expectation.
- $this->setExpectedException('moodle_exception');
// Exercise SUT
question_engine::load_behaviour_class('nonexistantbehaviour');
}
diff --git a/question/engine/tests/questionusage_autosave_test.php b/question/engine/tests/questionusage_autosave_test.php
index cb7d7c294de..aa3b03fcd03 100644
--- a/question/engine/tests/questionusage_autosave_test.php
+++ b/question/engine/tests/questionusage_autosave_test.php
@@ -566,7 +566,7 @@ class question_usage_autosave_test extends qbehaviour_walkthrough_test_base {
$transaction->allow_commit();
// Now commit the other transaction.
- $this->setExpectedException('dml_write_exception');
+ $this->expectException('dml_write_exception');
$this->save_quba($DB2);
$transaction2->allow_commit();
diff --git a/question/engine/tests/questionusagebyactivity_test.php b/question/engine/tests/questionusagebyactivity_test.php
index 7f82f3d0118..38562a0ac8b 100644
--- a/question/engine/tests/questionusagebyactivity_test.php
+++ b/question/engine/tests/questionusagebyactivity_test.php
@@ -94,7 +94,7 @@ class question_usage_by_activity_test extends advanced_testcase {
// Exercise SUT and verify.
$this->assertSame($tf, $quba->get_question($slot));
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$quba->get_question($slot + 1);
}
@@ -155,7 +155,7 @@ class question_usage_by_activity_test extends advanced_testcase {
);
// Exercise SUT - now it should fail.
- $this->setExpectedException('question_out_of_sequence_exception');
+ $this->expectException('question_out_of_sequence_exception');
$quba->process_all_actions($slot, $postdata);
}
}
diff --git a/question/engine/tests/questionutils_test.php b/question/engine/tests/questionutils_test.php
index 84c5673c8f9..b9db0ece675 100644
--- a/question/engine/tests/questionutils_test.php
+++ b/question/engine/tests/questionutils_test.php
@@ -177,18 +177,24 @@ class question_utils_test extends advanced_testcase {
$this->assertSame('mmmcmxcix', question_utils::int_to_roman(3999));
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_int_to_roman_too_small() {
- $this->setExpectedException('moodle_exception');
question_utils::int_to_roman(0);
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_int_to_roman_too_big() {
- $this->setExpectedException('moodle_exception');
question_utils::int_to_roman(4000);
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_int_to_roman_not_int() {
- $this->setExpectedException('moodle_exception');
question_utils::int_to_roman(1.5);
}
diff --git a/question/type/calculated/tests/variablesubstituter_test.php b/question/type/calculated/tests/variablesubstituter_test.php
index b67030652fe..0a66ad866f4 100644
--- a/question/type/calculated/tests/variablesubstituter_test.php
+++ b/question/type/calculated/tests/variablesubstituter_test.php
@@ -48,30 +48,38 @@ class qtype_calculated_variable_substituter_test extends advanced_testcase {
$this->assertEquals(1, $vs->calculate('{a}-{b}'));
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_cannot_use_nonnumbers() {
- $this->setExpectedException('moodle_exception');
$vs = new qtype_calculated_variable_substituter(array('a' => 'frog', 'b' => -2), '.');
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_invalid_expression() {
- $this->setExpectedException('moodle_exception');
$vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 2), '.');
$vs->calculate('{a} + {b}?');
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_tricky_invalid_expression() {
- $this->setExpectedException('moodle_exception');
$vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 2), '.');
$vs->calculate('{a}{b}'); // Have to make sure this does not just evaluate to 12.
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_division_by_zero_expression() {
if (intval(PHP_VERSION) < 7) {
$this->markTestSkipped('Division by zero triggers a PHP warning before PHP 7.');
}
- $this->setExpectedException('moodle_exception');
$vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 0), '.');
$vs->calculate('{a} / {b}');
}
diff --git a/question/type/missingtype/tests/missingtype_test.php b/question/type/missingtype/tests/missingtype_test.php
index 541436d6994..76b289f243a 100644
--- a/question/type/missingtype/tests/missingtype_test.php
+++ b/question/type/missingtype/tests/missingtype_test.php
@@ -66,14 +66,18 @@ class qtype_missing_test extends question_testcase {
return $questiondata;
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_cannot_grade() {
$q = new qtype_missingtype_question();
- $this->setExpectedException('moodle_exception');
$q->grade_response(array());
}
+ /**
+ * @expectedException moodle_exception
+ */
public function test_load_qtype_strict() {
- $this->setExpectedException('moodle_exception');
$qtype = question_bank::get_qtype('strange_unknown');
}
diff --git a/repository/tests/generator_test.php b/repository/tests/generator_test.php
index 9f24d63f1dc..71fd7a0ed15 100644
--- a/repository/tests/generator_test.php
+++ b/repository/tests/generator_test.php
@@ -185,7 +185,7 @@ class core_repository_generator_testcase extends advanced_testcase {
$this->assertEquals($record->contextid, $instance->contextid);
// Invalid context.
- $this->setExpectedException('coding_exception');
+ $this->expectException('coding_exception');
$record->contextid = context_block::instance($block->id)->id;
$instance = $this->getDataGenerator()->create_repository('webdav', $record);
}
diff --git a/user/tests/externallib_test.php b/user/tests/externallib_test.php
index c965b4208f9..b87d30162fc 100644
--- a/user/tests/externallib_test.php
+++ b/user/tests/externallib_test.php
@@ -523,7 +523,7 @@ class core_user_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability
$this->unassignUserCapability('moodle/user:create', $context->id, $roleid);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
$createdusers = core_user_external::create_users(array($user1));
}
@@ -554,7 +554,7 @@ class core_user_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability.
$this->unassignUserCapability('moodle/user:delete', $context->id, $roleid);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
core_user_external::delete_users(array($user1->id, $user2->id));
}
@@ -634,7 +634,7 @@ class core_user_externallib_testcase extends externallib_advanced_testcase {
// Call without required capability.
$this->unassignUserCapability('moodle/user:update', $context->id, $roleid);
- $this->setExpectedException('required_capability_exception');
+ $this->expectException('required_capability_exception');
core_user_external::update_users(array($user1));
}
diff --git a/user/tests/myprofile_test.php b/user/tests/myprofile_test.php
index f273192f71e..6d94bc7a19a 100644
--- a/user/tests/myprofile_test.php
+++ b/user/tests/myprofile_test.php
@@ -88,6 +88,9 @@ class core_user_myprofile_testcase extends advanced_testcase {
$this->assertSame('class1 class2', $category->classes);
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_validate_after_order1() {
$category = new \phpunit_fixture_myprofile_category('category', 'title', null);
@@ -100,11 +103,13 @@ class core_user_myprofile_testcase extends advanced_testcase {
$category->add_node($node2);
$category->add_node($node1);
- $this->setExpectedException('coding_exception');
$category->validate_after_order();
}
+ /**
+ * @expectedException coding_exception
+ */
public function test_validate_after_order2() {
$category = new \phpunit_fixture_myprofile_category('category', 'title', null);
@@ -117,7 +122,6 @@ class core_user_myprofile_testcase extends advanced_testcase {
$category->add_node($node2);
$category->add_node($node1);
- $this->setExpectedException('coding_exception');
$category->validate_after_order();
}
@@ -167,6 +171,8 @@ class core_user_myprofile_testcase extends advanced_testcase {
/**
* Test category::sort_nodes().
+ *
+ * @expectedException coding_exception
*/
public function test_sort_nodes1() {
$category = new \phpunit_fixture_myprofile_category('category', 'title', null);
@@ -213,7 +219,6 @@ class core_user_myprofile_testcase extends advanced_testcase {
// Add a node with invalid 'after' and make sure an exception is thrown.
$node7 = new \core_user\output\myprofile\node('category', 'node7', 'nodetitle', 'noderandom');
$category->add_node($node7);
- $this->setExpectedException('coding_exception');
$category->sort_nodes();
}
@@ -259,6 +264,8 @@ class core_user_myprofile_testcase extends advanced_testcase {
/**
* Test tree::add_node().
+ *
+ * @expectedException coding_exception
*/
public function test_tree_add_node() {
$tree = new \phpunit_fixture_myprofile_tree();
@@ -269,12 +276,13 @@ class core_user_myprofile_testcase extends advanced_testcase {
$this->assertEquals($node1, $node);
// Can't add node with same name.
- $this->setExpectedException('coding_exception');
$tree->add_node($node1);
}
/**
* Test tree::add_category().
+ *
+ * @expectedException coding_exception
*/
public function test_tree_add_category() {
$tree = new \phpunit_fixture_myprofile_tree();
@@ -285,7 +293,6 @@ class core_user_myprofile_testcase extends advanced_testcase {
$this->assertEquals($category1, $category);
// Can't add node with same name.
- $this->setExpectedException('coding_exception');
$tree->add_category($category1);
}
@@ -334,6 +341,8 @@ class core_user_myprofile_testcase extends advanced_testcase {
/**
* Test tree::sort_categories().
+ *
+ * @expectedException coding_exception
*/
public function test_sort_categories() {
$tree = new \phpunit_fixture_myprofile_tree('category', 'title', null);
@@ -372,7 +381,6 @@ class core_user_myprofile_testcase extends advanced_testcase {
$this->assertEquals($category6, $category);
// Can't add category with same name.
- $this->setExpectedException('coding_exception');
$tree->add_category($category1);
}
}
diff --git a/webservice/xmlrpc/tests/lib_test.php b/webservice/xmlrpc/tests/lib_test.php
index 8f38a546482..8adc4384f5d 100644
--- a/webservice/xmlrpc/tests/lib_test.php
+++ b/webservice/xmlrpc/tests/lib_test.php
@@ -85,7 +85,7 @@ class webservice_xmlrpc_test extends advanced_testcase {
$client = new webservice_xmlrpc_client_mock('/webservice/xmlrpc/server.php', 'anytoken');
$mockresponse = file_get_contents($CFG->dirroot . '/webservice/xmlrpc/tests/fixtures/fault_response.xml');
$client->set_mock_response($mockresponse);
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
$client->call('testfunction');
}
}