function testCheck_proid()
 {
     global $t;
     $db_config = new mock_db_configure(7);
     $db_q = array(0 => $this->queries['check_proid']);
     $dat = $this->_generate_records(array("proid"), 7);
     $rows = $this->_generate_records(array("status"), 7);
     $dat[0]["proid"] = '';
     // first test
     $rows[2]["status"] = 0;
     // third test
     $rows[3]["status"] = 0;
     // fourth test
     $rows[4]["status"] = -1;
     // fifth test
     $rows[5]["status"] = -1;
     // sixth test
     $rows[6]["status"] = 1;
     // seventh test
     for ($idx = 0; $idx < 7; $idx++) {
         $db_config->add_query(sprintf($db_q[0], $dat[$idx]["proid"]), $idx);
         $db_config->add_record($rows[$idx], $idx);
         $db_config->add_num_row($idx != 1 ? 1 : 0, $idx);
     }
     // first test: proid is empty
     capture_reset_and_start();
     $this->assertEquals(0, check_proid($dat[0]['proid']), "return value test 1");
     $this->set_text(capture_stop_and_get());
     $this->set_msg('test 1');
     $this->_test_error_box("Error", "No project with this id.");
     $this->_testFor_string_length(691);
     // second test: num_rows == 0
     capture_reset_and_start();
     $this->assertEquals(0, check_proid($dat[1]['proid']), "return value test 2");
     $this->set_text(capture_stop_and_get());
     $this->set_msg('test 2');
     $this->_test_error_box("Error", "No project with this id.");
     $this->_testFor_string_length(691);
     // third test: status value is zero and permission editor is not set
     $GLOBALS['perm']->remove_perm('editor');
     capture_reset_and_start();
     $this->assertEquals(0, check_proid($dat[2]['proid']), "return value test 3");
     $this->set_text(capture_stop_and_get());
     $this->set_msg('test 3');
     $this->_test_error_box("Error", "Project pending for review " . "by an editor");
     $this->_testFor_string_length(706);
     // fourth test: status value is zero and permission editor is set
     $GLOBALS['perm']->add_perm('editor');
     capture_reset_and_start();
     $this->assertEquals(1, check_proid($dat[3]['proid']), "return value test 4");
     $this->assert(strlen(capture_stop_and_get()) == 0, 'test 4');
     // fifth test: status value is minus one & perm editor is not set
     $GLOBALS['perm']->remove_perm('editor');
     capture_reset_and_start();
     $this->assertEquals(0, check_proid($dat[4]['proid']), "return value test 5");
     $this->set_text(capture_stop_and_get());
     $this->set_msg('test 5');
     $this->_test_error_box("Error", "Project was not accepted.");
     $this->_testFor_string_length(692);
     // sixth test: status value is minus one & perm editor is set
     $GLOBALS['perm']->add_perm('editor');
     capture_reset_and_start();
     $this->assertEquals(1, check_proid($dat[5]['proid']), "return value test 6");
     $this->assert(strlen(capture_stop_and_get()) == 0, 'test 6');
     // seventh test: status value is one, num_rows > 0, proid is not empty
     capture_reset_and_start();
     $this->assertEquals(1, check_proid($dat[6]['proid']), "return value test 7");
     $this->assert(strlen(capture_stop_and_get()) == 0, 'test 7');
     // check database object
     $this->_check_db($db_config);
 }
예제 #2
0
# This program is free software. You can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 or later of the GPL.
######################################################################
require "include/prepend.php3";
page_open(array("sess" => "SourceAgency_Session"));
if (isset($auth) && !empty($auth->auth["perm"])) {
    page_close();
    page_open(array("sess" => "SourceAgency_Session", "auth" => "SourceAgency_Auth", "perm" => "SourceAgency_Perm"));
}
require "include/header.inc";
require "include/contentlib.inc";
$bx = new box('100%', $th_box_frame_color, $th_box_frame_width, $th_box_title_bgcolor, $th_box_title_font_color, $th_box_title_align, $th_box_body_bgcolor, $th_box_body_font_color, $th_box_body_align);
start_content();
$page = "modify contents";
if (check_proid($proid)) {
    top_bar($proid, $page);
    print $t->translate('Technical contents') . "\n<br><p>\n";
    if ((!isset($preview) || empty($preview)) && (!isset($submit) || empty($submit))) {
        $db->query("SELECT * FROM tech_content WHERE content_id='4'");
        $db->next_record();
        $content_id = $db->f("content_id");
        $skills = $db->f("skills");
        $platform = $db->f("platform");
        $architecture = $db->f("architecture");
        $environment = $db->f("environment");
        $docs = $db->f("docs");
        $specification = $db->f("specification");
        $creation = $db->f("creation");
    }
    if (!isset($submit) || empty($submit)) {