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

boombatower - October 2, 2008 - 18:05
Title:Add meta refresh support to simpletest» Add meta refresh support to SimpleTest

#2

boombatower - October 2, 2008 - 18:13
Status:active» needs review

Code like the following would do it, but I'm not sure this is what we want? Seems fine.

AttachmentSize
simpletest_meta_refresh.patch 1.09 KB

#3

boombatower - October 2, 2008 - 18:36

Updated patch, that also removes hack related to simpletest.test with passes. :)

AttachmentSize
simpletest_meta_refresh.patch 4.98 KB

#4

boombatower - October 2, 2008 - 19:04

Updated regex to allow for any or no whitespace instead of my [ ]+ space check...heh.

AttachmentSize
simpletest_meta_refresh.patch 4.98 KB

#5

keith.smith - October 2, 2008 - 19:14
Status:needs review» needs work

Either the new page content of FALSE.

Minor, but huh? Maybe that "of" should be "or", perhaps?

#6

boombatower - October 2, 2008 - 19:15
Status:needs work» needs review

chx:

* Named sub-pattern.
* Changed urldecode -> decode_entities.

AttachmentSize
simpletest_meta_refresh.patch 4.99 KB

#7

boombatower - October 2, 2008 - 19:19

#5 fixed

AttachmentSize
simpletest_meta_refresh.patch 4.99 KB

#8

chx - October 2, 2008 - 19:31
Status:needs review» reviewed & tested by the community

Good work!

#9

c960657 - October 3, 2008 - 21:55
Status:reviewed & tested by the community» needs work

+      $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

boombatower - October 4, 2008 - 07:26
Status:needs work» reviewed & tested by the community

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.

AttachmentSize
simpletest_meta_refresh.patch 5.07 KB

#11

Dries - October 4, 2008 - 19:16
Status:reviewed & tested by the community» needs work

Let's go with #7 but add a comment about how to use it (i.e. case-sensitive).

#12

boombatower - October 4, 2008 - 21:47
Status:needs work» reviewed & tested by the community

How about this.

AttachmentSize
simpletest_meta_refresh.patch 5.09 KB

#13

boombatower - October 4, 2008 - 21:48

slight comment change.

AttachmentSize
simpletest_meta_refresh.patch 5.1 KB

#14

boombatower - October 9, 2008 - 02:44

Added comments after webchick reviewed in IRC.

AttachmentSize
simpletest_meta_refresh.patch 5.36 KB

#15

webchick - October 9, 2008 - 02:50
Status:reviewed & tested by the community» fixed

Committed! Thanks. :)

#16

Anonymous (not verified) - October 23, 2008 - 02:52
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.