diff --git a/admin/tool/licensemanager/tests/behat/delete_license.feature b/admin/tool/licensemanager/tests/behat/delete_license.feature index 8648d55242d..cdba0bff1b6 100644 --- a/admin/tool/licensemanager/tests/behat/delete_license.feature +++ b/admin/tool/licensemanager/tests/behat/delete_license.feature @@ -24,3 +24,26 @@ Feature: Delete custom licenses And I navigate to "Licence > Licence manager" in site administration Then I should see "Licence not specified" in the "unknown" "table_row" And I should not see "Delete" in the "unknown" "table_row" + + @javascript @_file_upload + Scenario: I cannot delete a custom license in use + Given I log in as "admin" + And I navigate to "Licence > Licence manager" in site administration + And I click on "Create licence" "link" + And I set the following fields to these values: + | shortname | Test licence | + | fullname | Test licence | + | source | https://opensource.org/licenses/MIT | + | Licence version | ##1 March 2019## | + And I press "Save changes" + And I follow "Private files" in the user menu + And I upload "lib/editor/atto/tests/fixtures/moodle-logo.png" file to "Files" filemanager + And I click on "moodle-logo.png" "link" + And I set the field "Choose licence" to "Test licence" + And I press "Update" + And I press "Save changes" + And I am on site homepage + And I navigate to "Licence > Licence manager" in site administration + And I click on "Delete" "icon" in the "Test licence" "table_row" + When I click on "Save changes" "button" in the "Delete licence" "dialogue" + Then I should see "Cannot delete a licence which is currently assigned to one or more files" diff --git a/admin/tool/licensemanager/tests/behat/license_manager.feature b/admin/tool/licensemanager/tests/behat/license_manager.feature index 0ff21b929d1..5ab86353b30 100644 --- a/admin/tool/licensemanager/tests/behat/license_manager.feature +++ b/admin/tool/licensemanager/tests/behat/license_manager.feature @@ -33,3 +33,26 @@ Feature: Licence manager And "This is the site default licence" "icon" should exist in the "cc" "table_row" And "Enable licence" "icon" should not exist in the "cc" "table_row" And "This is the site default licence" "icon" should not exist in the "public" "table_row" + + @javascript @_file_upload + Scenario Outline: User licence preference is remembered depending of setting value + Given the following config values are set as admin: + | sitedefaultlicense | cc | + | rememberuserlicensepref | | + And I log in as "admin" + And I follow "Private files" in the user menu + And I follow "Add..." + And I follow "Upload a file" + And the field with xpath "//select[@name='license']" matches value "Creative Commons" + And I click on "Close" "button" in the "File picker" "dialogue" + When I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager as: + | Save as | empty_copy.txt | + | license | Public domain | + And I press "Save changes" + And I follow "Add..." + Then the field with xpath "//select[@name='license']" matches value "" + + Examples: + | rememberuserlicensepref | expectedlicence | + | 0 | Creative Commons | + | 1 | Public domain |