From: tjhunt Date: Mon, 15 Dec 2008 03:08:22 +0000 (+0000) Subject: unit tests: MDL-17646 Arrgh! edited the wrong file after making testsimpletestlib... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b1bc12631980abfdaab07b4afb4d64c43198ac99;p=moodle.git unit tests: MDL-17646 Arrgh! edited the wrong file after making testsimpletestlib.php by copying testaccesslib.php! --- diff --git a/lib/simpletest/testsimpletestlib.php b/lib/simpletest/testsimpletestlib.php index 7471d5d12a..62465e647d 100644 --- a/lib/simpletest/testsimpletestlib.php +++ b/lib/simpletest/testsimpletestlib.php @@ -1,68 +1,33 @@ assertEqual(get_parent_contexts($context), array()); - - $context = new stdClass; - $context->path = '/1/25'; - $this->assertEqual(get_parent_contexts($context), array(1)); - - $context = new stdClass; - $context->path = '/1/123/234/345/456'; - $this->assertEqual(get_parent_contexts($context), array(345, 234, 123, 1)); - } - - function test_get_parent_contextid() { - $context = get_context_instance(CONTEXT_SYSTEM); - $this->assertFalse(get_parent_contextid($context)); - - $context = new stdClass; - $context->path = '/1/25'; - $this->assertEqual(get_parent_contextid($context), 1); - - $context = new stdClass; - $context->path = '/1/123/234/345/456'; - $this->assertEqual(get_parent_contextid($context), 345); - } - - function test_get_users_by_capability() { + function test_load_delete_test_data() { global $DB; - // Create three nested contexts. instanceid does not matter for this. Just - // ensure we don't violate any unique keys by using an unlikely number. - // We will fix paths in a second. $contexts = $this->load_test_data('context', array('contextlevel', 'instanceid', 'path', 'depth'), array( array(10, 666, '', 1), array(40, 666, '', 2), array(50, 666, '', 3), )); - $contexts[0]->path = '/' . $contexts[0]->id; - $DB->set_field('context', 'path', $contexts[0]->path, array('id' => $contexts[0]->id)); - $contexts[1]->path = $contexts[0]->path . '/' . $contexts[1]->id; - $DB->set_field('context', 'path', $contexts[1]->path, array('id' => $contexts[1]->id)); - $contexts[2]->path = $contexts[1]->path . '/' . $contexts[2]->id; - $DB->set_field('context', 'path', $contexts[2]->path, array('id' => $contexts[2]->id)); // Just test load_test_data and delete_test_data for now. $this->assertTrue($DB->record_exists('context', array('id' => $contexts[1]->id))); - $this->assertTrue($DB->get_field('context', 'path', array('id' => $contexts[2]->id)), $contexts[2]->path); + $this->assertTrue($DB->get_field('context', 'contextlevel', array('id' => $contexts[2]->id)), $contexts[2]->contextlevel); $this->delete_test_data('context', $contexts); $this->assertFalse($DB->record_exists('context', array('id' => $contexts[1]->id))); } } + ?>