From b43bf68f9c5b1396ae50db6a1ea087efb7b3b19f Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 30 Aug 2011 23:40:29 +1200 Subject: [PATCH] MINOR: Minor fixes to FunctionalTest --- dev/TestSession.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/dev/TestSession.php b/dev/TestSession.php index 4e81e312a..afb71eb7f 100644 --- a/dev/TestSession.php +++ b/dev/TestSession.php @@ -96,8 +96,12 @@ class TestSession { $form->setField(new SimpleByName($k), $v); } - if($button) $submission = $form->submitButton(new SimpleByName($button)); - else $submission = $form->submit(); + if($button) { + $submission = $form->submitButton(new SimpleByName($button)); + if(!$submission) throw new Exception("Can't find button '$button' to submit as part of test."); + } else { + $submission = $form->submit(); + } $url = Director::makeRelative($form->getAction()->asString()); @@ -137,6 +141,15 @@ class TestSession { return $this->lastResponse; } + /** + * Return the fake HTTP_REFERER; set each time get() or post() is called. + * + * @return string + */ + public function lastUrl() { + return $this->lastUrl; + } + /** * Get the most recent response's content */