Skip to content

Commit

Permalink
MDL-66876 core_filter: Fix context in Web Service warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva committed Oct 23, 2019
1 parent aaff669 commit e613b1f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion filter/classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static function get_available_in_context($contexts) {
} catch (Exception $e) {
$warnings[] = array(
'item' => 'context',
'itemid' => $context['instanceid'],
'itemid' => $contextinfo['instanceid'],
'warningcode' => $e->getCode(),
'message' => $e->getMessage(),
);
Expand Down
9 changes: 9 additions & 0 deletions filter/tests/external_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,14 @@ public function test_get_available_in_context_module() {
$this->assertEquals($firstfilter, $result['filters'][0]['filter']); // OK, the filter is enabled globally.
$this->assertEquals(TEXTFILTER_OFF, $result['filters'][0]['localstate']); // It is not available in this context.
$this->assertEquals(TEXTFILTER_ON, $result['filters'][0]['inheritedstate']); // In the parent context is available.

// Try user without permission, warning expected.
$user = $this->getDataGenerator()->create_user();
$this->setUser($user);
$result = external::get_available_in_context(array(array('contextlevel' => 'module', 'instanceid' => $forum->cmid)));
$result = external_api::clean_returnvalue(external::get_available_in_context_returns(), $result);
$this->assertNotEmpty($result['warnings']);
$this->assertEquals('context', $result['warnings'][0]['item']);
$this->assertEquals($forum->cmid, $result['warnings'][0]['itemid']);
}
}

0 comments on commit e613b1f

Please sign in to comment.