Esempio n. 1
0
 /**
  * @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));
 }
Esempio n. 3
0
 /**
  * @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);
 }
 protected function getDefaultOptions()
 {
     $appbox = self::$DI['app']['phraseanet.appbox'];
     foreach ($appbox->get_databoxes() as $databox) {
         break;
     }
     $options = new SearchEngineOptions();
     $options->onCollections($databox->get_collections());
     return $options;
 }
Esempio n. 5
0
 /**
  * @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);
 }
Esempio n. 6
0
 /**
  * @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);
 }