Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-28137 unit tests: Fixed up problem with block manager tests when …

…running unit tests after turning editing on
  • Loading branch information...
commit 34ee79470f6964adc7ae836ce6e332474bf7c8e8 1 parent a938306
@samhemelryk samhemelryk authored
Showing with 15 additions and 0 deletions.
  1. +15 −0 lib/simpletest/testblocklib_blockmanager.php
View
15 lib/simpletest/testblocklib_blockmanager.php
@@ -159,13 +159,28 @@ public function test_matching_page_type_patterns() {
*/
class moodle_block_manager_test_saving_loading extends UnitTestCaseUsingDatabase {
+ protected $isediting = null;
+
public function setUp() {
+ global $USER;
+ if (!empty($USER->editing)) {
+ // We want to avoid the capability checks associated with
+ // checking the user is editing.
+ $this->isediting = $USER->editing;
+ unset($USER->editing);
+ }
parent::setUp();
$this->create_test_tables(array('block', 'block_instances', 'block_positions', 'context'), 'lib');
$this->switch_to_test_db();
}
public function tearDown() {
+ global $USER;
+ if (!empty($this->isediting)) {
+ // Replace $USER->editing as it was there at setup.
+ $USER->editing = $this->isediting;
+ $this->isediting = null;
+ }
parent::tearDown();
}
Please sign in to comment.
Something went wrong with that request. Please try again.