/*
* Copyright (C) 2007-2008 Alain Peyrat <aljeux at free dot fr>
* Copyright (C) 2009 Alain Peyrat, Alcatel-Lucent
+ * Copyright 2013, Franck Villaume - TrivialDev
*
* This file is part of FusionForge.
*
$this->setHost(SELENIUM_RC_HOST);
}
-// protected function waitForPageToLoad($timeout)
-// {
-// parent::waitForPageToLoad($timeout);
-// $this->test->assertFalse($this->isTextPresent("Notice: Undefined variable:"));
-// $this->test->assertFalse($this->isTextPresent("Notice: Undefined index:"));
-// $this->test->assertFalse($this->isTextPresent("Warning: Missing argument"));
-// }
+ /**
+ * Method that is called after Selenium actions.
+ *
+ * @param string $action
+ */
+ protected function defaultAssertions($action)
+ {
+ if ($action == 'waitForPageToLoad') {
+ $this->assertElementPresent("//h1");
+// $this->assertFalse($this->isElementPresent("//div[@id='ffErrors']"));
+// $this->assertFalse($this->isTextPresent("PhpWiki Warning:"));
+ }
+ }
+
+ protected function clickAndWait($link)
+ {
+ $this->click($link);
+ $this->waitForPageToLoad();
+ }
+
+ protected function waitForTextPresent($text)
+ {
+ for ($second = 0; ; $second++) {
+ if ($second >= 30) $this->fail("timeout");
+ try {
+ if ($this->isTextPresent($text)) break;
+ } catch (Exception $e) {}
+ sleep(1);
+ }
+ }
- protected function runCommand($cmd)
- {
- system($cmd);
- }
+ protected function runCommand($cmd)
+ {
+ system($cmd);
+ }
+
+ protected function db($sql)
+ {
+ system("echo \"$sql\" | psql -q -Upostgres ".DB_NAME);
+ }
protected function cron($cmd)
{
protected function populateStandardTemplate($what='all')
{
if ($what == 'all') {
- $what = array('trackers','tasks','forums','docs');
+ $what = array('trackers','tasks','forums');
} elseif ($what == 'empty') {
$what = array();
} elseif (!is_array($what)) {
$this->waitForPageToLoad("30000");
if (in_array ('trackers', $what)) {
- $this->click("link=Trackers Admin");
+ $this->click("link=Trackers Administration");
$this->waitForPageToLoad("30000");
$this->type("name", "Bugs");
- $this->type("description", "Tracker for bug reports");
+ $this->type("//input[@name='description']", "Tracker for bug reports");
$this->click("post_changes");
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("Tracker created successfully"));
$this->waitForPageToLoad("30000");
$this->click("link=Tools");
$this->waitForPageToLoad("30000");
- $this->click("link=Trackers Admin");
+ $this->click("link=Trackers Administration");
$this->waitForPageToLoad("30000");
$this->type("name", "Support Requests");
- $this->type("description", "Tracker for support requests");
+ $this->type("//input[@name='description']", "Tracker for support requests");
$this->click("post_changes");
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("Tracker created successfully"));
$this->type("name", "Patches");
- $this->type("description", "Proposed changes to code");
+ $this->type("//input[@name='description']", "Proposed changes to code");
$this->click("post_changes");
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("Tracker created successfully"));
$this->type("name", "Feature Requests");
- $this->type("description", "New features that people want");
+ $this->type("//input[@name='description']", "New features that people want");
$this->click("post_changes");
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("Tracker created successfully"));
$this->waitForPageToLoad("30000");
$this->click("link=Tools");
$this->waitForPageToLoad("30000");
- $this->click("link=Tasks Admin");
+ $this->click("link=Tasks Administration");
$this->waitForPageToLoad("30000");
$this->click("link=Add a Subproject");
$this->waitForPageToLoad("30000");
$this->type("project_name", "To Do");
- $this->type("description", "Things we have to do");
+ $this->type("//input[@name='description']", "Things we have to do");
$this->click("submit");
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("Subproject Inserted"));
$this->type("project_name", "Next Release");
- $this->type("description", "Items for our next release");
+ $this->type("//input[@name='description']", "Items for our next release");
$this->click("submit");
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("Subproject Inserted"));
$this->click("link=Forums Admin");
$this->waitForPageToLoad("30000");
- $this->click("link=Add forum");
+ $this->click("link=Add Forum");
$this->waitForPageToLoad("30000");
$this->type("forum_name", "Open-Discussion");
- $this->type("description", "General Discussion");
+ $this->type("//input[@name='description']", "General Discussion");
$this->click("submit");
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("Forum added successfully"));
$this->type("forum_name", "Help");
- $this->type("description", "Get Public Help");
+ $this->type("//input[@name='description']", "Get Public Help");
$this->click("submit");
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("Forum added successfully"));
$this->type("forum_name", "Developers-Discussion");
- $this->type("description", "Project Developer Discussion");
+ $this->type("//input[@name='description']", "Project Developer Discussion");
$this->click("submit");
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("Forum added successfully"));
$this->assertTrue($this->isTextPresent("Get Public Help"));
$this->assertTrue($this->isTextPresent("Project Developer Discussion"));
}
-
- if (in_array ('docs', $what)) {
- $this->click("link=Docs");
- $this->waitForPageToLoad("30000");
- $this->click("link=Add new item");
- $this->waitForPageToLoad("30000");
- $this->click("link=Add new item");
- $this->waitForPageToLoad("30000");
- $this->click("//input[@name='type' and @value='folder']");
- $this->type("groupname", "Uncategorized Submissions2");
- $this->click("//input[@id='submitaddsubgroup']");
- $this->waitForPageToLoad("30000");
- $this->assertTrue($this->isTextPresent("Uncategorized Submissions2"));
- }
}
protected function initSvn($project='ProjectA', $user=FORGE_ADMIN_USERNAME)
return $this->isTextPresent("Permission denied") ;
}
- protected function registerProject ($name, $user) {
+ protected function registerProject ($name, $user, $scm='scmsvn') {
$unix_name = strtolower($name);
$saved_user = $this->logged_in ;
$this->clickAndWait("link=Register Project");
$this->type("full_name", $name);
$this->type("purpose", "This is a simple description for $name");
- $this->type("description", "This is the public description for $name.");
+ $this->type("//textarea[@name='description']", "This is the public description for $name.");
$this->type("unix_name", $unix_name);
- $this->click("//input[@name='scm' and @value='scmsvn']");
+ $this->click("//input[@name='scm' and @value='$scm']");
if ($this->isElementPresent("//select[@name='built_from_template']/option[.='Tmpl']")) {
$this->select("//select[@name='built_from_template']", "label=Tmpl");
}
- $this->click("submit");
- $this->waitForPageToLoad("30000");
- $this->assertTrue($this->isTextPresent("Your project has been submitted"));
- $this->assertTrue($this->isTextPresent("you will receive notification of their decision and further instructions"));
+ $this->clickAndWait("submit");
+ $this->assertTextPresent("Your project has been automatically approved");
$this->switchUser ($saved_user) ;
}
$this->switchUser ($saved_user) ;
}
- protected function createProject ($name) {
+ protected function createProject ($name, $scm='scmsvn') {
$unix_name = strtolower($name);
$this->switchUser (FORGE_ADMIN_USERNAME) ;
-
+
// Create a simple project.
if ((!defined('PROJECTA')) || ($unix_name != "projecta")) {
- $this->registerProject ($name, FORGE_ADMIN_USERNAME) ;
- $this->approveProject ($name, FORGE_ADMIN_USERNAME) ;
+ $this->registerProject ($name, FORGE_ADMIN_USERNAME, $scm) ;
}
}
$this->clickAndWait("submit");
$this->clickAndWait("link=Site Admin");
$this->clickAndWait("link=Display Full User List/Edit Users");
- $this->click("//table/tbody/tr/td/a[contains(@href,'useredit.php') and contains(.,'($login)')]/../..//a[contains(@href, 'userlist.php?action=activate&user_id=')]");
- $this->waitForPageToLoad("30000");
+ $this->clickAndWait("//table/tbody/tr/td/a[contains(@href,'useredit.php') and contains(.,'($login)')]/../..//a[contains(@href, 'userlist.php?action=activate&user_id=')]");
}
protected function activatePlugin($pluginName) {
// mode: php
// c-file-style: "bsd"
// End:
-
-?>