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...