Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

Unit tests for calendar_information.

Copyright: 2017 Andrew Nicols <andrew@nicols.co.uk>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1069 lines (50 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 calendar/tests/helpers.php

Defines 1 class

calendar_information_testcase:: (27 methods):
  mock_structure()
  test_site_visibility_no_enrolment()
  test_site_visibility_no_enrolment_category()
  test_site_visibility_category_manager_site()
  test_site_visibility_category_manager_own_category()
  test_site_visibility_category_manager_parent_category()
  test_site_visibility_category_manager_child_category()
  test_site_visibility_single_course_site()
  test_site_visibility_single_course_course_course()
  test_site_visibility_single_course_category()
  test_site_visibility_single_course_parent_category()
  test_site_visibility_single_course_sibling_category()
  test_site_visibility_single_course_different_category()
  test_site_visibility_two_courses_one_category_site()
  test_site_visibility_two_courses_one_category_course()
  test_site_visibility_two_courses_one_category_courseb()
  test_site_visibility_two_courses_one_category_category()
  test_site_visibility_two_courses_one_category_othercategory()
  test_site_visibility_two_courses_two_categories_site()
  test_site_visibility_two_courses_two_categories_coursea()
  test_site_visibility_two_courses_two_categories_courseb()
  test_site_visibility_two_courses_two_categories_category()
  test_site_visibility_two_courses_two_categories_different_category()
  test_site_visibility_admin_user()
  test_site_visibility_admin_user_with_enrolment_site()
  test_site_visibility_admin_user_with_enrolment_course()
  test_site_visibility_admin_user_with_enrolment_category()


Class: calendar_information_testcase  - X-Ref

Unit tests for calendar_information.

mock_structure()   X-Ref
Helper to mock a course and category structure.

return: array

test_site_visibility_no_enrolment()   X-Ref
Given a user has no enrolments.
And I ask for the site information.
Then I should see the site.
And I should see no other courses.
And I should see no categories.


test_site_visibility_no_enrolment_category()   X-Ref
Given a user has no enrolments.
And I ask for a category.
Then I should see the category.
And I should see the category parents.
And I should see the category descendants.
And I should see the site course.
And I should see no other courses.


test_site_visibility_category_manager_site()   X-Ref
Given a user has a role assignment to manage a category.
And I ask for the site information.
Then I should see that category.
And I should see the category parents.
And I should see the category descendants.
And I should see the site course.
And I should see no other courses.


test_site_visibility_category_manager_own_category()   X-Ref
Given a user has a role assignment to manage a category.
And I ask for that category.
Then I should see that category.
And I should see the category parents.
And I should see the category descendants.
And I should see the site course.
And I should see no other courses.


test_site_visibility_category_manager_parent_category()   X-Ref
Given a user has a role assignment to manage a category.
And I ask for the parent of that category.
Then I should see that category.
And I should see the category parents.
And I should see the category descendants.
And I should see the site course.
And I should see no other courses.


test_site_visibility_category_manager_child_category()   X-Ref
Given a user has a role assignment to manage a category.
And I ask for a child of that category.
Then I should see that category.
And I should see the category parents.
And I should see the category descendants.
And I should see the site course.
And I should see no other courses.


test_site_visibility_single_course_site()   X-Ref
Given a user has an enrolment in a single course.
And I ask for the site information.
Then I should see the site.
And I should see the course I am enrolled in.
And I should see the category that my enrolled course is in.
And I should see the parents of the category that my enrolled course is in.


test_site_visibility_single_course_course_course()   X-Ref
Given a user has an enrolment in a single course.
And I ask for the course information.
Then I should see the site.
And I should see that course.
And I should see the category of that course.
And I should see the parents of that course category.


test_site_visibility_single_course_category()   X-Ref
Given a user has an enrolment in a single course.
And I ask for the category information for the category my course is in.
Then I should see that category.
And I should see the category parents.
And I should see the category descendants.
And I should see the site.
And I should see my course.
And I should see no other courses.
And I should see no categories.


test_site_visibility_single_course_parent_category()   X-Ref
Given a user has an enrolment in a single course.
And I ask for the category information for the parent of the category my course is in.
Then I should see that category.
And I should see the category parents.
And I should see the category descendants.
And I should see the site.
And I should see my course.
And I should see no other courses.
And I should see no categories.


test_site_visibility_single_course_sibling_category()   X-Ref
Given a user has an enrolment in a single course.
And I ask for the category information for the sibling of the category my course is in.
Then I should see that category.
And I should see the category parents.
And I should see the category descendants.
And I should see the site.
And I should see my course.
And I should see no other courses.
And I should see no categories.


test_site_visibility_single_course_different_category()   X-Ref
Given a user has an enrolment in a single course.
And I ask for the category information for a different category to the one my course is in.
Then I should see that category.
And I should see the category parents.
And I should see the category descendants.
And I should see the site.
And I should see not see my course.
And I should see no other courses.
And I should see no categories.


test_site_visibility_two_courses_one_category_site()   X-Ref
Given a user has an enrolment in two courses in the same category.
And I ask for the site information.
Then I should see the site.
And I should see the course I am enrolled in.
And I should see the category that my enrolled course is in.
And I should see the parents of the category that my enrolled course is in.


test_site_visibility_two_courses_one_category_course()   X-Ref
Given a user has an enrolment in two courses in the same category.
And I ask for the course information.
Then I should see the site.
And I should see that course.
And I should see the category that my enrolled courses are in.
And I should see the parents of the category that my enrolled course are in.


test_site_visibility_two_courses_one_category_courseb()   X-Ref
Given a user has an enrolment in two courses in the same category.
And I ask for the course information of the second course.
Then I should see the site.
And I should see that course.
And I should see the category that my enrolled courses are in.
And I should see the parents of the category that my enrolled course are in.


test_site_visibility_two_courses_one_category_category()   X-Ref
Given a user has an enrolment in two courses in the same category.
And I ask for the category information.
Then I should see the site.
And I should see that course.
And I should see the category that my enrolled courses are in.
And I should see the parents of the category that my enrolled course are in.


test_site_visibility_two_courses_one_category_othercategory()   X-Ref
Given a user has an enrolment in two courses in the same category.
And I ask for the categoy information of a different course.
Then I should see the site.
And I should see that course.
And I should see the category that my enrolled courses are in.
And I should see the parents of the category that my enrolled course are in.


test_site_visibility_two_courses_two_categories_site()   X-Ref
Given a user has an enrolment in two courses in the separate category.
And I ask for the site informatino.
Then I should see the site.
And I should see both course.
And I should see the categories that my enrolled courses are in.
And I should see the parents of those categories.


test_site_visibility_two_courses_two_categories_coursea()   X-Ref
Given a user has an enrolment in two courses in the separate category.
And I ask for the course information for one of those courses.
Then I should see the site.
And I should see one of the courses.
And I should see the categories that my enrolled courses are in.
And I should see the parents of those categories.


test_site_visibility_two_courses_two_categories_courseb()   X-Ref
Given a user has an enrolment in two courses in the separate category.
And I ask for the course information for the second of those courses.
Then I should see the site.
And I should see one of the courses.
And I should see the categories that my enrolled courses are in.
And I should see the parents of those categories.


test_site_visibility_two_courses_two_categories_category()   X-Ref
Given a user has an enrolment in two courses in separate categories.
And I ask for the category information.
Then I should see the site.
And I should see one of the courses.
And I should see the categories that my enrolled courses are in.
And I should see the parents of those categories.


test_site_visibility_two_courses_two_categories_different_category()   X-Ref
Given a user has an enrolment in two courses in the separate category.
And I ask for the category information of a different category.
Then I should see the site.
And I should see one of the courses.
And I should see the categories that my enrolled courses are in.
And I should see the parents of those categories.


test_site_visibility_admin_user()   X-Ref
Given an admin user with no enrolments.
And I ask for the site information.
Then I should see the site.
And I should see no other courses.
And I should see no categories.


test_site_visibility_admin_user_with_enrolment_site()   X-Ref
Given an admin user with a single enrolments.
And I ask for the site information.
Then I should see the site.
And I should see the course I am enrolled in
And I should see the category of that course.
And I should see the parents of that course category.
And I should see no other courses.
And I should see no other categories.


test_site_visibility_admin_user_with_enrolment_course()   X-Ref
Given an admin user with a single enrolments.
And I ask for the course information.
Then I should see the site.
And I should see the course I am enrolled in
And I should see the category of that course.
And I should see the parents of that course category.


test_site_visibility_admin_user_with_enrolment_category()   X-Ref
Given an admin user with a single enrolments.
And I ask for the category information for the category my course is in.
Then I should see that category.
And I should see the category parents.
And I should see the category descendants.
And I should see the site.
And I should see my course.
And I should see no other courses.
And I should see no categories.