mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Fix unit tests
This commit is contained in:
@@ -17,7 +17,7 @@ class UserManagerTest extends \PhraseanetTestCase
|
||||
self::$DI['app']['manipulator.user']->setUserSetting($user, 'setting', false);
|
||||
self::$DI['app']['manipulator.user']->setNotificationSetting($user, 'setting', false);
|
||||
self::$DI['app']['model.user-manager']->delete($user);
|
||||
$user = self::$DI['app']['manipulator.user']->getRepository()->findOneByLogin('login');
|
||||
$user = self::$DI['app']['repo.users']->findOneByLogin('login');
|
||||
$this->assertEquals(0, $user->getSettings()->count());
|
||||
$this->assertEquals(0, $user->getNotificationSettings()->count());
|
||||
$this->assertEquals(0, $user->getQueries()->count());
|
||||
|
@@ -55,7 +55,7 @@ class RegistrationManipulatorTest extends \PhraseanetTestCase
|
||||
public function testDeleteRegistrationForUser()
|
||||
{
|
||||
$service = new RegistrationManipulator(self::$DI['app'], self::$DI['app']['EM'], self::$DI['app']['acl'], self::$DI['app']['phraseanet.appbox'], self::$DI['app']['repo.registrations']);
|
||||
$qb = $service->getRepository()->createQueryBuilder('r');
|
||||
$qb = self::$DI['app']['repo.registrations']->createQueryBuilder('r');
|
||||
$nbRegistrationBefore = $qb->select('COUNT(r)')
|
||||
->where($qb->expr()->eq('r.user', ':user'))
|
||||
->setParameter(':user', self::$DI['user_alt1']->getId())
|
||||
@@ -69,7 +69,7 @@ class RegistrationManipulatorTest extends \PhraseanetTestCase
|
||||
public function testDeleteOldRegistrations()
|
||||
{
|
||||
$service = new RegistrationManipulator(self::$DI['app'], self::$DI['app']['EM'], self::$DI['app']['acl'], self::$DI['app']['phraseanet.appbox'], self::$DI['app']['repo.registrations']);
|
||||
$qb = $service->getRepository()->createQueryBuilder('r');
|
||||
$qb = self::$DI['app']['repo.registrations']->createQueryBuilder('r');
|
||||
$nbRegistrationBefore = $qb->select('COUNT(r)')->getQuery()->getSingleScalarResult();
|
||||
$service->deleteOldRegistrations();
|
||||
$nbRegistrationAfter = $qb->getQuery()->getSingleScalarResult();
|
||||
@@ -79,7 +79,7 @@ class RegistrationManipulatorTest extends \PhraseanetTestCase
|
||||
public function testDeleteRegistrationOnCollection()
|
||||
{
|
||||
$service = new RegistrationManipulator(self::$DI['app'], self::$DI['app']['EM'], self::$DI['app']['acl'], self::$DI['app']['phraseanet.appbox'], self::$DI['app']['repo.registrations']);
|
||||
$qb = $service->getRepository()->createQueryBuilder('r');
|
||||
$qb = self::$DI['app']['repo.registrations']->createQueryBuilder('r');
|
||||
$nbRegistrationBefore = $qb->select('COUNT(r)')->getQuery()->getSingleScalarResult();
|
||||
$service->deleteRegistrationsOnCollection(self::$DI['collection']);
|
||||
$nbRegistrationAfter = $qb->getQuery()->getSingleScalarResult();
|
||||
|
@@ -104,12 +104,6 @@ class TaskManipulatorTest extends \PhraseanetTestCase
|
||||
$this->assertEquals(0, $task->getCrashed());
|
||||
}
|
||||
|
||||
public function testGetRepository()
|
||||
{
|
||||
$manipulator = new TaskManipulator(self::$DI['app']['EM'], $this->createNotifierMock(), self::$DI['app']['translator'], self::$DI['app']['repo.tasks']);
|
||||
$this->assertSame(self::$DI['app']['EM']->getRepository('Phraseanet:Task'), $manipulator->getRepository());
|
||||
}
|
||||
|
||||
public function testCreateEmptyCollection()
|
||||
{
|
||||
$collection = $this->getMockBuilder('collection')
|
||||
|
@@ -11,7 +11,7 @@ class UserManipulatorTest extends \PhraseanetTestCase
|
||||
public function testCreateUser()
|
||||
{
|
||||
$user = self::$DI['app']['manipulator.user']->createUser('login', 'pass');
|
||||
$this->assertInstanceOf('\Alchemy\Phrasea\Model\Entities\User', self::$DI['app']['manipulator.user']->getRepository()->findOneByLogin('login'));
|
||||
$this->assertInstanceOf('\Alchemy\Phrasea\Model\Entities\User', self::$DI['app']['repo.users']->findOneByLogin('login'));
|
||||
}
|
||||
|
||||
public function testDeleteUser()
|
||||
@@ -25,7 +25,7 @@ class UserManipulatorTest extends \PhraseanetTestCase
|
||||
public function testCreateAdminUser()
|
||||
{
|
||||
$user = self::$DI['app']['manipulator.user']->createUser('login', 'pass', 'admin@admin.com', true);
|
||||
$user = self::$DI['app']['manipulator.user']->getRepository()->findOneByLogin('login');
|
||||
$user = self::$DI['app']['repo.users']->findOneByLogin('login');
|
||||
$this->assertTrue($user->isAdmin());
|
||||
$this->assertNotNull($user->getEmail());
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class UserManipulatorTest extends \PhraseanetTestCase
|
||||
{
|
||||
$user = self::$DI['app']['manipulator.user']->createUser('login', 'pass');
|
||||
$template = self::$DI['app']['manipulator.user']->createTemplate('test', $user);
|
||||
$user = self::$DI['app']['manipulator.user']->getRepository()->findOneByLogin('test');
|
||||
$user = self::$DI['app']['repo.users']->findOneByLogin('test');
|
||||
$this->assertTrue($user->isTemplate());
|
||||
}
|
||||
|
||||
@@ -87,9 +87,9 @@ class UserManipulatorTest extends \PhraseanetTestCase
|
||||
$user2 = self::$DI['app']['manipulator.user']->createUser('login2', 'toto');
|
||||
$this->assertFalse($user2->isAdmin());
|
||||
self::$DI['app']['manipulator.user']->promote([$user, $user2]);
|
||||
$user = self::$DI['app']['manipulator.user']->getRepository()->findOneByLogin('login');
|
||||
$user = self::$DI['app']['repo.users']->findOneByLogin('login');
|
||||
$this->assertTrue($user->isAdmin());
|
||||
$user2 = self::$DI['app']['manipulator.user']->getRepository()->findOneByLogin('login');
|
||||
$user2 = self::$DI['app']['repo.users']->findOneByLogin('login');
|
||||
$this->assertTrue($user2->isAdmin());
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ class UserManipulatorTest extends \PhraseanetTestCase
|
||||
$user = self::$DI['app']['manipulator.user']->createUser('login', 'toto', null, true);
|
||||
$this->assertTrue($user->isAdmin());
|
||||
self::$DI['app']['manipulator.user']->demote($user);
|
||||
$user = self::$DI['app']['manipulator.user']->getRepository()->findOneByLogin('login');
|
||||
$user = self::$DI['app']['repo.users']->findOneByLogin('login');
|
||||
$this->assertFalse($user->isAdmin());
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ class UserManipulatorTest extends \PhraseanetTestCase
|
||||
{
|
||||
$user = self::$DI['app']['manipulator.user']->createUser('login', 'password');
|
||||
self::$DI['app']['manipulator.user']->setUserSetting($user, 'name' ,'value');
|
||||
$user = self::$DI['app']['manipulator.user']->getRepository()->findOneByLogin('login');
|
||||
$user = self::$DI['app']['repo.users']->findOneByLogin('login');
|
||||
$this->assertCount(1, $user->getSettings());
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ class UserManipulatorTest extends \PhraseanetTestCase
|
||||
{
|
||||
$user = self::$DI['app']['manipulator.user']->createUser('login', 'password');
|
||||
self::$DI['app']['manipulator.user']->setNotificationSetting($user, 'name', 'value');
|
||||
$user = self::$DI['app']['manipulator.user']->getRepository()->findOneByLogin('login');
|
||||
$user = self::$DI['app']['repo.users']->findOneByLogin('login');
|
||||
$this->assertCount(1, $user->getNotificationSettings());
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ class UserManipulatorTest extends \PhraseanetTestCase
|
||||
{
|
||||
$user = self::$DI['app']['manipulator.user']->createUser('login', 'password');
|
||||
self::$DI['app']['manipulator.user']->logQuery($user, 'query');
|
||||
$user = self::$DI['app']['manipulator.user']->getRepository()->findOneByLogin('login');
|
||||
$user = self::$DI['app']['repo.users']->findOneByLogin('login');
|
||||
$this->assertCount(1, $user->getQueries());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user