51 Commits

Author SHA1 Message Date
Amaia Anabitarte
6c1471c755 MDL-78288 core_course: Adding a link to edit availability settings
AMOS BEGIN
  CPY [editsettings,moodle],[editsettings,core_availability]
AMOS END
2023-07-12 14:23:17 +02:00
Amaia Anabitarte
b9a840f638 MDL-78288 behat: New availability info selectors
- Create a new availability info selectors for section and activity data info regions
- Replace css_element by created selectors in the existing behat tests
2023-07-12 14:22:56 +02:00
Mikel Martín
045f8cb50d MDL-78204 course: Use 'showmore' component in course restrictions
- Create new availability template, so it can be reused from both
section/availability and cm/availability mustaches.

- When rendering activity or section restrictions with long or multiline text
display a condensed version (excerpt) and use 'showmore' component to add
showmore/showless behaviour.

Co-authored-by: Ferran Recio <ferran@moodle.com>
2023-06-28 15:08:13 +02:00
Angelia Dela Cruz
fb9745ab0b MDL-74021 behat: Page behat generators use UI
Replace steps that manually add page instances via the UI and use
Behat generators. This improves the speed of Behat test runs.

Co-authored-by: Simey Lameze <simey@moodle.com>
2023-06-19 17:03:02 +08:00
Angelia Dela Cruz
c95ef35b60 MDL-70152 behat: Forum behat generators use UI
Behat cleanup and optimisation
2023-05-29 10:32:20 +08:00
Angelia Dela Cruz
640db57c0e MDL-70152 behat: Forum behat generators use UI
Replace steps that manually add forum and forum post instances
via the UI and use Behat generators. This improves the speed of
Behat test runs.
2023-05-29 10:32:12 +08:00
Mark Johnson
cab6e97c1f MDL-68093 availability: Add support for private rule sets
This allows an availability plugin to indicate that a selected condition
should be considered "private", and therefore should never be shown to
users who don't satisfy the criteria. The availability_groups plugin
uses this to protect visibility of groups that are not visible to
non-members.
2023-03-14 08:52:25 +00:00
Víctor Déniz
d4de7b630e MDL-76395 lang: Use fixed strings in tests 2022-11-23 17:03:58 +00:00
Eloy Lafuente (stronk7)
9f53b0e965 MDL-73971 phpunit: Move more tests to use correct names and namespaces
Applied the following changes to various testcase classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Remove file phpdoc block
- Remove MOODLE_INTERNAL if not needed.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.

Special mention to:

- Some fixtures, initially defined in the test files have been
  moved to new files in fixtures subdirectory, leaving the unit
  test files clearer:
  - moodle2_course_format_test.php
- Rename wrong named test:
  - baseoptiogroup_test = baseoptigroup_test
2022-05-06 18:29:11 +02:00
Jake Dallimore
b6e9d54a38 MDL-73758 availability: fix info::is_available_for_all()
Should only return true early when the config setting is disabled,
not when it's enabled.
2022-02-03 16:41:44 +08:00
Bas Brands
35a5288554 MDL-71691 core_behat: behat fixes for changed course design 2021-12-08 13:14:05 +01:00
Bas Brands
70d86ac570 MDL-71691 core_availability: add show more link 2021-12-06 10:54:05 +01:00
Mihail Geshoski
7d821080f0 MDL-72093 navigation: Update behat tests 2021-09-14 12:02:35 +08:00
Ilya Tregubov
cf1cf222e7 MDL-66431 core: Fix behat tests.
Move activity creation to data generators. Only fixing those
tests failing due to removing usemodchooser preference.
2021-05-01 16:22:03 +02:00
Víctor Déniz
4d0292b3b5 Merge branch 'MDL-70537-master' of https://github.com/sammarshallou/moodle 2021-03-26 20:14:19 +00:00
sam marshall
c89ea6733c MDL-70537 Availability: Avoid recursive calls to $cm->name
These recursive calls didn't work in PHP 7.3 and below, but in PHP
7.4 they also cause a fatal error which means if you have invalid
availability data, the whole page might die.
2021-03-18 15:54:17 +00:00
Eloy Lafuente (stronk7)
ba5b6089d5 MDL-71036 phpunit: Renamed various regexp-related assertions
In PHPUnit 9.1, the following regexp-related assertions
have been deprecated and there are new alternatives for
all them:
    - assertRegExp()     -> assertMatchesRegularExpression()
    - assertNotRegExp()  -> assertDoesNotMatchRegularExpression()

This is about to, simply, move all cases to the new alternatives.

Source: https://github.com/sebastianbergmann/phpunit/blob/9.1.0/ChangeLog-9.1.md

Regexp to find all them:

    ag 'assertRegExp|assertNotRegExp' -li
2021-03-11 19:22:24 +01:00
Eloy Lafuente (stronk7)
40de097e65 MDL-67673 phpunit: Remove deprecated assertContains() uses on strings
Both assertContains() and assertNotContains() are deprecated in PHPUnit 8
for operations on strings. Also the optional case parameter is. All uses
must be changed to one of:

- assertStringContainsString()
- assertStringContainsStringIgnoringCase()
- assertStringNotContainsString()
- assertStringNotContainsStringIgnoringCase()

More info: https://github.com/sebastianbergmann/phpunit/issues/3422

Regexp to find all uses:

ag 'assert(Not)?Contains\('
2020-10-21 12:46:00 +02:00
Eloy Lafuente (stronk7)
f6711bb394 MDL-67673 phpunit: Fix the return type of template methods
All the setup/teardown/pre/post/conditions template methods
now are required to return void. This was warned with phpunit 7
and now is enforced.

At the same time, fix a few wrong function names,
provider data and param types, return statements...
2020-10-21 12:45:59 +02:00
Ferran Recio
c54b183c8d MDL-67613 availability_completion: add previous activity condition 2020-05-06 10:56:47 +02:00
Mark Nielsen
197e2bca5b MDL-59602 behat: make use of new course nav steps 2017-07-21 13:50:47 -07:00
Dan Poltawski
1e4e5c52d7 Merge branch 'MDL-55611-master' of git://github.com/danpoltawski/moodle 2017-04-04 17:07:41 +01:00
Simey Lameze
fdeeaff954 MDL-58265 core_test: replace I turn editing on steps
Also remove few more unnecessary steps that redirects behat to
site home page to actually get to the course.

Part of MDL-55611 epic.
2017-04-03 11:37:07 +08:00
Simey Lameze
93be3f730c MDL-58265 core_test: remove unnecessary steps
This commmit removes steps that take behat to site home page
to actually get to a course page.

Part of MDL-55611 epic.
2017-04-03 11:37:07 +08:00
Simey Lameze
c987d1b2ef MDL-58265 core_test: replace all uses of I follow course steps
Part of MDL-55611 epic.
2017-04-03 11:37:07 +08:00
Jakob
6a36b8526e MDL-37765 course: Add capability to ignore availability restrictions.
Allow a role to view activities without addressing the restriction rules.
2017-03-27 08:37:27 -07:00
Marina Glancy
e5287f9b3b MDL-56614 behat: navigate without navigation and admin blocks 2016-12-06 11:49:14 +08:00
David Mudrák
445aa472b9 MDL-53481 availability: Fix unit test to not execute the huge query
Some DBs have troubles to execute such a huge query as generated in this
test. We do not actually need to execute it. All we need is to make sure
that the parameter placeholders are enumerated correctly. So it is what
this new test does.
2016-11-10 09:52:31 +01:00
David Mudrák
93f4f3494a MDL-53481 availability: Fix uniqueness of SQL named param placeholders
Static variables do not behave the way you might expect when accessing
them through the classes inheritance. When accessing a method via self::
or static:: operators, even though the method is inherited, its variable
scope is not. So the method unique_sql_parameter() was using the scope
of the child class and each child class had its own sequence of usp1,
usp2, usp3, ... placeholders. This led to "Incorrect number of query
parameters" error when multiuple condition classes were contributing to
a single SQL query.

All credit should go to Adam Olley who debugged and described the
essence of the problem in the tracker.
2016-11-08 13:36:07 +01:00
Dan Poltawski
8be9cffb8b MDL-52219 phpunit: updated for new defaults
The externallib assertion was previously never being run and had a typo..
2015-11-26 14:07:17 +00:00
Dan Poltawski
aa306e7bc8 MDL-52219 behat: remove steps which turn on avaibility/completion
Now its the default, we can reduce test time by relying on the default
state rather than going around turning it on
2015-11-26 14:07:17 +00:00
sam marshall
07bb79b451 MDL-51652 Availability: OR conditions fail when filtering user lists
When filtering a user list, if there is an OR tree where one of the
conditions does not restrict user lists such as a date condition,
then the overall result should include all users (not be filtered).
This was not working correctly.
2015-10-12 10:23:54 +01:00
rajesh Taneja
5ecf8e8f21 MDL-51266 unittest: replaced low level phpunit_util calls 2015-09-23 15:42:48 +08:00
sam marshall
362616ae6c MDL-51007 Availability: Unit test fails with extra plugins 2015-08-05 14:27:40 +01:00
Marina Glancy
57ca231ad9 MDL-49434 availability: unit test adjustments 2015-07-22 12:49:22 +08:00
Rajesh Taneja
0fe86bbdbb MDL-49799 behat: replaced asd.com with example.com
asd.com is a valid domain, we should use reserved domain names for testing
2015-04-20 11:21:20 +08:00
Simey Lameze
06d631f1c5 MDL-49412 availability: Fix behat failures
Part of MDL-45774
2015-04-10 17:18:22 +08:00
Rajesh Taneja
bed97c39eb MDL-49513 behat: Set admin config using php api
Added a new set to set config using set_config() api
to make steps faster and more efficient
2015-04-01 14:25:23 +08:00
John Okely
e7bcd2764a MDL-44520 behat: Change behat features to use new section selectors 2015-02-06 10:34:54 +08:00
sam marshall
6b40e5b2ec MDL-48660 Availability: filter_user_list() should respect 'view hidden'
Updated filter_user_list and get_user_list_sql to account for
the viewhiddenactivities and viewhiddensections capabilities.
2015-01-27 10:59:05 +00:00
sam marshall
a4c318325c MDL-47628 Availability: Restrict by selected grouping button 2014-11-28 15:55:41 +00:00
sam marshall
06c0603825 MDL-47322 Availability: empty availability should be saved as null
As part of the unit test modifications for this change, I added the get_json
function to the availability conditions that didn't have it. (This is a function
for use in unit tests.)
2014-09-26 15:42:37 +01:00
sam marshall
28f31f7d2d MDL-44725 Availability: Unit test for tree::get_user_list_sql 2014-09-04 10:25:01 +08:00
sam marshall
1a7049af22 MDL-44725 Availability: Add SQL feature for user lists (11)
The previous API included a facility to filter a list of users
to include only those who are allowed to access an activity, i.e.
only people who belong to the required groups etc.

This change adds a new API function to return SQL that obtains
this list of users, so that it can be combined with other
queries.
2014-09-02 13:03:29 +01:00
sam marshall
f9103882dc MDL-44725 Availability: Add utility API to make unit testing easier (7)
Previously there was no way in PHP to create the JSON values used for
availability, except by manually hard-coding them (the main code to
do this normally is in JavaScript).

This makes unit tests hard to read, so I have implemented static
functions tree::get_root_json and tree::get_nested_json which allow
for easier-to-read unit tests.
2014-09-02 13:03:19 +01:00
sam marshall
3d962d49cb MDL-44725 Availability: Replace groupmembersonly - core_availability (2)
Remove groupmembersonly usage in the core_availability API, and change
the update code (used in backup) so that it considers groupmembersonly
when restoring old backups.
2014-09-02 13:03:09 +01:00
Rajesh Taneja
a9e2d4c03a MDL-45698 behat: Added extra setting, to avoid timout issue 2014-05-29 09:44:03 +08:00
sam marshall
a3a2423982 MDL-45362 Availability: Behat test fails on first of month 2014-05-01 11:18:06 +01:00
sam marshall
1282c47446 MDL-45138 Conditional availability: toggling AND/OR affects nested groups 2014-04-17 14:09:12 +01:00
Rajesh Taneja
0adadbf00b MDL-44070 core_completion: Removed unwanted tag 2014-04-10 14:28:28 +08:00