Skip to content

Commit

Permalink
MDL-45131 notes: Add validation for returned parameters in WS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva committed Apr 16, 2015
1 parent 82fc915 commit 80cb20a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions notes/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ public function test_delete_notes() {

// Call without required capability.
$creatednotes = core_notes_external::create_notes($cnotes);
$creatednotes = external_api::clean_returnvalue(core_notes_external::create_notes_returns(), $creatednotes);
$dnotes3 = array($creatednotes[0]['noteid']);

$this->unassignUserCapability('moodle/notes:manage', $contextid, $roleid);
$this->setExpectedException('required_capability_exception');
$deletednotes = core_notes_external::delete_notes($dnotes3);
$deletednotes = external_api::clean_returnvalue(core_notes_external::delete_notes_returns(), $deletednotes);
}

public function test_get_notes() {
Expand Down Expand Up @@ -230,6 +232,7 @@ public function test_update_notes() {

// Call without required capability.
$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');
$note2 = array();
Expand All @@ -239,6 +242,7 @@ public function test_update_notes() {
$note2['format'] = FORMAT_HTML;
$notes2 = array($note2);
$updatednotes = core_notes_external::update_notes($notes2);
$updatednotes = external_api::clean_returnvalue(core_notes_external::update_notes_returns(), $updatednotes);
}

/**
Expand Down

0 comments on commit 80cb20a

Please sign in to comment.