Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
ElasticsearchEntitySearcher example
}
protected
function
createEntitySearcher
(
)
: ElasticsearchEntitySearcher
{
$decorated
=
$this
->
createMock
(
EntitySearcher::
class
)
;
$decorated
->
expects
(
static
::
never
(
)
)
->
method
(
'search'
)
;
return
new
ElasticsearchEntitySearcher
(
$this
->
getDiContainer
(
)
->
get
(
Client::
class
)
,
$decorated
,
$this
->
getDiContainer
(
)
->
get
(
ElasticsearchHelper::
class
)
,
$this
->
getDiContainer
(
)
->
get
(
CriteriaParser::
class
)
,
$this
->
getDiContainer
(
)
->
get
(
AbstractElasticsearchSearchHydrator::
class
)
,
$this
->
getDiContainer
(
)
->
get
(
'event_dispatcher'
)
)
;
}
abstract
protected
function
getDiContainer
(
)
: ContainerInterface;
$client
=
$this
->
createMock
(
Client::
class
)
;
// client should not be used if limit is 0
$client
->
expects
(
static
::
never
(
)
)
->
method
(
'search'
)
;
$helper
=
$this
->
createMock
(
ElasticsearchHelper::
class
)
;
$helper
->
method
(
'allowSearch'
)
->
willReturn
(
true
)
;
$searcher
=
new
ElasticsearchEntitySearcher
(
$client
,
$this
->
createMock
(
EntitySearcherInterface::
class
)
,
$helper
,
$this
->
createMock
(
CriteriaParser::
class
)
,
$this
->
createMock
(
AbstractElasticsearchSearchHydrator::
class
)
,
new
EventDispatcher
(
)
,
)
;
$context
= Context::
createDefaultContext
(
)
;
$criteria
->
addState
(
Criteria::STATE_ELASTICSEARCH_AWARE
)
;