Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'wip-MDL-31175-m23' of git://github.com/samhemelryk/moodle

  • Loading branch information...
commit e4db653e3a7a79c3b7b8c17f178d65271314ea38 2 parents 65fc031 + 00f286e
@stronk7 stronk7 authored
View
2  backup/util/settings/base_setting.class.php
@@ -303,7 +303,7 @@ public function register_dependency(setting_dependency $dependency) {
if ($this->is_circular_reference($dependency->get_dependent_setting())) {
$a = new stdclass();
$a->alreadydependent = $this->name;
- $a->main = $dependentsetting->get_name();
+ $a->main = $dependency->get_dependent_setting()->get_name();
throw new base_setting_exception('setting_circular_reference', $a);
}
$this->dependencies[$dependency->get_dependent_setting()->get_name()] = $dependency;
View
17 backup/util/settings/simpletest/testsettings.php
@@ -32,10 +32,12 @@
require_once($CFG->dirroot . '/backup/backup.class.php');
require_once($CFG->dirroot . '/backup/util/settings/base_setting.class.php');
require_once($CFG->dirroot . '/backup/util/settings/backup_setting.class.php');
+require_once($CFG->dirroot . '/backup/util/settings/setting_dependency.class.php');
require_once($CFG->dirroot . '/backup/util/settings/root/root_backup_setting.class.php');
require_once($CFG->dirroot . '/backup/util/settings/activity/activity_backup_setting.class.php');
require_once($CFG->dirroot . '/backup/util/settings/section/section_backup_setting.class.php');
require_once($CFG->dirroot . '/backup/util/settings/course/course_backup_setting.class.php');
+require_once($CFG->dirroot . '/backup/util/ui/backup_ui_setting.class.php');
/*
* setting tests (all)
@@ -209,6 +211,21 @@ function test_base_setting() {
$this->assertEqual($e->a->alreadydependent, 'test4');
}
+ $bs1 = new mock_base_setting('test1', base_setting::IS_INTEGER, null);
+ $bs2 = new mock_base_setting('test2', base_setting::IS_INTEGER, null);
+ $bs1->register_dependency(new setting_dependency_disabledif_empty($bs1, $bs2));
+ try {
+ // $bs1 is already dependent on $bs2 so this should fail.
+ $bs2->register_dependency(new setting_dependency_disabledif_empty($bs2, $bs1));
+ $this->assertTrue(false, 'base_setting_exception expected');
+ } catch (exception $e) {
+ $this->assertTrue($e instanceof base_setting_exception);
+ $this->assertEqual($e->errorcode, 'setting_circular_reference');
+ $this->assertTrue($e->a instanceof stdclass);
+ $this->assertEqual($e->a->main, 'test1');
+ $this->assertEqual($e->a->alreadydependent, 'test2');
+ }
+
// Create 3 settings and observe between them, last one must
// automatically inherit all the settings defined in the main one
$bs1 = new mock_base_setting('test1', base_setting::IS_INTEGER, null);
Please sign in to comment.
Something went wrong with that request. Please try again.