diff --git a/.github/workflows/behat.yml b/.github/workflows/behat.yml index 561ac5fcc6..ef67437ef8 100644 --- a/.github/workflows/behat.yml +++ b/.github/workflows/behat.yml @@ -182,6 +182,7 @@ jobs: #../../vendor/behat/behat/bin/behat features/companyReports.feature -vvv ../../vendor/behat/behat/bin/behat features/course.feature -vvv ../../vendor/behat/behat/bin/behat features/course_user_registration.feature -vv + ../../vendor/behat/behat/bin/behat features/courseCategory.feature -vvv ../../vendor/behat/behat/bin/behat features/createUser.feature -vvv ../../vendor/behat/behat/bin/behat features/createUserViaCSV.feature -vv ../../vendor/behat/behat/bin/behat features/extraFieldUser.feature -vv diff --git a/public/main/admin/course_category.php b/public/main/admin/course_category.php index 3ae6d4e784..34542bfa3c 100644 --- a/public/main/admin/course_category.php +++ b/public/main/admin/course_category.php @@ -37,13 +37,13 @@ switch ($action) { CourseCategory::delete($categoryId); Display::addFlash(Display::return_message(get_lang('Deleted'))); header('Location: '.api_get_self().'?category='.Security::remove_XSS($category)); - exit(); + exit; break; case 'moveUp': CourseCategory::moveNodeUp($categoryId, $_GET['tree_pos'], $category); header('Location: '.api_get_self().'?category='.Security::remove_XSS($category)); Display::addFlash(Display::return_message(get_lang('Update successful'))); - exit(); + exit; break; case 'add': if (isset($_POST['formSent']) && $_POST['formSent']) { @@ -58,8 +58,7 @@ switch ($action) { if (isset($_FILES['image']) && $categoryEntity) { CourseCategory::saveImage($categoryEntity, $_FILES['image']); } - $message = Display::return_message(get_lang('Created')); - Display::addFlash($message); + Display::addFlash(Display::return_message(get_lang('Item added'))); header('Location: '.api_get_path(WEB_CODE_PATH).'admin/course_category.php?id='.$parentId); exit; } @@ -84,9 +83,7 @@ switch ($action) { CourseCategory::saveImage($categoryEntity, $_FILES['image']); } - $message = Display::return_message(get_lang('Update successful')); - - Display::addFlash($message); + Display::addFlash(Display::return_message(get_lang('Update successful'))); header('Location: '.api_get_path(WEB_CODE_PATH).'admin/course_category.php?id='.$parentId); exit; } @@ -210,7 +207,6 @@ if ('add' === $action || 'edit' === $action) { if (!empty($parentInfo)) { echo Display::page_subheader($parentInfo['name'].' ('.$parentInfo['code'].')'); } - echo CourseCategory::listCategories($categoryInfo); } diff --git a/tests/behat/features/courseCategory.feature b/tests/behat/features/courseCategory.feature new file mode 100644 index 0000000000..9bcebcaaad --- /dev/null +++ b/tests/behat/features/courseCategory.feature @@ -0,0 +1,24 @@ + +Feature: Course category + + Background: + Given I am a platform administrator + + Scenario: Add a course category + Given I am on "/main/admin/course_category.php?action=add" + And I should see "Add category" + When I fill in the following: + | code | COURSE_CATEGORY | + | name | Course category | + Then I fill in editor field "description" with "description" + Then I attach the file "/public/img/logo.png" to "picture" + And I press "submit" + And wait for the page to be loaded + Then I should see "Item added" + + Scenario: Delete course category + Given I am on "/main/admin/course_category.php" + Then I should see "Course category" + Then I follow "Delete" + And wait for the page to be loaded + Then I should see "There are no categories here" \ No newline at end of file