-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
191 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20240410075332 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Add deleted_at and deleted_by_id on suivi'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE suivi ADD deleted_by_id INT DEFAULT NULL, ADD deleted_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\''); | ||
$this->addSql('ALTER TABLE suivi ADD CONSTRAINT FK_2EBCCA8FC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)'); | ||
$this->addSql('CREATE INDEX IDX_2EBCCA8FC76F1F52 ON suivi (deleted_by_id)'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE suivi DROP FOREIGN KEY FK_2EBCCA8FC76F1F52'); | ||
$this->addSql('DROP INDEX IDX_2EBCCA8FC76F1F52 ON suivi'); | ||
$this->addSql('ALTER TABLE suivi DROP deleted_by_id, DROP deleted_at'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
tests/Functional/Controller/Back/SignalementActionControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace App\Tests\Functional\Controller\Back; | ||
|
||
use App\Entity\Suivi; | ||
use App\Repository\SignalementRepository; | ||
use App\Repository\SuiviRepository; | ||
use App\Repository\UserRepository; | ||
use App\Tests\SessionHelper; | ||
use Symfony\Bundle\FrameworkBundle\KernelBrowser; | ||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
use Symfony\Component\Routing\RouterInterface; | ||
|
||
class SignalementActionControllerTest extends WebTestCase | ||
{ | ||
use SessionHelper; | ||
|
||
private ?KernelBrowser $client = null; | ||
private UserRepository $userRepository; | ||
private SignalementRepository $signalementRepository; | ||
private SuiviRepository $suiviRepository; | ||
private RouterInterface $router; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->client = static::createClient(); | ||
$this->router = self::getContainer()->get(RouterInterface::class); | ||
$this->userRepository = static::getContainer()->get(UserRepository::class); | ||
$this->suiviRepository = static::getContainer()->get(SuiviRepository::class); | ||
$this->signalementRepository = static::getContainer()->get(SignalementRepository::class); | ||
|
||
$user = $this->userRepository->findOneBy(['email' => 'admin-01@histologe.fr']); | ||
$this->client->loginUser($user); | ||
} | ||
|
||
public function testDeleteSuivi(): void | ||
{ | ||
$signalement = $this->signalementRepository->findOneBy(['uuid' => '00000000-0000-0000-2023-000000000006']); | ||
|
||
$route = $this->router->generate('back_signalement_delete_suivi', ['uuid' => $signalement->getUuid()]); | ||
$this->client->request('GET', $route); | ||
|
||
$description = 'Un petit message de rappel afin d\'y revenir plus tard'; | ||
$suivi = $this->suiviRepository->findOneBy(['description' => $description]); | ||
|
||
$this->client->request( | ||
'POST', | ||
$route, | ||
[ | ||
'suivi' => $suivi->getId(), | ||
'_token' => $this->generateCsrfToken($this->client, 'signalement_delete_suivi_'.$signalement->getId()), | ||
] | ||
); | ||
|
||
$suivi = $this->suiviRepository->findOneBy(['description' => $description]); | ||
$this->assertNotNull($suivi->getDeletedAt()); | ||
$this->assertNotNull($suivi->getDeletedBy()); | ||
$this->assertNotEquals($description, $suivi->getDescription()); | ||
$this->assertStringContainsString(Suivi::DESCRIPTION_DELETED, $suivi->getDescription()); | ||
$this->assertResponseRedirects('/bo/signalements/'.$signalement->getUuid().'#suivis'); | ||
} | ||
} |