replaced delete confirm dialog with modal (#638)
This commit is contained in:
@@ -9,7 +9,9 @@
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Entity\Timesheet;
|
||||
use App\Entity\User;
|
||||
use App\Tests\DataFixtures\TimesheetFixtures;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \App\Controller\UserController
|
||||
@@ -86,6 +88,60 @@ class UserControllerTest extends ControllerBaseTest
|
||||
$this->assertEquals(1, $form->get('user_create[create_more]')->getValue());
|
||||
}
|
||||
|
||||
public function testDeleteAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);
|
||||
|
||||
$this->request($client, '/admin/user/4/delete');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$form = $client->getCrawler()->filter('form[name=form]')->form();
|
||||
$this->assertStringEndsWith($this->createUrl('/admin/user/4/delete'), $form->getUri());
|
||||
$client->submit($form);
|
||||
|
||||
$client->followRedirect();
|
||||
$this->assertHasDataTable($client);
|
||||
$this->assertHasFlashSuccess($client);
|
||||
|
||||
$this->request($client, '/admin/user/4/edit');
|
||||
$this->assertFalse($client->getResponse()->isSuccessful());
|
||||
}
|
||||
|
||||
public function testDeleteActionWithTimesheetEntries()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);
|
||||
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$user = $this->getUserByRole($em, User::ROLE_USER);
|
||||
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture->setUser($user);
|
||||
$fixture->setAmount(10);
|
||||
$this->importFixture($em, $fixture);
|
||||
|
||||
$timesheets = $em->getRepository(Timesheet::class)->findAll();
|
||||
$this->assertEquals(10, count($timesheets));
|
||||
|
||||
$this->request($client, '/admin/user/' . $user->getId() . '/delete');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
$form = $client->getCrawler()->filter('form[name=form]')->form();
|
||||
$this->assertStringEndsWith($this->createUrl('/admin/user/' . $user->getId() . '/delete'), $form->getUri());
|
||||
$client->submit($form);
|
||||
|
||||
$this->assertIsRedirect($client, $this->createUrl('/admin/user/'));
|
||||
$client->followRedirect();
|
||||
$this->assertHasFlashDeleteSuccess($client);
|
||||
|
||||
// SQLIte does not necessarly support onCascade delete, so these timesheet will stay after deletion
|
||||
// $em->clear();
|
||||
// $timesheets = $em->getRepository(Timesheet::class)->findAll();
|
||||
// $this->assertEquals(0, count($timesheets));
|
||||
|
||||
$this->request($client, '/admin/user/' . $user->getId() . '/edit');
|
||||
$this->assertFalse($client->getResponse()->isSuccessful());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidationTestData
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user