Issue Details (XML | Word | Printable)

Key: MDL-19566
Type: Improvement Improvement
Status: Open Open
Priority: Minor Minor
Assignee: moodle.com
Reporter: Nicolas Connault
Votes: 0
Watchers: 0
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Refactoring of regular expressions and unit test best practice

Created: 19/Jun/09 05:30 PM   Updated: 13/Nov/09 04:08 PM
Return to search
Component/s: Unit tests
Affects Version/s: 1.9.5
Fix Version/s: 2.0

Participants: moodle.com, Nicolas Connault and Tim Hunt
Security Level: None
Affected Branches: MOODLE_19_STABLE
Fixed Branches: MOODLE_20_STABLE


 Description  « Hide
Regular expressions are very powerful, but most of them in Moodle are untested. Ideally we should unit-test every regular expression with a wide range of inputs.

This is difficult for one main reason: often the regular expressions are not accessible to unit tests, they are deeply embedded in the logic and have strong coupling.

One solution is to extract all static regular expressions into constants, and dynamic expressions into functions. Unit tests can then be written for them easily.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Nicolas Connault committed 2 files to 'Moodle CVS' - 22/Jun/09 02:07 PM
MDL-19566 Refactored some of the more complex regular expressions in their own function and added unit tests for them.
MODIFY lib/weblib.php   Rev. 1.1272    (+38 -9 lines)
MODIFY lib/simpletest/testweblib.php   Rev. 1.14    (+23 -0 lines)