. */ declare(strict_types=1); namespace App\Tests\Controller; use App\Entity\UserSystem\User; use PHPUnit\Framework\Attributes\Group; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; #[Group("slow")] #[Group("DB")] class BatchEdaControllerTest extends WebTestCase { private function loginAsUser($client, string $username): void { $entityManager = $client->getContainer()->get('doctrine')->getManager(); $userRepository = $entityManager->getRepository(User::class); $user = $userRepository->findOneBy(['name' => $username]); if (!$user) { $this->markTestSkipped("User {$username} not found"); } $client->loginUser($user); } public function testBatchEdaPageLoads(): void { $client = static::createClient(); $this->loginAsUser($client, 'admin'); // Request with part IDs in session — the page expects ids[] query param $client->request('GET', '/en/tools/batch_eda_edit', ['ids' => [1, 2, 3]]); self::assertResponseIsSuccessful(); } public function testBatchEdaPageWithoutPartsRedirects(): void { $client = static::createClient(); $this->loginAsUser($client, 'admin'); // Request without part IDs should redirect $client->request('GET', '/en/tools/batch_eda_edit'); self::assertResponseRedirects(); } public function testBatchEdaFormSubmission(): void { $client = static::createClient(); $this->loginAsUser($client, 'admin'); // Load the form page first $crawler = $client->request('GET', '/en/tools/batch_eda_edit', ['ids' => [1, 2]]); self::assertResponseIsSuccessful(); // Find the form and submit it with reference prefix applied $form = $crawler->selectButton('batch_eda[submit]')->form(); $form['batch_eda[apply_reference_prefix]'] = true; $form['batch_eda[reference_prefix]'] = 'R'; $client->submit($form); // Should redirect after successful submission self::assertResponseRedirects(); } }