mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-51802 core: new template for quick editing a title
convert editing tag name to use new template
This commit is contained in:
parent
2f45a11ac4
commit
cdc5f9785b
23 changed files with 636 additions and 171 deletions
|
@ -153,7 +153,7 @@ Feature: Users can edit tags to add description or rename
|
|||
And I set the field "New name for tag Cat" to "Kitten"
|
||||
And I press key "13" in the field "New name for tag Cat"
|
||||
Then I should not see "Cat"
|
||||
And "New name for tag" "field" should not be visible
|
||||
And "New name for tag" "field" should not exist
|
||||
And I wait until "Kitten" "link" exists
|
||||
And I follow "Default collection"
|
||||
And I should see "Kitten"
|
||||
|
@ -163,8 +163,8 @@ Feature: Users can edit tags to add description or rename
|
|||
And I set the field "New name for tag Turtle" to "DOG"
|
||||
And I press key "13" in the field "New name for tag Turtle"
|
||||
And I should see "Tag names already being used"
|
||||
And I press "Ok"
|
||||
And "New name for tag" "field" should not be visible
|
||||
And I press "Close"
|
||||
And "New name for tag" "field" should not exist
|
||||
And I should see "Turtle"
|
||||
And I should see "Dog"
|
||||
And I should not see "DOG"
|
||||
|
@ -176,7 +176,7 @@ Feature: Users can edit tags to add description or rename
|
|||
And I click on "Edit tag name" "link" in the "Dog" "table_row"
|
||||
And I set the field "New name for tag Dog" to "Penguin"
|
||||
And I press key "27" in the field "New name for tag Dog"
|
||||
And "New name for tag" "field" should not be visible
|
||||
And "New name for tag" "field" should not exist
|
||||
And I should see "Turtle"
|
||||
And I should not see "Penguin"
|
||||
And I follow "Default collection"
|
||||
|
|
|
@ -147,4 +147,38 @@ class core_tag_external_testcase extends externallib_advanced_testcase {
|
|||
$this->assertEquals($tag->id, $result['warnings'][0]['item']);
|
||||
$this->assertEquals('namesalreadybeeingused', $result['warnings'][0]['warningcode']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update_inplace_editable()
|
||||
*/
|
||||
public function test_update_inplace_editable() {
|
||||
global $CFG, $DB, $PAGE;
|
||||
require_once($CFG->dirroot . '/lib/external/externallib.php');
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
$tag = $this->getDataGenerator()->create_tag();
|
||||
|
||||
// Call service for core_tag component without necessary permissions.
|
||||
try {
|
||||
core_external::update_inplace_editable('core_tag', 'tagname', $tag->id, 'new tag name');
|
||||
$this->fail('Exception expected');
|
||||
} catch (moodle_exception $e) {
|
||||
$this->assertEquals('Sorry, but you do not currently have permissions to do that (Manage all tags)',
|
||||
$e->getMessage());
|
||||
}
|
||||
|
||||
// Change to admin user and make sure that tag name can be updated using web service update_inplace_editable().
|
||||
$this->setAdminUser();
|
||||
$res = core_external::update_inplace_editable('core_tag', 'tagname', $tag->id, 'New tag name');
|
||||
$res = external_api::clean_returnvalue(core_external::update_inplace_editable_returns(), $res);
|
||||
$this->assertEquals('New tag name', $res['value']);
|
||||
$this->assertEquals('New tag name', $DB->get_field('tag', 'rawname', array('id' => $tag->id)));
|
||||
|
||||
// Call callback core_tag_inplace_editable() directly.
|
||||
$tmpl = component_callback('core_tag', 'inplace_editable', array('tagname', $tag->id, 'Rename me again'));
|
||||
$this->assertInstanceOf('core\output\inplace_editable', $tmpl);
|
||||
$res = $tmpl->export_for_template($PAGE->get_renderer('core'));
|
||||
$this->assertEquals('Rename me again', $res['value']);
|
||||
$this->assertEquals('Rename me again', $DB->get_field('tag', 'rawname', array('id' => $tag->id)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue