Page 1 of 1

[SOLVED, Cause: Stupidity] WebTestCase submitFormById

Posted: Fri Jun 09, 2006 5:32 pm
by Nathaniel
Hi guys,

I have:

Code: Select all

class HelpTestCase extends WebTestCase
{
	function testDefaultsToIndexOfQuestions()
	{
		$this->get('http://help.yogler.com/');
		$this->assertResponse(200);
		$this->assertWantedPattern('/yogler.com help/i');
		$this->assertField('q');
		$this->submitFormById('search');
		$this->assertResponse(200, 'If this does not pass, check that the index tests pass first. Error: %s; Current URL: ' . $this->getUrl());
	}
}
http://help.yogler.com currently spits out:

Code: Select all

<html><body>yogler.com help <form id="submit" method="get" action="/search"><input name="q" /></form></body></html>
The one fail that SimpleTest comes up with is
If this does not pass, check that the index tests pass first. Error: Expecting response in [200] got []; Current URL: at line [20]
So... it appears to me that it does not like submitting the form by the id... but why? Submitting the form manually by hitting enter when the input box is in focus works as intended.

- Nathaniel

Posted: Fri Jun 09, 2006 7:04 pm
by Christopher
You are doing submitFormById('search') but the ID of your form is 'submit'.

Posted: Fri Jun 09, 2006 7:17 pm
by Nathaniel
... yeah.

Thanks. Please excuse the oversight :D