diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Api/ApiTestCase.php b/tests/Alchemy/Tests/Phrasea/Controller/Api/ApiTestCase.php index cfecfd4e49..5f498c40ed 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Api/ApiTestCase.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Api/ApiTestCase.php @@ -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(); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/QueryTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/QueryTest.php index e11b2022d1..a89a2a2877 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/QueryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/QueryTest.php @@ -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); diff --git a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/UserManipulatorTest.php b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/UserManipulatorTest.php index f01d9b48e4..b7b7a93260 100644 --- a/tests/Alchemy/Tests/Phrasea/Model/Manipulator/UserManipulatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Model/Manipulator/UserManipulatorTest.php @@ -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.'