source: trunk/tests/round.php @ 1184

Revision 1091, 7.6 KB checked in by bogdan2412, 2 years ago (diff)

Many many small fixes.

  • Changed task-tag action from simple-critical to simple-edit.
  • Fixed downloading attachments containing grader from normal (non-task) pages.
  • Moved a call to remote_ip_info() from common/ to www/ where it's supposed to be in MVC.
  • Fixed round and task tests.
  • Fixed test cleanup to delete only the created users and to delete them from the forum also.
  • Check that the username doesn't exist in the forum when someone tries to register (there are users on the forum that are not on infoarena, because of the import from info.devnet.ro i guess). Having two smf users with the same name crashes things.
  • Allow rounds to have no tasks.

Reviewed: http://reviewboard.infoarena.ro/r/126/

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1#! /usr/bin/env php
2<?php
3
4require_once(dirname($argv[0]) . "/utilities.php");
5require_once(IA_ROOT_DIR.'www/utilities.php');
6require_once(IA_ROOT_DIR.'common/db/db.php');
7
8test_cleanup();
9test_prepare();
10
11log_print("WARNING: This test requires the evaluator.");
12
13log_print("Helper1 looks at new round page, works");
14$res = curl_test(array(
15        'url' => url_round_create(),
16        'user' => 'test_helper1',
17));
18log_assert_equal($res['url'], url_absolute(url_round_create()));
19
20
21log_print("Helper1 tries to create a new round, works");
22$res = curl_test(array(
23        'url' => url_round_create(),
24        'user' => 'test_helper1',
25        'post' => array(
26          'id' => 'tEst_Round',
27          'type' => 'user-defined',
28)));
29log_assert_equal($res['url'], url_absolute(url_round_edit('test_round')));
30
31
32log_print("Helper1 tries to create a new round, fails");
33$res = curl_test(array(
34        'url' => url_round_create(),
35        'user' => 'test_helper1',
36        'post' => array(
37          'id' => 'tEst_Round',
38          'type' => 'classic',
39)));
40log_assert_equal($res['url'], url_absolute(url_round_create()));
41
42
43log_print("Helper2 looks at round page, and it's there");
44$res = curl_test(array(
45        'url' => url_textblock('runda/tEst_Round'),
46        'user' => 'test_helper2',
47));
48log_assert_equal($res['url'], url_absolute(url_textblock('runda/tEst_Round')));
49
50
51log_print("Admin looks at new round page, ok");
52$res = curl_test(array(
53        'url' => url_round_create(),
54        'user' => 'test_admin',
55));
56log_assert_equal($res['url'], url_absolute(url_round_create()));
57
58
59log_print("Admin creates round, already exists.");
60$res = curl_test(array(
61        'url' => url_round_create(),
62        'user' => 'test_admin',
63        'post' => array(
64                'id' => 'tEst_Round',
65)));
66log_assert_equal($res['url'], url_absolute(url_round_create()));
67log_assert(strstr($res['content'], 'test_round'));
68
69log_print("Admin changes round to classic.");
70$res = curl_test(array(
71        'url' => url_round_edit('tEst_Round'),
72        'user' => 'test_admin',
73        'post' => array(
74            'type' => 'classic',
75            'rating_update' => true,
76            'start_time' => db_date_format(time() + 3600),
77)));
78log_assert(!strstr($res['content'], '<span class="fieldError"'));
79log_assert(strstr($res['content'], '<option value="classic" selected="selected">Concurs clasic'));
80log_assert_equal($res['url'], url_absolute(url_round_edit('test_round')));
81
82log_print("Admin adds tasks adunare and cmmdc to round.");
83$res = curl_test(array(
84        'url' => url_round_edit('tEst_Round'),
85        'user' => 'test_admin',
86        'post' => array(
87                'title' => 'xzx-round-title-xzx',
88                'tasks' => array('adunare', 'cmmdc'),
89)));
90log_assert_equal($res['url'], url_absolute(url_round_edit('test_round')));
91log_assert(!strstr($res['content'], '<span class="fieldError"'));
92log_assert(strstr($res['content'], 'xzx-round-title-xzx'));
93
94
95log_print("Admin looks at round page, sees links to tasks");
96$res = curl_test(array(
97        'url' => url_textblock("runda/tEst_Round"),
98        'user' => 'test_admin',
99));
100log_assert_equal($res['url'], url_absolute(url_textblock('runda/tEst_Round')));
101log_assert(strstr($res['content'], 'xzx-round-title-xzx'));
102log_assert(strstr($res['content'], '<a href="'.
103            url_textblock('problema/adunare')));
104log_assert(strstr($res['content'], '<a href="'.
105            url_textblock('problema/cmmdc')));
106
107
108log_print("Admin removes task adunare, adds flip and biti.");
109$res = curl_test(array(
110        'url' => url_round_edit('tEst_Round'),
111        'user' => 'test_admin',
112        'post' => array(
113                'tasks' => array('cmmdc', 'flip', 'biti'),
114)));
115log_assert_equal($res['url'], url_absolute(url_round_edit('test_round')));
116log_assert(!strstr($res['content'], '<span class="fieldError"'));
117log_assert(strstr($res['content'], 'xzx-round-title-xzx'));
118
119
120log_print("Admin looks at round page again, adunare is gone");
121$res = curl_test(array(
122        'url' => url_textblock("runda/tEst_Round"),
123        'user' => 'test_admin',
124));
125log_assert_equal($res['url'], url_absolute(url_textblock('runda/tEst_Round')));
126log_assert(strstr($res['content'], 'xzx-round-title-xzx'));
127log_assert(!strstr($res['content'], '<a href="'.
128            url_textblock('problema/adunare')));
129log_assert(strstr($res['content'], '<a href="'.
130            url_textblock('problema/cmmdc')));
131log_assert(strstr($res['content'], '<a href="'.
132            url_textblock('problema/flip')));
133log_assert(strstr($res['content'], '<a href="'.
134            url_textblock('problema/biti')));
135
136
137log_print("Anon looks at round page, sees that round hasn't started");
138$res = curl_test(array(
139        'url' => url_textblock("runda/tEst_Round"),
140));
141log_assert_equal($res['url'], url_absolute(url_textblock('runda/tEst_Round')));
142log_assert(strstr($res['content'], 'xzx-round-title-xzx'));
143log_assert(strstr($res['content'], 'Nu esti inscris la'));
144log_assert(!strstr($res['content'], '<a href="'.
145            url_textblock('problema/cmmdc')));
146log_assert(!strstr($res['content'], '<a href="'.
147            url_textblock('problema/flip')));
148log_assert(!strstr($res['content'], '<a href="'.
149            url_textblock('problema/biti')));
150
151
152log_print("Admin makes round an archive starting 3 seconds in the future");
153$start_date = db_date_format(time() + 3);
154$res = curl_test(array(
155        'url' => url_round_edit('tEst_Round'),
156        'user' => 'test_admin',
157        'post' => array(
158                'type' => 'archive',
159                'start_time' => $start_date,
160                'tasks' => array('cmmdc', 'flip', 'biti'),
161        ),
162));
163log_assert_equal($res['url'], url_absolute(url_round_edit('test_round')));
164log_assert(!strstr($res['content'], '<span class="fieldError"'));
165log_assert(strstr($res['content'], 'xzx-round-title-xzx'));
166log_assert(strstr($res['content'], $start_date));
167
168
169log_print("Admin looks at round page, round still not started");
170$res = curl_test(array(
171        'url' => url_textblock("runda/tEst_Round"),
172        'user' => 'test_admin',
173));
174log_assert_equal($res['url'], url_absolute(url_textblock('runda/tEst_Round')));
175log_assert(strstr($res['content'], 'xzx-round-title-xzx'));
176log_assert(strstr($res['content'], 'Nu esti inscris la'));
177log_assert(!strstr($res['content'], 'Nu se mai pot face inscrieri'));
178log_assert(!strstr($res['content'], 'Runda s-a incheiat'));
179log_assert(strstr($res['content'], '<a href="'.
180            url_textblock('problema/cmmdc')));
181log_assert(strstr($res['content'], '<a href="'.
182            url_textblock('problema/flip')));
183log_assert(strstr($res['content'], '<a href="'.
184            url_textblock('problema/biti')));
185
186
187// Yuck
188$wait = 4;
189if (IA_MEM_CACHE_METHOD != "none") {
190    $wait += IA_MEM_CACHE_ROUND_EXPIRATION;
191}
192log_print("Waiting for $wait seconds...");
193usleep($wait * 1000000);
194
195log_print("Anon looks at round page, sees that round started");
196$res = curl_test(array(
197        'url' => url_textblock("runda/tEst_Round"),
198));
199log_assert_equal($res['url'], url_absolute(url_textblock('runda/tEst_Round')));
200log_assert(strstr($res['content'], 'xzx-round-title-xzx'));
201log_assert(!strstr($res['content'], 'Nu esti inscris la'),
202    "Round still waiting, is the evaluator ON?");
203log_assert(strstr($res['content'], 'Nu se mai pot face inscrieri'));
204log_assert(!strstr($res['content'], 'Runda s-a incheiat'));
205log_assert(strstr($res['content'], '<a href="'.
206            url_textblock('problema/cmmdc')));
207log_assert(strstr($res['content'], '<a href="'.
208            url_textblock('problema/flip')));
209log_assert(strstr($res['content'], '<a href="'.
210            url_textblock('problema/biti')));
211
212
213log_print("Basic round passed");
214test_cleanup();
215
216
217?>
Note: See TracBrowser for help on using the repository browser.