-
-
Notifications
You must be signed in to change notification settings - Fork 893
Geshi Option parsing #2307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geshi Option parsing #2307
Conversation
While it's generally frowned upon testing privates, it can often be useful and the easier way to write tests. Eg you want to test something complicated method that is important, but you do not want to expose it directly to other classes... This new method uses reflection to make access to such methods possible from within tests without the need for intermediate classes.
* private_testing: (375 commits) make testing of inaccessible methods easier updated composer dependencies renamed ActionRouter::checkPermissions to checkPreconditions shortened new search configs Section edit: corrected pattern 'SEC_EDIT_PATTERN' fix regex character class. fixes #2301 fix: switch extensions if stylesheet in style.ini doesn't exist refactor: rename and move function to set $JSINFO typo. capital P for class name fix: add missing global $ACT for $JSINFO refactor: use native json_encode for $JSINFO refactor: rename JSINFO.DOKU_UHN and JSINFO.DOKU_UHC refactor: extract $JSINFO initialization into tpl_ function refactor: rename dta and dtb parameters doc(search): parameter must be string or false doc(search): highlight is expected to be an array show adavanced tools with JavaScript only adjusted language files to remove outdated string removed sub header from all languages added aria attributes ...
Quotes are now optional, the options are spearated by space
monkey patched GeSHi/geshi-1.0#104
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGBI. Just an question open.
* @throws ReflectionException | ||
*/ | ||
public function testOptionParser($input, $expect) { | ||
$h = new Doku_Handler(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ever executed? I assume there is some magic happening because of the @dataProvider dataProvider
comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is magic :).
PHPUnit calls this function with every element in the array returned by the dataprovider()
method.
You can see it for yourself by running phpunit --filter TestOfDoku_Handler_ParseHighlightOptions
on the commandline in the _test/
directory.
Documentation: https://phpunit.de/manual/6.5/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks.
This picks up from #1985, drops the JSON parsing again (sorry) and relaxes the options a bit more. They are now separated by spaces and the quotes are optional.
To make testing easier I merged another branch of mine into this which allows for easy testing of private or protected methods. This way I was able to test the option parser directly.
I also applied the code change from GeSHi/geshi-1.0#104 manually.