Commit a37784cc authored by Laurent's avatar Laurent

hotline #101207 activities : fix deletion of an anonymous subscription

parent cb3241c9
Pipeline #8998 passed with stage
in 44 minutes and 29 seconds
- ticket #101207 : Activités : correction de la suppression d'une inscription anonyme
\ No newline at end of file
......@@ -46,10 +46,8 @@ class Admin_SessionActivityController extends ZendAfi_Controller_Action {
$session = Class_SessionActivity::getLoader()->find((int)$this->_getParam('id'));
if ($id_user_to_delete = $this->_getParam('delete')) {
$user_to_delete = Class_Users::getLoader()->find($id_user_to_delete);
$session
->removeStagiaire($user_to_delete)
->saveWithoutValidation();
$subscription_to_delete = Class_SessionActivityInscription::deleteBy(['stagiaire_id' => $id_user_to_delete,
'session_activity_id' => $session->getId()]);
$redirect_url = '/admin/session-activity/inscriptions/id/'.$session->getId();
if ($_GET)
......
......@@ -1593,12 +1593,13 @@ class Admin_ActivityControllerSessionMarsJavaDeletePatrickTest extends Admin_Act
public function setUp() {
parent::setUp();
$this->dispatch("/admin/session-activity/inscriptions/id/32/delete/5?dummmy=Zork");
Class_SessionActivity::clearCache();
}
/** @test */
public function patrickShouldNotAppearInStagiaires() {
$this->assertNotContains($this->_patrick, $this->_session_java_mars->getStagiaires());
$this->assertNotContains($this->_patrick, Class_SessionActivity::find(32)->getStagiaires());
}
......@@ -1611,6 +1612,29 @@ class Admin_ActivityControllerSessionMarsJavaDeletePatrickTest extends Admin_Act
class Admin_ActivityControllerSessionMarsJavaDeleteAnonymousTest extends Admin_ActivityControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch("/admin/session-activity/inscriptions/id/32/delete/999");
Class_SessionActivity::clearCache();
}
/** @test */
public function anonymousShouldHaveBeenDeleted() {
$this->assertEmpty(Class_SessionActivityInscription::find(999));
}
/** @test */
public function sessionJavaMarsShouldHaveTwoStagiaires() {
$this->assertEquals(2, Class_SessionActivity::find(32)->numberOfStagiaires());
}
}
class Admin_ActivityControllerSessionMarsJavaWithOtherUsersNotStagiairesDeletePatrickTest extends Admin_ActivityControllerTestCase {
protected $_nb_stagiaires_session_java_mars;
......@@ -1621,13 +1645,14 @@ class Admin_ActivityControllerSessionMarsJavaWithOtherUsersNotStagiairesDeletePa
$this->_patrick->setUserGroups([]);
$this->_nb_stagiaires_session_java_mars = count($this->_session_java_mars->getStagiaires());
$this->dispatch("/admin/session-activity/inscriptions/id/32/delete/5?dummmy=Zork");
Class_SessionActivity::clearCache();
}
/** @test */
public function sessionShouldHaveBeenSaved() {
$this->assertEquals($this->_nb_stagiaires_session_java_mars-1,
count($this->_session_java_mars->getStagiaires()));
count(Class_SessionActivity::find(32)->getStagiaires()));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment