/** * @dataProvider searchDataProvider * @param string $query * @param array $expectedResult * @param array $expectedIndexerCalls * @param array $expectSearchResultCalls * @param array $expectEntityRepositoryCalls * @param array $expectQueryBuilderCalls * @param array $expectExprCalls * @param array $expectQueryCalls */ public function testSearch($query, $expectedResult, $expectedIndexerCalls, $expectSearchResultCalls, $expectEntityRepositoryCalls, $expectQueryBuilderCalls, $expectExprCalls, $expectQueryCalls) { MockHelper::addMockExpectedCalls($this->indexer, $expectedIndexerCalls, $this); MockHelper::addMockExpectedCalls($this->searchResult, $expectSearchResultCalls, $this); MockHelper::addMockExpectedCalls($this->entityRepository, $expectEntityRepositoryCalls, $this); MockHelper::addMockExpectedCalls($this->queryBuilder, $expectQueryBuilderCalls, $this); MockHelper::addMockExpectedCalls($this->expr, $expectExprCalls, $this); MockHelper::addMockExpectedCalls($this->query, $expectQueryCalls, $this); $actualResult = $this->searchHandler->search($query['query'], $query['page'], $query['perPage']); $this->assertEquals($expectedResult, $actualResult); }
/** * @param string $search * @param int $firstResult * @param int $maxResults * * @return array */ protected function searchIds($search, $firstResult, $maxResults) { $ids = parent::searchIds($search, $firstResult, $maxResults); // Need to make additional query cause of Mysql Full-Text Search limitation and databases stop words. // http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_ft_min_word_len // http://dev.mysql.com/doc/refman/5.0/en/fulltext-stopwords.html // http://www.postgresql.org/docs/9.1/static/textsearch-dictionaries.html $object = $this->entityRepository->findOneBy(['name' => $search, 'organization' => $this->securityFacade->getOrganization()]); if ($object !== null) { $id = $object->getId(); if (!in_array($id, $ids, true)) { $ids[] = $id; } } return $ids; }
/** * {@inheritdoc} */ public function convertItem($item) { $result = parent::convertItem($item); $result['fullName'] = $this->getFullName($item); return $result; }
/** * {@inheritdoc} */ public function search($query, $page, $perPage, $searchById = false) { list($query, $targetEntity, $targetField) = explode(',', $query); $this->initForEntity($targetEntity, $targetField); return parent::search($query, $page, $perPage, $searchById); }
/** * @param string $entityName * @param array $properties * @param string $channelRelationName * @param string $channelSearchPropertyName */ public function __construct($entityName, array $properties, $channelRelationName = 'dataChannel', $channelSearchPropertyName = 'dataChannelId') { parent::__construct($entityName, $properties); $this->channelRelationName = $channelRelationName; $this->channelSearchPropertyName = $channelSearchPropertyName; }
/** * @param string $entityName * @param array $properties * @param FrontendProductListModifier $productListModifier */ public function __construct($entityName, array $properties, FrontendProductListModifier $productListModifier) { $this->productListModifier = $productListModifier; parent::__construct($entityName, $properties); }