From 63ce0bd4ecf25791150a76d6b2396fab759922f3 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 16 Dec 2009 05:40:27 +0000 Subject: [PATCH] ENHANCEMENT Added FunctionalTest::findAttribute() as a helper for getting an attribute from a SimpleXMLElement object by it's name (from r94381) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@95605 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- dev/FunctionalTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dev/FunctionalTest.php b/dev/FunctionalTest.php index b58689295..e02c66d84 100644 --- a/dev/FunctionalTest.php +++ b/dev/FunctionalTest.php @@ -121,6 +121,22 @@ class FunctionalTest extends SapphireTest { function content() { return $this->mainSession->lastContent(); } + + /** + * Find an attribute in a SimpleXMLElement object by name. + * @param SimpleXMLElement object + * @param string $attribute Name of attribute to find + * @return SimpleXMLElement object of the attribute + */ + function findAttribute($object, $attribute) { + $found = false; + foreach($object->attributes() as $a => $b) { + if($a == $attribute) { + $found = $b; + } + } + return $found; + } /** * Return a CSSContentParser for the most recent content.