|
2 | 2 |
|
3 | 3 | namespace App\Tests\Unit\Controller\Team;
|
4 | 4 |
|
| 5 | +use App\DataFixtures\Test\DemoAboutToStartContestFixture; |
| 6 | +use App\Entity\Contest; |
| 7 | +use App\Entity\ContestProblem; |
5 | 8 | use App\Entity\Problem;
|
6 | 9 | use App\Entity\Testcase;
|
7 | 10 | use App\Tests\Unit\BaseTestCase;
|
@@ -183,4 +186,43 @@ public function testInteractiveSamples(): void
|
183 | 186 | $response = $this->client->getResponse();
|
184 | 187 | self::assertEquals(404, $response->getStatusCode());
|
185 | 188 | }
|
| 189 | + |
| 190 | + /** |
| 191 | + * Test that the problems page does not show page, statement, sample data before contest start. |
| 192 | + */ |
| 193 | + public function testAccessProblemBeforeContestStarts(): void |
| 194 | + { |
| 195 | + $this->loadFixtures([DemoAboutToStartContestFixture::class]); |
| 196 | + |
| 197 | + /** @var EntityManagerInterface $em */ |
| 198 | + $em = self::getContainer()->get(EntityManagerInterface::class); |
| 199 | + $problems = $em->createQueryBuilder() |
| 200 | + ->select('p.probid') |
| 201 | + ->from(ContestProblem::class, 'cp') |
| 202 | + ->join('cp.problem', 'p') |
| 203 | + ->join('cp.contest', 'c') |
| 204 | + ->where('c.shortname = :shortname') |
| 205 | + ->setParameter('shortname', 'demo') |
| 206 | + ->getQuery() |
| 207 | + ->getResult(); |
| 208 | + $probids = array_column($problems, 'probid'); |
| 209 | + |
| 210 | + $this->client->request('GET', '/public/problems'); |
| 211 | + static::assertSelectorTextContains('.nav-item .nav-link.disabled', 'Problems'); |
| 212 | + static::assertSelectorTextContains('.alert.alert-secondary', 'No problem texts available at this point.'); |
| 213 | + |
| 214 | + foreach ($probids as $id) { |
| 215 | + $endpoints = [ |
| 216 | + "/team/problems/{$id}", |
| 217 | + "/team/problems/{$id}/statement", |
| 218 | + "/team/problems/{$id}/samples.zip" |
| 219 | + ]; |
| 220 | + |
| 221 | + foreach ($endpoints as $endpoint) { |
| 222 | + $this->client->request('GET', $endpoint); |
| 223 | + $statusCode = $this->client->getResponse()->getStatusCode(); |
| 224 | + static::assertSame(404, $statusCode, "Expected status code 404, got {$statusCode} for {$endpoint}"); |
| 225 | + } |
| 226 | + } |
| 227 | + } |
186 | 228 | }
|
0 commit comments