public function testRouteCaptionSearchEngine() { $route_base = '/prod/tooltip/caption/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/%s/'; $routes = [sprintf($route_base, 'answer'), sprintf($route_base, 'lazaret'), sprintf($route_base, 'preview'), sprintf($route_base, 'basket'), sprintf($route_base, 'overview')]; foreach ($routes as $route) { $option = new SearchEngineOptions(); $crawler = self::$DI['client']->request('POST', $route, ['options_serial' => $option->serialize()]); $this->assertTrue(self::$DI['client']->getResponse()->isOk()); } }
/** * @covers Alchemy\Phrasea\Controller\Prod\Query::queryAnswerTrain */ public function testQueryAnswerTrain() { $app = $this->mockElasticsearchResult(self::$DI['record_2']); $this->authenticate($app); $options = new SearchEngineOptions(); $options->onCollections($app->getAclForUser($app->getAuthenticatedUser())->get_granted_base()); $serializedOptions = $options->serialize(); $client = $this->getClient(); $client->request('POST', '/prod/query/answer-train/', ['options_serial' => $serializedOptions, 'pos' => 0, 'query' => '']); $response = $client->getResponse(); $this->assertTrue($response->isOk()); $datas = (array) json_decode($response->getContent()); $this->assertArrayHasKey('current', $datas); unset($response, $datas); }
/** * @covers Alchemy\Phrasea\SearchEngine\SearchEngineOptions */ public function testSerialize() { $options = new SearchEngineOptions(self::$DI['app']); $options->onCollections([self::$DI['collection']]); $options->allowBusinessFieldsOn([self::$DI['collection']]); foreach (self::$DI['collection']->get_databox()->get_meta_structure() as $field) { $options->setFields([$field]); $options->setDateFields([$field]); break; } $min_date = new \DateTime('-5 days'); $max_date = new \DateTime('+5 days'); $options->setMinDate(\DateTime::createFromFormat(DATE_ATOM, $min_date->format(DATE_ATOM))); $options->setMaxDate(\DateTime::createFromFormat(DATE_ATOM, $max_date->format(DATE_ATOM))); $serialized = $options->serialize(); $this->assertEquals($options, SearchEngineOptions::hydrate(self::$DI['app'], $serialized)); }
/** * @covers Alchemy\Phrasea\Controller\Prod\Query::queryAnswerTrain */ public function testQueryAnswerTrain() { if (!extension_loaded('phrasea2')) { $this->markTestSkipped('Phrasea2 is required for this test'); } $this->authenticate(self::$DI['app']); self::$DI['record_2']; $options = new SearchEngineOptions(); $options->onCollections(self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser())->get_granted_base()); $serializedOptions = $options->serialize(); self::$DI['client']->request('POST', '/prod/query/answer-train/', ['options_serial' => $serializedOptions, 'pos' => 0, 'query' => '']); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); $datas = (array) json_decode($response->getContent()); $this->assertArrayHasKey('current', $datas); unset($response, $datas); }
/** * @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord */ public function testGetRecordDetailResult() { if (!extension_loaded('phrasea2')) { $this->markTestSkipped('Phrasea2 is required for this test'); } $this->authenticate(self::$DI['app']); self::$DI['record_1']; $options = new SearchEngineOptions(); $acl = self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser()); $options->onCollections($acl->get_granted_base()); $serializedOptions = $options->serialize(); $this->XMLHTTPRequest('POST', '/prod/records/', ['env' => 'RESULT', 'options_serial' => $serializedOptions, 'pos' => 0, 'query' => '']); $response = self::$DI['client']->getResponse(); $data = json_decode($response->getContent(), true); $this->assertArrayHasKey('desc', $data); $this->assertArrayHasKey('html_preview', $data); $this->assertArrayHasKey('current', $data); $this->assertArrayHasKey('others', $data); $this->assertArrayHasKey('history', $data); $this->assertArrayHasKey('popularity', $data); $this->assertArrayHasKey('tools', $data); $this->assertArrayHasKey('pos', $data); $this->assertArrayHasKey('title', $data); unset($response, $data); }
/** * @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord */ public function testGetRecordDetailResult() { $app = $this->mockElasticsearchResult(self::$DI['record_1']); $this->authenticate($app); $options = new SearchEngineOptions(); $acl = $app->getAclForUser($app->getAuthenticatedUser()); $options->onCollections($acl->get_granted_base()); $serializedOptions = $options->serialize(); $this->XMLHTTPRequest('POST', '/prod/records/', ['env' => 'RESULT', 'options_serial' => $serializedOptions, 'pos' => 0, 'query' => '']); $response = self::$DI['client']->getResponse(); $data = json_decode($response->getContent(), true); $this->assertArrayHasKey('desc', $data); $this->assertArrayHasKey('html_preview', $data); $this->assertArrayHasKey('current', $data); $this->assertArrayHasKey('others', $data); $this->assertArrayHasKey('history', $data); $this->assertArrayHasKey('popularity', $data); $this->assertArrayHasKey('tools', $data); $this->assertArrayHasKey('pos', $data); $this->assertArrayHasKey('title', $data); unset($response, $data); }