예제 #1
0
xassert(!$review2d->reviewSubmitted);
xassert($review2d->reviewNeedsSubmit == 0);
// uploading the current assignment makes no changes
function get_pcassignment_csv()
{
    global $user_chair;
    list($header, $texts) = SearchAction::pcassignments_csv_data($user_chair, range(1, 30));
    $csvg = new CsvGenerator();
    $csvg->set_header($header);
    $csvg->set_selection($header);
    $csvg->add($texts);
    return $csvg->unparse();
}
$old_pcassignments = get_pcassignment_csv();
xassert(AssignmentSet::run($user_chair, $old_pcassignments));
xassert_eqq(get_pcassignment_csv(), $old_pcassignments);
// `any` assignments
assert_search_papers($user_chair, "re:R1", "12 13");
assert_search_papers($user_chair, "re:R2", "13");
assert_search_papers($user_chair, "re:R3", "12");
assert_search_papers($user_chair, "round:none", "1 2 3 4 5 6 7 8 9 10 11 14 15 16 17 18");
xassert(AssignmentSet::run($user_chair, "action,paper,email,round\nreview,all,all,R1:none\n"));
assert_search_papers($user_chair, "re:R1", "");
assert_search_papers($user_chair, "re:R2", "13");
assert_search_papers($user_chair, "re:R3", "12");
assert_search_papers($user_chair, "round:none", "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18");
xassert(AssignmentSet::run($user_chair, "action,paper,email,round\nreview,1-5,all,none:R1"));
assert_search_papers($user_chair, "re:R1", "1 2 3 4 5");
assert_search_papers($user_chair, "re:R2", "13");
assert_search_papers($user_chair, "re:R3", "12");
assert_search_papers($user_chair, "round:none", "6 7 8 9 10 11 12 13 14 15 16 17 18");
예제 #2
0
function assert_query($q, $b)
{
    $result = Dbl::qe_raw($q);
    xassert_eqq(join("\n", edb_first_columns($result)), $b);
}
예제 #3
0
<?php

// test05.php -- HotCRP paper submission tests
// HotCRP is Copyright (c) 2006-2016 Eddie Kohler and Regents of the UC
// Distributed under an MIT-like license; see LICENSE
global $ConfSitePATH;
$ConfSitePATH = preg_replace(",/[^/]+/[^/]+\$,", "", __FILE__);
require_once "{$ConfSitePATH}/test/setup.php";
$Conf->save_setting("sub_open", 1);
$Conf->save_setting("sub_update", $Now + 100);
$Conf->save_setting("sub_sub", $Now + 100);
// load users
$user_estrin = Contact::find_by_email("*****@*****.**");
// pc
$user_nobody = new Contact();
$ps = new PaperStatus($user_estrin);
$paper1a = $ps->paper_json(1);
xassert_eqq($paper1a->title, "Scalable Timers for Soft State Protocols");
$ps->save_paper_json((object) ["id" => 1, "title" => "Scalable Timers? for Soft State Protocols"]);
xassert(!$ps->nerrors);
$paper1b = $ps->paper_json(1);
xassert_eqq($paper1b->title, "Scalable Timers? for Soft State Protocols");
$paper1b->title = $paper1a->title;
$paper1b->submitted_at = $paper1a->submitted_at;
xassert_eqq(json_encode($paper1b), json_encode($paper1a));
$doc = Filer::file_upload_json(["error" => UPLOAD_ERR_OK, "name" => "amazing-sample.pdf", "tmp_name" => "{$ConfSitePATH}/src/sample.pdf", "tmp_name_safe" => true, "type" => "application/pdf"]);
$ps->save_paper_json((object) ["id" => 1, "submission" => $doc]);
xassert(!$ps->nerrors);
$paper1c = $ps->paper_json(1);
xassert_eqq($paper1c->submission->sha1, "2f1bccbf1e0e98004c01ef5b26eb9619f363e38e");
xassert_exit();
예제 #4
0
xassert(Contact::is_anonymous_email("anonymous10"));
xassert(Contact::is_anonymous_email("anonymous9"));
xassert(!Contact::is_anonymous_email("*****@*****.**"));
xassert(!Contact::is_anonymous_email("example@anonymous"));
// Mailer::allow_send tests
$Opt["sendEmail"] = true;
xassert(Mailer::allow_send("*****@*****.**"));
xassert(Mailer::allow_send("*****@*****.**"));
xassert(!Mailer::allow_send("ass"));
xassert(!Mailer::allow_send("ass@_.com"));
xassert(!Mailer::allow_send("ass@_.co.uk"));
xassert(!Mailer::allow_send("*****@*****.**"));
xassert(!Mailer::allow_send("*****@*****.**"));
xassert(!Mailer::allow_send("*****@*****.**"));
xassert(!Mailer::allow_send("*****@*****.**"));
xassert(!Mailer::allow_send("*****@*****.**"));
xassert(!Mailer::allow_send("*****@*****.**"));
$Opt["sendEmail"] = false;
xassert(!Mailer::allow_send("*****@*****.**"));
xassert(!Mailer::allow_send("*****@*****.**"));
// NavigationState tests
$ns = new NavigationState(["SERVER_PORT" => 80, "SCRIPT_FILENAME" => __FILE__, "SCRIPT_NAME" => __FILE__, "REQUEST_URI" => "/fart/barf/?butt", "HTTP_HOST" => "butt.com", "SERVER_SOFTWARE" => "nginx"]);
xassert_eqq($ns->host, "butt.com");
xassert_eqq($ns->make_absolute("https://foo/bar/baz"), "https://foo/bar/baz");
xassert_eqq($ns->make_absolute("http://fooxxx/bar/baz"), "http://fooxxx/bar/baz");
xassert_eqq($ns->make_absolute("//foo/bar/baz"), "http://foo/bar/baz");
xassert_eqq($ns->make_absolute("/foo/bar/baz"), "http://butt.com/foo/bar/baz");
xassert_eqq($ns->make_absolute("after/path"), "http://butt.com/fart/barf/after/path");
xassert_eqq($ns->make_absolute("../after/path"), "http://butt.com/fart/after/path");
xassert_eqq($ns->make_absolute("?confusion=20"), "http://butt.com/fart/barf/?confusion=20");
xassert_exit();
예제 #5
0
}
foreach (array("u0", "u1", "u2") as $x) {
    foreach (array("p0", "p1", "p2") as $y) {
        $m->add_edge($x, $y, 1);
    }
}
$assignments = array();
foreach (range(100, 921384, 1247) as $seed) {
    $m->reset();
    srand($seed);
    // the shuffle() uses this seed
    $m->shuffle();
    $m->run();
    $assignments[mcmf_assignment_text($m)] = true;
}
$assignments = array_keys($assignments);
sort($assignments);
xassert_eqq(count($assignments), 6);
xassert_eqq($assignments[0], "u0 p0\nu1 p1\nu2 p2\n");
xassert_eqq($assignments[1], "u0 p0\nu1 p2\nu2 p1\n");
xassert_eqq($assignments[2], "u0 p1\nu1 p0\nu2 p2\n");
xassert_eqq($assignments[3], "u0 p1\nu1 p2\nu2 p0\n");
xassert_eqq($assignments[4], "u0 p2\nu1 p0\nu2 p1\n");
xassert_eqq($assignments[5], "u0 p2\nu1 p1\nu2 p0\n");
fwrite(STDERR, "- Phase 4 complete.\n");
$m = new MinCostMaxFlow();
$m->parse_dimacs("n 1 s\nn 2 t\nc ninfo 3 u0 u\nc ninfo 4 u1 u\nc ninfo 5 u2 u\nc ninfo 6 p0 p\nc ninfo 7 p1 p\nc ninfo 8 p2 p\na 1 3 1\na 1 4 1\na 1 5 1\na 3 6 0 1 0\na 3 7 0 1 -1\na 4 6 0 1 0\na 4 7 0 1 0\na 4 8 0 1 0\na 5 6 0 1 0\na 5 8 0 1 1\na 6 2 1\na 7 2 1\na 8 2 1");
$m->run();
xassert_eqq(mcmf_assignment_text($m), "u0 p1\nu1 p2\nu2 p0\n");
xassert_eqq(preg_replace('/^c[^\\n]*\\n/m', "", $m->mincost_dimacs_output()), "s -1\nf 1 3 1\nf 1 4 1\nf 1 5 1\nf 3 7 1\nf 4 8 1\nf 5 6 1\nf 6 2 1\nf 7 2 1\nf 8 2 1\n");
xassert_exit();
예제 #6
0
xassert_eqq($te2->lastName, "Thamrongrattanarit 1");
xassert_eqq($te2->affiliation, "String");
$te2_cdb = $te2->contactdb_user();
xassert(!!$te2_cdb);
xassert_eqq($te2_cdb->firstName, "Te 1");
xassert_eqq($te2_cdb->lastName, "Thamrongrattanarit 1");
xassert_eqq($te2_cdb->affiliation, "String");
// borrow from cdb
$acct = $us->save((object) ["email" => "te@_.com"]);
xassert(!!$acct);
$te = user("te@_.com");
xassert_eqq($te->email, "te@_.com");
xassert_eqq($te->firstName, "Te");
xassert_eqq($te->lastName, "Thamrongrattanarit");
xassert_eqq($te->affiliation, "Brandeis University");
xassert_eqq($te->collaborators, "Computational Linguistics Magazine");
// create a user in cdb: create, then delete from local db
$anna = "*****@*****.**";
xassert(!user($anna));
$acct = $us->save((object) ["email" => $anna, "first" => "Anna", "last" => "Akhmatova"]);
xassert(!!$acct);
Dbl::qe("delete from ContactInfo where email=?", $anna);
save_password($anna, "aquablouse", true);
xassert(!user($anna));
$user_estrin = user("*****@*****.**");
$user_floyd = user("*****@*****.**");
$user_van = user("*****@*****.**");
$ps = new PaperStatus(null);
$ps->save_paper_json((object) ["id" => 1, "authors" => ["*****@*****.**", $user_estrin->email, $user_floyd->email, $user_van->email, $anna]]);
$paper1 = $Conf->paperRow(1, $user_chair);
$user_anna = user($anna);