Commit c10bfee4 authored by Neill Magill's avatar Neill Magill
Browse files

MDL-55209 coursecat: Should be able to remove category idnumber test

A user should be able to remove an idnumber from a category, also 0
should not be allowed multiple times.
parent cad8adcc
......@@ -348,3 +348,20 @@ Feature: Test category management actions
| Category ID number | CAT1 |
When I press "Create category"
Then I should see "ID number is already used for another category"
Scenario: Test that is possible to remove an idnumber from a course category
Given the following "categories" exist:
| name | category | idnumber |
| Cat 1 | 0 | CAT1 |
| Cat 2 | 0 ||
And I log in as "admin"
And I go to the courses management page
And I should see "CAT1" in the "#category-listing" "css_element"
When I click on "edit" action for "Cat 1" in management category listing
And I set the following fields to these values:
| Category name | Category 1 (edited) |
| Category ID number ||
And I press "Save changes"
# Redirect
Then I should see "Category 1 (edited)" in the "#category-listing" "css_element"
And I should not see "CAT1" in the "#course-listing" "css_element"
......@@ -128,6 +128,21 @@ class core_coursecatlib_testcase extends advanced_testcase {
} catch (moodle_exception $e) {
$this->assertInstanceOf('moodle_exception', $e);
}
// Test that duplicates with an idnumber of 0 cannot be created.
coursecat::create(array('name' => 'Cat3', 'idnumber' => '0'));
try {
coursecat::create(array('name' => 'Cat4', 'idnumber' => '0'));
$this->fail('Duplicate idnumber "0" exception expected in coursecat::create');
} catch (moodle_exception $e) {
$this->assertInstanceOf('moodle_exception', $e);
}
// Test an update cannot make a duplicate idnumber of 0.
try {
$cat2->update(array('idnumber' => '0'));
$this->fail('Duplicate idnumber "0" exception expected in coursecat::update');
} catch (Exception $e) {
$this->assertInstanceOf('moodle_exception', $e);
}
}
public function test_visibility() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment