Beispiel #1
0
 function testEffort()
 {
     global $g_streber_url;
     TestEnvironment::initStreberUrl();
     TestEnvironment::prepare('fixtures/project_setup.sql');
     $this->addHeader('USER_AGENT: streber_unit_tester');
     ### logout first ###
     $this->assertTrue($this->get($g_streber_url), 'getting login page (%s)');
     $this->assertWantedPattern('/please login/i', 'check content (%s)');
     $this->assertValidHtmlStucture('login');
     ### Test login working ###
     $this->assertTrue($this->setField('login_name', 'bob'));
     $this->assertTrue($this->setField('login_password', 'bob_secret'));
     $this->assertTrue($this->clickSubmit('Submit'));
     validatePage($this);
     $this->assertTrue($this->get($g_streber_url . "/index.php?go=projViewEfforts&prj=10"), 'getting project effort view (%s)');
     validatePage($this);
     $this->assertTrue($this->get($g_streber_url . "/index.php?go=homeListEfforts"), 'getting user efforts (%s)');
     validatePage($this);
     $this->assertTrue($this->get($g_streber_url . "/index.php?go=effortNew&prj=10"), 'book new effort (%s)');
     validatePage($this);
     $this->assertTrue($this->setField('effort_name', 'bla2'));
     $this->assertTrue($this->clickSubmit('Submit'));
     validatePage($this);
 }
Beispiel #2
0
* test installation
*/
#$grouptest = new GroupTest('Installation');
#$grouptest->addTestFile('test_install.php');
#$grouptest->run(new HtmlReporter());
#
### create a function to make sure we are starting at index.php ###
function startedIndexPhp()
{
    return true;
}
### include some core libraries ###
require_once '../std/common.inc.php';
require_once dirname(__FILE__) . '/../conf/conf.inc.php';
require_once dirname(__FILE__) . '/class.test_environment.php';
#confChange('DB_TABLE_PREFIX_UNITTEST', '');   # overwrite development database!!!
TestEnvironment::initStreberUrl();
TestEnvironment::prepare('fixtures/project_setup.sql');
$grouptest = new GroupTest('Efforts');
$grouptest->addTestFile('test_efforts.php');
$grouptest->run(new HtmlReporter());
$grouptest = new GroupTest('Item visibility');
$grouptest->addTestFile('test_item_visibility.php');
$grouptest->run(new HtmlReporter());
$grouptest = new GroupTest('Login logic');
$grouptest->addTestFile('test_pages_login.php');
$grouptest->run(new HtmlReporter());
$grouptest = new GroupTest('Render all pages');
$grouptest->addTestFile('test_pages_all.php');
$result = $grouptest->run(new HtmlReporter());
#TestEnvironment::prepare('fixtures/remove_tables.sql');
Beispiel #3
0
 /**
  *
  */
 function testAllPages()
 {
     global $g_streber_url;
     TestEnvironment::prepare('fixtures/project_setup.sql');
     TestEnvironment::initStreberUrl();
     $this->addHeader('USER_AGENT: streber_unit_tester');
     /**
      * we require some valid logins and ids to test all pages
      */
     $login_name = "admin";
     $login_password = "";
     # FIXME: Setting an absolute path is bad!
     $url_start = $g_streber_url . '/index.php?go=logout';
     $test_params = array("_projectView_" => 12, "_projectEdit_" => 12, "_taskView_" => 18, "_taskEdit_" => 18, "_personView_" => 1, "_personEdit_" => 1, "_companyView_" => 8, "_companyEdit_" => 8, "_commentView_" => 39, "_commentEdit_" => 39, "_effortView_" => 35, "_effortEdit_" => 35);
     require_once "../conf/defines.inc.php";
     # the order of those includes is tricky
     require_once '../std/class_auth.inc.php';
     require_once "../std/class_pagehandler.inc.php";
     require_once "../pages/_handles.inc.php";
     confChange('USE_MOD_REWRITE', false);
     # uncomment this for apache 1.x
     /**
      * test all pagehandles for correct rendering
      */
     ### go though all pagehandles and render ###
     foreach ($PH->hash as $key => $handle) {
         ### enter login-infos ###
         $this->assertTrue($this->get($url_start), 'getting logout-page (%s)');
         $this->assertTrue($this->setField('login_name', $login_name), 'set login-name (%s)');
         $this->assertTrue($this->setField('login_password', $login_password), 'set password (%s)');
         ### submit -> login to home ###
         $this->assertTrue($this->clickSubmit('Submit'), 'click_submit');
         $this->assertNoUnwantedPattern('/invalid login/i', 'Login for testing working (%s)');
         if ($handle->test == 'yes') {
             TestEnvironment::prepare('fixtures/project_setup.sql');
             $params = array();
             if (isset($handle->test_params)) {
                 foreach ($handle->test_params as $param => $value) {
                     if (isset($test_params[$value])) {
                         #echo "using param $param=$test_params[$value]<br>";
                         $params[$param] = $test_params[$value];
                     }
                 }
                 $url = $g_streber_url . $PH->getUrl($key, $params);
             } else {
                 $url = $g_streber_url . $PH->getUrl($key);
             }
             echo "<b>{$handle->id}</b> ";
             print_r($params);
             echo "<br>";
             $this->assertTrue($this->get("/" . $url), "getting {$url} (%s)");
             $this->assertNoUnwantedPattern('/PHP Error |<b>Fatal error<\\/b>|<b>Warning<\\/b>|<b>Error<\\/b>|<b>Notice<\\/b>|<b>Parse error<\\/b>/i', 'php-error found (%s)');
             $this->assertNoUnwantedPattern('/' . '%' . '%' . '/i', 'debug output found (%s)');
             $this->assertValidHtmlStucture($url);
             $this->assertNoUnwantedPattern('/fatal error \\(/i', 'check for streber warnings (%s)');
             $this->assertNoUnwantedPattern('/Error:/i', 'check for streber warnings (%s)');
             $this->assertWantedPattern('/<\\/html>/', 'rendering Complete? (%s)');
             $this->assertNoUnwantedPattern('/<x>/', 'check unescaped data (%s)');
             $this->assertNoUnwantedPattern('/&amp;lt;x&amp;gt;/', 'check double escaped data (%s)');
             for ($i = 0; $i < 20; $i++) {
                 echo "                       ";
             }
         }
     }
 }
 /**
  * scenario: 
  * - bob runs beserk an deletes all tasks of manhatten project
  * - pm logs in an reverts all changes by bob
  */
 function testRevertChanges()
 {
     TestEnvironment::initStreberUrl();
     global $g_streber_url;
     TestEnvironment::prepare('fixtures/project_setup.sql');
     $this->addHeader('USER_AGENT: streber_unit_tester');
     $deleted_items = array(25, 23, 19, 18);
     ### login as bob ###
     $this->assertTrue($this->get($g_streber_url), 'getting login page (%s)');
     $this->assertTrue($this->setField('login_name', 'bob'));
     $this->assertTrue($this->setField('login_password', 'bob_secret'));
     $this->assertTrue($this->clickSubmit('Submit'));
     validatePage($this);
     ### View topics ###
     ### delete all tasks
     foreach ($deleted_items as $id) {
         $this->assertTrue($this->get($g_streber_url . '/?go=tasksDelete&tsk=' . $id), 'deleting (%s)');
         print $id;
         $this->assertNoUnwantedText('Warning:');
     }
     ### make sure, we are at home and items are listed as deleted
     $this->assertWantedText('deleted by ');
     ### make sure, bob can't access revert function, because it's only for admins
     $this->assertTrue($this->get($g_streber_url . '/?go=personRevertChanges&person=5'), 'getting revert page (%s)');
     $this->assertWantedText('Operation aborted');
     ### logout bob ###
     $this->assertTrue($this->clickLink('Logout'));
     $this->assertWantedPattern('/please login/i', 'check content (%s)');
     $this->assertValidHtmlStucture('login');
     ### login as pm ###
     $this->assertTrue($this->get($g_streber_url), 'getting login page (%s)');
     $this->assertTrue($this->setField('login_name', 'pm'));
     $this->assertTrue($this->setField('login_password', 'pm_secret'));
     $this->assertTrue($this->clickSubmit('Submit'));
     validatePage($this);
     ### make sure he sees the deleted tasks at home
     $this->assertWantedPattern("/body class=\"home\"/");
     #$this->showSource();
     foreach ($deleted_items as $id) {
         $this->assertWantedPattern("/{$id}\">.*deleted by <span class=person>Bob/");
         #            echo "<pre>" . $this->_browser->getContent() . "</pre>";
     }
     $this->assertTrue($this->get($g_streber_url . '/?go=personRevertChanges&person=5'), 'getting revert page (%s)');
     validatePage($this);
     $this->assertTrue($this->get($g_streber_url));
     ### make sure pm does no longer see any changes by bob
     foreach ($deleted_items as $id) {
         $this->assertNoUnwantedPattern("/href=\"{$id}\">.*deleted by <span class=person>Bob/");
     }
 }