Add xpath method to Simpletest and refactor existing tests

boombatower - August 20, 2008 - 23:00
Project:Drupal
Version:7.x-dev
Component:simpletest.module
Category:task
Priority:critical
Assigned:boombatower
Status:closed
Description

A number of tests and internal functions use xpath to make assertions. This is a very powerful feature, but is not documented or exposed in any way.

This patch adds an xpath method to DrupalWebTestCase so that it can be both documented, used consistently, and enclosed in the proper $this->parse() condition.

The patch also reactors existing tests and internal code that uses xpath. Changing $this->elements->xpath(...) becomes $this->xpath(...).

I have not tested this patch and will get back to it, but I have to leave at the moment so I figured I would post what I have.

AttachmentSizeStatusTest resultOperations
simpletest_xpath.patch6.34 KBIgnoredNoneNone

#1

boombatower - August 20, 2008 - 23:33
Status:needs review» needs work

Making some changes.

#2

boombatower - August 20, 2008 - 23:50
Status:needs work» needs review

Just needed $this->elements->xpath() instead of $this->xpath() (recursion heh).

AttachmentSizeStatusTest resultOperations
simpletest_xpath.patch6.35 KBIgnoredNoneNone

#3

boombatower - August 20, 2008 - 23:51
Priority:normal» critical

This patch is required for: #297894: Add assertLink and assertNoLink to SimpleTest
which is required for: #296693: Empty admin categories are not hidden
which is required for: #263616: Move SimpleTest out of "Site building"

So I'll mark it as critical.

#4

boombatower - August 20, 2008 - 23:58
Status:needs review» needs work

Ran tests on changed/effected code and they all pass except two with exception. If someone wants to run on all tests that would be great.

SimpleTest functionality: 43 passes, 0 fails, 2 exceptions
Drupal HTTP request: 4 passes, 0 fails, 2 exceptions

#5

boombatower - August 21, 2008 - 00:08
Status:needs work» needs review

This should fix the exception mentioned. Still need whole suite to be run.

AttachmentSizeStatusTest resultOperations
simpletest_xpath.patch6.35 KBIgnoredNoneNone

#6

boombatower - August 21, 2008 - 00:33

Ran entire test suite with all passes.

#7

moshe weitzman - August 21, 2008 - 03:55

Code looks good to me. Since the test suite still runs to 100% perfecton, this is RTBC.

#8

moshe weitzman - August 21, 2008 - 03:55
Status:needs review» reviewed & tested by the community

#9

Dries - August 22, 2008 - 12:36
Status:reviewed & tested by the community» fixed

Committed to CVS HEAD. Thanks.

#10

Anonymous (not verified) - September 11, 2008 - 05:32
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.