From 002d949f6c9a03e35113ad9ba78f429e3d71f714 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Sat, 16 Nov 2013 19:55:19 +0100 Subject: [PATCH] Replace delete method --- features/bootstrap/GuiContext.php | 2 +- lib/Alchemy/Phrasea/Helper/User/Edit.php | 2 +- .../Authentication/AccountCreatorTest.php | 13 ++++++----- .../Controller/Admin/AdminDashboardTest.php | 3 +-- .../Phrasea/Controller/Admin/UsersTest.php | 23 +++++++++---------- .../Phrasea/Controller/Root/LoginTest.php | 9 ++++---- ...thenticationManagerServiceProviderTest.php | 4 ++-- .../Model/Manipulator/ACLManipulatorTest.php | 2 +- tests/classes/ACLTest.php | 12 +++++----- tests/classes/userTest.php | 4 ++-- 10 files changed, 36 insertions(+), 38 deletions(-) diff --git a/features/bootstrap/GuiContext.php b/features/bootstrap/GuiContext.php index d765709927..1278b83a0c 100644 --- a/features/bootstrap/GuiContext.php +++ b/features/bootstrap/GuiContext.php @@ -71,7 +71,7 @@ class GuiContext extends MinkContext $this->app['authentication']->getUser()->ACL()->get_granted_base(array('canadmin')) )); - $user->delete(); + $this->app['model.user-manager']->delete($user); } } diff --git a/lib/Alchemy/Phrasea/Helper/User/Edit.php b/lib/Alchemy/Phrasea/Helper/User/Edit.php index b9be6b1b53..8671cfdffd 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/User/Edit.php @@ -78,7 +78,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $this->app['acl']->get($user)->revoke_access_from_bases($list); if ($this->app['acl']->get($user)->is_phantom()) { - $user->delete(); + $this->app['model.user-manager']->delete($user); } return $this; diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/AccountCreatorTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/AccountCreatorTest.php index c3b308fc92..1de2b94761 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/AccountCreatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/AccountCreatorTest.php @@ -57,7 +57,8 @@ class AccountCreatorTest extends \PhraseanetTestCase $user = $creator->create(self::$DI['app'], self::$DI['app']['tokens']->generatePassword()); $this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\User', $user); - $user->delete(); + + self::$DI['app']['model.user-manager']->delete($user); } public function testCreateWithTemplates() @@ -77,10 +78,10 @@ class AccountCreatorTest extends \PhraseanetTestCase $user = $creator->create(self::$DI['app'], self::$DI['app']['tokens']->generatePassword(), null, $extra); $this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\User', $user); - $user->delete(); - $template1->delete(); - $template2->delete(); - $template3->delete(); + self::$DI['app']['model.user-manager']->delete($user); + self::$DI['app']['model.user-manager']->delete($template1); + self::$DI['app']['model.user-manager']->delete($template2); + self::$DI['app']['model.user-manager']->delete($template3); } public function testCreateWithAlreadyExistingLogin() @@ -90,6 +91,6 @@ class AccountCreatorTest extends \PhraseanetTestCase $this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\User', $user); $this->assertNotEquals(self::$DI['user']->getLogin(), $user->getLogin()); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminDashboardTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminDashboardTest.php index 947aa37222..14bbbf2d7d 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminDashboardTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminDashboardTest.php @@ -123,7 +123,6 @@ class AdminDashboardTest extends \PhraseanetAuthenticatedWebTestCase ]); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); - - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php index 53fe688a61..0832feec70 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php @@ -69,7 +69,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase $this->assertTrue(self::$DI['app']['acl']->get($user)->has_right_on_base($base_id, "manage")); $this->assertTrue(self::$DI['app']['acl']->get($user)->has_right_on_base($base_id, "canpush")); $this->assertTrue(self::$DI['app']['acl']->get($user)->has_right_on_base($base_id, "canreport")); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } public function testRouteRightsApplyException() @@ -87,7 +87,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase $datas = json_decode($response->getContent()); $this->assertTrue(is_object($datas)); $this->assertTrue($datas->error); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } public function testRouteQuota() @@ -155,7 +155,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase self::$DI['client']->request('POST', '/admin/users/rights/time/apply/', array('base_id' => $base_id, 'dmin' => $dmin, 'dmax' => $dmax, 'limit' => 1, 'users' => $user->getId())); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOK()); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } public function testRouteRightTimeApplySbas() @@ -170,7 +170,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase self::$DI['client']->request('POST', '/admin/users/rights/time/apply/', array('sbas_id' => $sbas_id, 'dmin' => $dmin, 'dmax' => $dmax, 'limit' => 1, 'users' => $user->getId())); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOK()); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } public function testRouteRightTimeApplyWithtoutBasOrSbas() @@ -184,7 +184,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase self::$DI['client']->request('POST', '/admin/users/rights/time/apply/', array('dmin' => $dmin, 'dmax' => $dmax, 'limit' => 1, 'users' => $user->getId())); $response = self::$DI['client']->getResponse(); $this->assertEquals(400, $response->getStatusCode()); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } public function testRouteRightMask() @@ -208,7 +208,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase )); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOK()); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } public function testRouteSearch() @@ -249,9 +249,8 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isRedirect()); - - $template->delete(); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($template); + self::$DI['app']['model.user-manager']->delete($user); } public function testRouteCreateException() @@ -295,7 +294,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase $this->assertFalse($datas->error); $this->assertNotNull($user = (self::$DI['app']['manipulator.user']->getRepository((int) $datas->data))); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } public function testRouteCreateUserAndSendCredentials() @@ -318,7 +317,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase $this->assertFalse($datas->error); $this->assertNotNull($user = (self::$DI['app']['manipulator.user']->getRepository((int) $datas->data))); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } public function testRouteExportCsv() @@ -372,7 +371,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase $this->assertTrue(is_object($datas)); $this->assertFalse($datas->error); $this->assertFalse(self::$DI['app']['acl']->get($user)->has_access_to_base($base_id)); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } public function testRenderDemands() diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php index e17f30b3b2..5df82af825 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php @@ -244,7 +244,7 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase $this->assertFlashMessagePopulated(self::$DI['app'], 'info', 1); $this->assertEquals('/login/', $response->headers->get('location')); $this->assertFalse(self::$DI['user']->isMailLocked()); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } /** @@ -1017,7 +1017,7 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase ->findBy(array('usr_id' => $user->getId(), 'provider' => 'provider-test')); $this->assertCount(1, $ret); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); $this->assertGreaterThan(0, $emails['Alchemy\Phrasea\Notification\Mail\MailInfoUserRegistered']); $this->assertEquals(1, $emails['Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation']); @@ -1066,7 +1066,7 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase $this->fail('User not created'); } - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); $this->assertGreaterThan(0, $emails['Alchemy\Phrasea\Notification\Mail\MailInfoUserRegistered']); $this->assertEquals(1, $emails['Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation']); @@ -1595,8 +1595,7 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase $this->assertSame('/prod/', self::$DI['client']->getResponse()->headers->get('location')); $this->assertTrue(self::$DI['app']['authentication']->isAuthenticated()); - - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } public function testAuthenticateProviderCallbackWithRegistrationEnabled() diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php index f90573738e..fd3d6b89f2 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php @@ -164,7 +164,7 @@ class AuthenticationManagerServiceProviderTest extends ServiceProviderTestCase $this->assertEquals(array($template1, $template2), $app['authentication.providers.account-creator']->getTemplates()); - $template1->delete(); - $template2->delete(); + self::$DI['app']['model.user-manager']->delete($template1); + self::$DI['app']['model.user-manager']->delete($template2); } } diff --git a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ACLManipulatorTest.php b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ACLManipulatorTest.php index 18e4789d16..c85be00957 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ACLManipulatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/ACLManipulatorTest.php @@ -86,6 +86,6 @@ class ACLManipulatorTest extends \PhraseanetTestCase $this->assertEquals(0, $acl->get_limits($acl->get_mask_xor($baseId))); $this->assertEquals(0, $acl->get_limits($acl->get_mask_and($baseId))); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } } diff --git a/tests/classes/ACLTest.php b/tests/classes/ACLTest.php index 85ebec8c49..ffeffd1cae 100644 --- a/tests/classes/ACLTest.php +++ b/tests/classes/ACLTest.php @@ -13,11 +13,11 @@ class ACLTest extends \PhraseanetAuthenticatedTestCase { $application = new Application('test'); if (null !== $template = self::$DI['app']['manipulator.user']->findByLogin('test_phpunit2')) { - $template->delete(); + self::$DI['app']['model.user-manager']->delete($template); } if (null !== $template = self::$DI['app']['manipulator.user']->findByLogin('test_phpunit3')) { - $template->delete(); + self::$DI['app']['model.user-manager']->delete($template); } if (null !== $template = self::$DI['app']['manipulator.user']->findByLogin('test_phpunit3')) { @@ -105,8 +105,8 @@ class ACLTest extends \PhraseanetAuthenticatedTestCase $this->assertNull(self::$DI['app']['acl']->get($cobaye)->get_limits($base_id)); } - $template->delete(); - $cobaye->delete(); + self::$DI['app']['model.user-manager']->delete($template); + self::$DI['app']['model.user-manager']->delete($cobaye); } public function testApply_model_with_time_limit() @@ -143,8 +143,8 @@ class ACLTest extends \PhraseanetAuthenticatedTestCase $this->assertEquals(array('dmin' => $limit_from, 'dmax' => $limit_to), self::$DI['app']['acl']->get($cobaye)->get_limits($base_id)); } - $template->delete(); - $cobaye->delete(); + self::$DI['app']['model.user-manager']->delete($template); + self::$DI['app']['model.user-manager']->delete($cobaye); } public function testRevoke_access_from_bases() diff --git a/tests/classes/userTest.php b/tests/classes/userTest.php index 08e0ba67f0..04b17e7462 100644 --- a/tests/classes/userTest.php +++ b/tests/classes/userTest.php @@ -40,7 +40,7 @@ class userTest extends \PhraseanetTestCase self::$DI['app']['EM']->persist($provider); self::$DI['app']['EM']->flush(); - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); $repo = self::$DI['app']['EM']->getRepository('Phraseanet:UsrAuthProvider'); $this->assertNull($repo->findWithProviderAndId('custom-one', 12345)); @@ -134,7 +134,7 @@ class userTest extends \PhraseanetTestCase private function get_user() { if (null !== $user = self::$DI['app']['manipulator.user']->getRepository()->findByLogin('notif_ref_test')) { - $user->delete(); + self::$DI['app']['model.user-manager']->delete($user); } return self::$DI['app']['manipulator.user']->create('notif_ref_test', mt_rand(), null, false);