Following up with #2077455: Add initial simpletests with a base class where an initial version of Baidu Analytics Test Cases was committed (at 6357889), it seems baidu_analytics.test could probably be further improved:
Test Cases: A few more things we might want to test:
- Tracking of error messages only, based on the configuration.
- Tracking of error, status and warning messages.
- HTML tags in Status Message should be stripped off before being inserted in generated tracking code.
Now, the trick here would be to know how these different tracking messages could be triggered.
Therefore, for the purpose of this Test Case only, we could create a simple hidden sub-module with an implementation of hook_page_alter
that would trigger all the test messages we would need by calling drupal_set_message
.
It seems this would be the only way currently, to trigger programmatically Drupal status messages: it doesn't seem to be possible directly from within the Test Case.
Please let me know if you would have any questions, objections, comments, suggestions, recommendations or concerns on any aspects of this feature request, I would be glad to provide more information or explain in more details.
Any questions, feedback, testing, changes, ideas or recommendations would be highly appreciated.
Thanks to all in advance.
Comments
Comment #1
DYdave CreditAttribution: DYdave commentedQuick follow-up on this feature request:
Modified the file
baidu_analytics.test
to add a new Test Case Class, calledBaiduAnalyticsStatusMessagesTest
wich performs the tests described in the issue summary:With all message types displayed on the page, check that only the error message is being tracked, as configured in the settings, and check that all Status Message types could actually be tracked properly once tracking is enabled for all types; also check HTML tags are stripped off before being injected in the JavaScript code.
To be able to trigger programmatically error, status and warning messages, a simple hidden sub-module called baidu_analytics_test with an implementation of
hook_page_alter
was added.It triggers on every page a message of each type and an additionnal error message with HTML tags inside (4 messages).
To ensure baidu_analytics_test runs before the Baidu Analytics module, the weight of the test module had to be set to a lower value (-5, for example) than the baidu_analytics module when module is installed, from the
baidu_analytics_test.install
file's hook_install implementation.This file is necessary and if this test module's weight is not lower than the one of the baidu_analytics module, the tests would fail (tracking of messages not found in the JavaScript code).
This module is then included in the
BaiduAnalyticsStatusMessagesTest::setUp
and as a dependency inBaiduAnalyticsStatusMessagesTest::getInfo
.I went ahead and committed the changes against the 7.x-1.x branch at 8911874, followed by another commit at 09f1a03 to add
baidu_analytics_test.install
file to override Baidu Analytics Test module's weight to run before the Baidu Analytics module.I allowed myself to mark this issue as fixed for now, but feel free to re-open it, or post a new ticket, at any time if you have any further objections with this ticket or any of the related commits (8911874, 09f1a03 - we would surely be happy to hear your feedback).
Please let me know if you would have any further comments, feedback, questions, issues, objections, suggestions or concerns on the commits or this feature request in general, I would be glad to provide more information or explain in more details.
Thanks in advance to everyone for your testing, reviews, feedback and comments on this issue.
Cheers!
Comment #2
DYdave CreditAttribution: DYdave commentedFurther follow up on this issue:
Some of the tests were broken in the Test Case for messages, due to the change in code at ce1f68a, related with #2076967-2: Fix display of tracked URLs for Original source translations, with a problem for the display of labels for tracked messages in the Baidu Analytics platform.
They should actually have been committed at the same time, but it seems it was forgotten.
We'll just have to be a bit more careful in the future and maybe use Project's testbot first by uploading a patch before committing (or at least running tests locally).
Changes to the tests have been committed against the 7.x-1.x branch at 95ff431, accordingly with the change made in previous commit at ce1f68a.
Please let me know if you would have any further comments, feedback, questions, issues, objections, suggestions or concerns on the commits or this bug report in general, I would be glad to provide more information or explain in more details.
Thanks in advance to everyone for your testing, reviews, feedback and comments on this issue.
Cheers!