Closed bobbingwide closed 7 years ago
I developed more functions to support tests using different locales ( especially bb_BB ). These should also be added to the BW_UnitTestCase
class.
New method | Purpose |
---|---|
assertArrayEqualsFile | Asserts that the HTML array equals the file |
prepareExpectedArray | Converts to an array if required |
prepareFile | Returns the expected file name |
find_test_name | Finds the test name from the call stack |
query_la_CY | Queries the currently set locale |
generate_expected_file | Helps to generate the expected file from actual test output |
More methods to be added
New method | Purpose |
---|---|
switch_to_locale | Switch to a selected locale and reload domains |
reload_domains | reload domains and enable Just Translate It |
More methods added
New method | Purpose |
---|---|
replace_created_nonce | Replaces the created nonce with nonsense |
arraytohtml | Reduce a print_r'ed string |
More methods to be added
New method | Purpose |
---|---|
replace_home_url | replaces instances of home_url() and site_url() in $expected |
replace_post_id | replaces instances of "post=" . $post->ID with "post=42" |
replace_post_id supports a $prefix parameter so you can use other this method to replace the post->ID in other parameter names e.g. 'id="link-'
During development of new test cases for the oik base plugin, as part of the i18n work, I developed some helper functions that allow the generated HTML to be treated as an array and for hardcoded or generated values to be replaced with generic values, or vice-versa.
This makes it slightly easier to construct the $expected output for assertions. These new methods could be generalised and implemented in oik-batch'es
BW_UnitTestCase
class.