Getting more and more stumped
Posted: Mon Aug 08, 2005 11:40 pm
I think I fought through all the issues with testing my test tools; but it broke a lot of my existing tests. I thought that was because I had changed the interface slightly. However its a deeper problem and I think it should be "impossible".
Here is the tests of the Web Test Tool:
Here is the source for the test tool:
Here's a bit of a test class that uses the test tool:
Now for the "impossible aspect" -- All of the tests of the test tool pass. However all the tests that use it fail. In all cases the post fails in the setup so there is no page loaded. (The showSource is empty).
So I added the debug "POST FAILED" strings and captured the T/F return from post. What's really confusing me is that the last test method in the test of web tools (last method of first code block) is also triggering the POST FAILED, but still passing the test!!!?? How is that possible?
Digging deeper I also find that $browser->setField() is often returning false, even though it appears to set the field...
Here is the tests of the Web Test Tool:
Code: Select all
class WebAuthTestCaseTest extends DatabaseUnitTestCase {
function WebAuthTestCaseTest() {
$this->DatabaseUnitTestCase('WebAuthTestCase Tests');
}
function testLoginFromLoginPage() {
$browser = new SimpleBrowser();
$browser->get(CIB_URL."accounts/login.php");
$browser->setField("username","siteadmin-tester");
$browser->setField("password","XXXX");
$browser->clickSubmit("Login");
$this->assertPattern("/personal/",$browser->getUrl());
}
function testRedirectFromLoginPage() {
$browser = new SimpleBrowser();
$browser->get(CIB_URL."accounts/login.php");
$browser->setField("username","siteadmin-tester");
$browser->setField("password","XXXX");
$browser->setField("returnTo","results/import_cib.php");
$browser->clickSubmit("Login");
$this->assertPattern("/import_cib/",$browser->getUrl());
}
function testLogin() {
$web = new WebAuthTestCase("Testing Login","siteadmin-tester","/");
$web->setBrowser($web->createBrowser()); // simulate invoke
$web->_runner = &$web->_createRunner(new HTMLReporter()); // simulate run
$web->setup();
$this->assertPattern("/personal/",$web->getUrl());
}
function testLoginWithRedirect() {
$web = new WebAuthTestCase("Testing Login","siteadmin-tester",
"results/import_cib.php");
$web->setBrowser($web->createBrowser()); // simulate invoke
$web->_runner = &$web->_createRunner(new HTMLReporter()); //simulate run
$web->setup();
$this->assertPattern("/import_cib/",$web->getUrl());
}
}Code: Select all
class WebAuthTestCase extends DatabaseWebTestCase {
var $u;
var $p;
var $logins;
function WebAuthTestCase($title,$user,$page="") {
parent::DatabaseWebTestCase($title);
$this->u=$user;
$this->p=$page;
$this->logins["siteadmin-tester"]="XXXX";
}
/** Login and Navigate to desired page */
function setup() {
parent::setUp();
$postTo=CIB_URL."accounts/SCRIPTS/login.php";
$postParam=array("returnTo"=>$this->p,
"username"=>$this->u,
"password"=>$this->logins[$this->u]);
$temp=$this->post($postTo, $postParam);
if (!$temp) {echo "POST FAILED--$postTo--"; print_r($postParam);}
}
function tearDown() {
parent::tearDown();
}
}
?>Code: Select all
class TestAdminLinks extends WebAuthTestCase {
function TestAdminLinks() {
$this->WebAuthTestCase('Sliding Doors Admin -- Admin Links',
"siteadmin-tester","register/SD/admin/index.php");
}
function setUp() {
parent::setUp();
}
function testInformationExportOption() {
$this->showSource();
$this->assertWantedText("Information Export");
}
}So I added the debug "POST FAILED" strings and captured the T/F return from post. What's really confusing me is that the last test method in the test of web tools (last method of first code block) is also triggering the POST FAILED, but still passing the test!!!?? How is that possible?
Digging deeper I also find that $browser->setField() is often returning false, even though it appears to set the field...