Add meta refresh support to SimpleTest
boombatower - October 2, 2008 - 18:04
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | simpletest.module |
| Category: | task |
| Priority: | normal |
| Assigned: | boombatower |
| Status: | closed |
Description
From work with testing.drupal.org and looking at some of the hax related to simpletest.test I think we need meta refresh support in the SimpleTest browser. In general this is needed to run any page using the batch API so it would most likely come in to more uses in the future.
The question is how to implement it.
<?php
function drupalGet($path, $options = array(), $ = 10) {
$options['absolute'] = TRUE;
// We re-using a CURL connection here. If that connection still has certain
// options set, it might change the GET into a POST. Make sure we clear out
// previous options.
$out = $this->curlExec(array(CURLOPT_HTTPGET => TRUE, CURLOPT_URL => url($path, $options), CURLOPT_HEADER => FALSE, CURLOPT_NOBODY => FALSE));
$this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up.
return $out;
}
?>should I add something like:
<?php
if ($this->parse()) {
$refresh = $this->xpath('//meta[@http-equiv="Refresh"]');
if ($refresh) {
// .... call drupalGet again or something?
}
}
?>and if so should I call drupalGet again? or somehow allow for support of meta refresh with delay longer then 0? or even allow test to see the page in the middle?

#1
#2
Code like the following would do it, but I'm not sure this is what we want? Seems fine.
#3
Updated patch, that also removes hack related to simpletest.test with passes. :)
#4
Updated regex to allow for any or no whitespace instead of my [ ]+ space check...heh.
#5
Either the new page content of FALSE.Minor, but huh? Maybe that "of" should be "or", perhaps?
#6
chx:
* Named sub-pattern.
* Changed urldecode -> decode_entities.
#7
#5 fixed
#8
Good work!
#9
+ $refresh = $this->xpath('//meta[@http-equiv="Refresh"]');AFAICT this does a case-sensitive search for "Refresh", but the http-equiv attribute is case-insentive (according to the section 7.4.4 of the HTML spec).
#10
This is how ugly it looks after adding that...since we are really just trying to support Drupal not sure if we want this.
<?php$this->xpath('//meta[@http-equiv="Refresh"]');
?>
turned into:
<?php$this->xpath("//meta[contains(translate(@http-equiv,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 'REFRESH')]");
?>
plus made regex case insentive, but that was easy...just added modifier (i).
If not use #7.
#11
Let's go with #7 but add a comment about how to use it (i.e. case-sensitive).
#12
How about this.
#13
slight comment change.
#14
Added comments after webchick reviewed in IRC.
#15
Committed! Thanks. :)
#16
Automatically closed -- issue fixed for two weeks with no activity.