Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
hasEqualsFilter example
class
ElasticsearchLanguageProviderTest
extends
TestCase
{
public
function
testGetLanguages
(
)
: void
{
$languageRepository
=
$this
->
createMock
(
EntityRepository::
class
)
;
$languageRepository
->
method
(
'search'
)
->
willReturnCallback
(
function
DCriteria
$criteria
)
{
static
::
assertTrue
(
$criteria
->
hasEqualsFilter
(
'fooo'
)
)
;
$sortings
=
$criteria
->
getSorting
(
)
;
static
::
assertCount
(
1,
$sortings
)
;
static
::
assertEquals
(
'id',
$sortings
[
0
]
->
getField
(
)
)
;
return
new
EntitySearchResult
(
'foo', 0,
new
LanguageCollection
(
)
, null,
$criteria
, Context::
createDefaultContext
(
)
)
;
}
)
;
$dispatcher
=
new
EventDispatcher
(
)
;
$dispatcher
->
addListener
(
ElasticsearchIndexerLanguageCriteriaEvent::
class
,
function
DElasticsearchIndexerLanguageCriteriaEvent
$event
)
: void
{
$event
->
getCriteria
(
)
->
addFilter
(
new
EqualsFilter
(
'fooo', null
)
)
;
}
)
;
static
::
assertTrue
(
$config
->
getSkipInvalid
(
)
)
;
}
public
function
testCriteria
(
)
: void
{
$route
=
new
ProductPageSeoUrlRoute
(
$this
->
createMock
(
ProductDefinition::
class
)
)
;
$criteria
=
new
Criteria
(
)
;
$salesChannel
=
new
SalesChannelEntity
(
)
;
$salesChannel
->
setId
(
'test'
)
;
$route
->
prepareCriteria
(
$criteria
,
$salesChannel
)
;
static
::
assertTrue
(
$criteria
->
hasEqualsFilter
(
'active'
)
)
;
static
::
assertTrue
(
$criteria
->
hasEqualsFilter
(
'visibilities.salesChannelId'
)
)
;
}
public
function
testMappingWithInvalidEntity
(
)
: void
{
$route
=
new
ProductPageSeoUrlRoute
(
$this
->
createMock
(
ProductDefinition::
class
)
)
;
static
::
expectException
(
\InvalidArgumentException::
class
)
;
$route
->
getMapping
(
new
ArrayEntity
(
)
,
new
SalesChannelEntity
(
)
)
;
}
static
::
assertTrue
(
$config
->
getSkipInvalid
(
)
)
;
}
public
function
testCriteria
(
)
: void
{
$route
=
new
ProductPageSeoUrlRoute
(
$this
->
createMock
(
ProductDefinition::
class
)
)
;
$criteria
=
new
Criteria
(
)
;
$salesChannel
=
new
SalesChannelEntity
(
)
;
$salesChannel
->
setId
(
'test'
)
;
$route
->
prepareCriteria
(
$criteria
,
$salesChannel
)
;
static
::
assertTrue
(
$criteria
->
hasEqualsFilter
(
'active'
)
)
;
static
::
assertTrue
(
$criteria
->
hasEqualsFilter
(
'visibilities.salesChannelId'
)
)
;
}
public
function
testMappingWithInvalidEntity
(
)
: void
{
$route
=
new
ProductPageSeoUrlRoute
(
$this
->
createMock
(
ProductDefinition::
class
)
)
;
static
::
expectException
(
\InvalidArgumentException::
class
)
;
$route
->
getMapping
(
new
ArrayEntity
(
)
,
new
SalesChannelEntity
(
)
)
;
}