Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Follow-up to #2827100: Improve test coverage and function docs
Implementing additional tests for ctools:
- working on the context handling functions, e.g. in context.inc
Comment | File | Size | Author |
---|---|---|---|
#19 | ctools-n2829295-19.patch | 83.23 KB | rivimey |
#19 | ctools-n2829295-19-interdiff.txt | 3.36 KB | rivimey |
Comments
Comment #2
rivimeyComment #3
rivimeyA first round: testing the ctools_context_id and ctools_context_next_id functions.
Plus some minor changes in context.inc to bring it into the php 5 era ('var').
Note: there are known exception failures here caused by the tests intentionally not including 'id', 'name' or both expected keys. I expect a change to the context.inc code is needed to fix these.
Comment #4
rivimeyIncluded some more tests and a new test class, for the miscellaneous functions in the ctools.module file.
The patch ctools-test_coverage-2829295-7x1x-4.patch is against now-current ctools HEAD, and includes patch 49 of #2827100: Improve test coverage and function docs, which is a prerequisite of this patch.
The 'interdiff' patch is the work covered in this issue, -- it is an interdiff back to patch 49.
In the new code I have added 2 new functions to the main codebase, ctools_classes_reset() and ctools_get_classes, to wrap the use of drupal_static and the function name shared by ctools_process(), ctools_classes_add() and ctools_classes_remove(). I am not expecting it to cause any difficulties....
Creating suitable tests for the ctools_process() code itself is a WIP.
Comment #5
rivimeyComment #6
rivimeyComment #8
rivimeyComment #9
rivimeyComment #10
darrenwh CreditAttribution: darrenwh as a volunteer and at Investis Digital commentedThis could do with some comments
What type of parameters are these? int, array bool etc? Ps include in comment.
This could do with some comments
What type of parameters are these? int, array bool etc? Ps include in comment.
Perhaps FALSE? Instead of falsy ;-)
Needs @file tag
Comment #11
rivimeyHi Darren, thanks for the check. Another rabbithole... I hope I've addressed your comments and done a bunch more as well.
Would much appreciate any checking on the validity of the comments I've made, especially around ctools_context_select() which confused me for a bit. I have had to leave some doc comments sparser than I'd like because I just don't know enough of what is happening :(
Added an interdiff too :)
Comment #12
rivimeyComment #13
darrenwh CreditAttribution: darrenwh as a volunteer and at Investis Digital commentedA few observations:
Sorry mega trivial, but goes over 80 char limit
Should be @todo
This needs a docblock.
Please add a docblock
Dock block and others below
May be worth adding comment covering whats returned in this array?
Could $r be refactored to be more descriptive?
Us @todo instead of //TODO
@todo
Humm? Not covered by your patch, this line runs over 80 char limit
@todo
Please add comments for return value and @param if possible
Comment #14
rivimeyThanks, Darren. Been doing a bit more today, hope these changes are enough :-)
Some very small code changes, mostly more docs as requested.
Mostly the changes are to move initialisations into the constructor, which is clearer, and recommended, and occasionally required.
Comment #15
stella CreditAttribution: stella at Annertech commentedLooks good, just a few small changes:
It'd be good to rename the $dv variable to something easily understandable.
$r variable has now been renamed to $item, so it'd be good to update the comment to match.
Comment #16
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commentedComment #17
rivimeyThanks, Gaurav.
Done a but more now; getting there.
I would appreciate anyone reviewing the meaning of the function docs, not (just) DCS issues :-)
Comment #18
darrenwh CreditAttribution: darrenwh as a volunteer and at Investis Digital commentedFew! this is a long patch :-/ Notes below
This is missing a variable type and desription?
Missing var type and description
This should use inline commented syntax //
Missing method description.
needs a couple of spaces before Keyword
Perhaps: is the context
perhaps: is the context
Perhaps lowercase or full caps for false?
Perhaps if TRUE
Missing parameter types and comments
Comment #19
rivimeyHi Darren, thanks for your notes.
Regarding (1), (2), I do not know any more than is there.. I can infer some things (such as 'array' etc) but this one will have to be an exercise for the reader!
For similar reasons my effort with (4) is somewhat circular.
Re (8) I prefer using True / False in English, to be clear I'm talking about logical true rather than an English hand-wavy true.
I've addressed the rest... all good?
Comment #20
rivimeyComment #21
darrenwh CreditAttribution: darrenwh as a volunteer and at Investis Digital commentedLooks good
Comment #22
japerryWhew, long indeed! Committed.
Comment #24
klausiThis broke ctools_context_optional, opened #2905885: ctools_context_optional regression with public $required property.
Comment #26
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedThis broke the Feeds tests on PHP 5.3 because the short array syntax is used. Opened #2942581: ctools.test breaks Feeds tests on PHP 5.3 because of short array syntax.