mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 14:33:14 +00:00
Fixup some tests using UserManipulator
This commit is contained in:
@@ -839,7 +839,14 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
||||
public function testSearchRoute()
|
||||
{
|
||||
self::$DI['app']['manipulator.user'] = $this->getMockBuilder('Alchemy\Phrasea\Model\Manipulator\UserManipulator')
|
||||
->setConstructorArgs([self::$DI['app']['model.user-manager'], self::$DI['app']['auth.password-encoder'], self::$DI['app']['geonames.connector'], self::$DI['app']['repo.users'], self::$DI['app']['random.low']])
|
||||
->setConstructorArgs([
|
||||
self::$DI['app']['model.user-manager'],
|
||||
self::$DI['app']['auth.password-encoder'],
|
||||
self::$DI['app']['geonames.connector'],
|
||||
self::$DI['app']['repo.users'],
|
||||
self::$DI['app']['random.low'],
|
||||
self::$DI['app']['dispatcher'],
|
||||
])
|
||||
->setMethods(['logQuery'])
|
||||
->getMock();
|
||||
|
||||
|
@@ -21,16 +21,26 @@ class QueryTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
{
|
||||
$route = '/prod/query/';
|
||||
|
||||
self::$DI['app']['manipulator.user'] = $this->getMockBuilder('Alchemy\Phrasea\Model\Manipulator\UserManipulator')
|
||||
->setConstructorArgs([self::$DI['app']['model.user-manager'], self::$DI['app']['auth.password-encoder'], self::$DI['app']['geonames.connector'], self::$DI['app']['repo.users'], self::$DI['app']['random.low']])
|
||||
$userManipulator = $this->getMockBuilder('Alchemy\Phrasea\Model\Manipulator\UserManipulator')
|
||||
->setConstructorArgs([
|
||||
self::$DI['app']['model.user-manager'],
|
||||
self::$DI['app']['auth.password-encoder'],
|
||||
self::$DI['app']['geonames.connector'],
|
||||
self::$DI['app']['repo.users'],
|
||||
self::$DI['app']['random.low'],
|
||||
self::$DI['app']['dispatcher'],
|
||||
])
|
||||
->setMethods(['logQuery'])
|
||||
->getMock();
|
||||
|
||||
self::$DI['app']['manipulator.user']->expects($this->once())->method('logQuery');
|
||||
self::$DI['app']['manipulator.user'] = $userManipulator;
|
||||
|
||||
self::$DI['client']->request('POST', $route);
|
||||
$userManipulator->expects($this->once())->method('logQuery');
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$client = $this->getClient();
|
||||
$client->request('POST', $route);
|
||||
|
||||
$response = $client->getResponse();
|
||||
$this->assertEquals('application/json', $response->headers->get('Content-type'));
|
||||
$data = json_decode($response->getContent(), true);
|
||||
$this->assertInternalType('array', $data);
|
||||
@@ -48,12 +58,13 @@ class QueryTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$options->onCollections($app->getAclForUser($app->getAuthenticatedUser())->get_granted_base());
|
||||
$serializedOptions = $options->serialize();
|
||||
|
||||
self::$DI['client']->request('POST', '/prod/query/answer-train/', [
|
||||
$client = $this->getClient();
|
||||
$client->request('POST', '/prod/query/answer-train/', [
|
||||
'options_serial' => $serializedOptions,
|
||||
'pos' => 0,
|
||||
'query' => ''
|
||||
]);
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$response = $client->getResponse();
|
||||
$this->assertTrue($response->isOk());
|
||||
$datas = (array) json_decode($response->getContent());
|
||||
$this->assertArrayHasKey('current', $datas);
|
||||
|
@@ -84,7 +84,7 @@ class UserManipulatorTest extends \PhraseanetTestCase
|
||||
->getMock();
|
||||
|
||||
$user = self::$DI['app']['manipulator.user']->createUser('login', 'password');
|
||||
$manipulator = new UserManipulator($manager, $passwordInterface, $geonamesConnector, self::$DI['app']['repo.tasks'], self::$DI['app']['random.low']);
|
||||
$manipulator = new UserManipulator($manager, $passwordInterface, $geonamesConnector, self::$DI['app']['repo.tasks'], self::$DI['app']['random.low'], self::$DI['app']['dispatcher']);
|
||||
|
||||
$manipulator->setGeonameId($user, 4);
|
||||
$this->assertEquals(4, $user->getGeonameId());
|
||||
@@ -150,7 +150,7 @@ class UserManipulatorTest extends \PhraseanetTestCase
|
||||
$passwordInterface = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')
|
||||
->getMock();
|
||||
$user = self::$DI['app']['manipulator.user']->createUser('login', 'password');
|
||||
$manipulator = new UserManipulator($manager, $passwordInterface, $geonamesConnector, self::$DI['app']['repo.tasks'], self::$DI['app']['random.low']);
|
||||
$manipulator = new UserManipulator($manager, $passwordInterface, $geonamesConnector, self::$DI['app']['repo.tasks'], self::$DI['app']['random.low'], self::$DI['app']['dispatcher']);
|
||||
$this->setExpectedException(
|
||||
'Alchemy\Phrasea\Exception\InvalidArgumentException',
|
||||
'Invalid geonameid -1.'
|
||||
|
Reference in New Issue
Block a user