Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
ProductReviewRouteResponse example
class
ProductDescriptionReviewsTypeDataResolverTest
extends
TestCase
{
use
IntegrationTestBehaviour;
private
ProductDescriptionReviewsCmsElementResolver
$productDescriptionReviewResolver
;
protected
function
setUp
(
)
: void
{
$productReviewRouteMock
=
$this
->
createMock
(
AbstractProductReviewRoute::
class
)
;
$productReviewRouteMock
->
method
(
'load'
)
->
willReturn
(
new
ProductReviewRouteResponse
(
new
EntitySearchResult
(
'product', 0,
new
ProductReviewCollection
(
)
, null,
new
Criteria
(
)
, Context::
createDefaultContext
(
)
)
)
)
;
$this
->productDescriptionReviewResolver =
new
ProductDescriptionReviewsCmsElementResolver
(
$productReviewRouteMock
)
;
}
public
function
testType
(
)
: void
{
new
MultiFilter
(
MultiFilter::CONNECTION_AND,
[
$active
,
new
MultiFilter
(
MultiFilter::CONNECTION_OR,
[
new
EqualsFilter
(
'product.id',
$productId
)
,
new
EqualsFilter
(
'product.parentId',
$productId
)
,
]
)
,
]
)
)
;
$result
=
$this
->productReviewRepository->
search
(
$criteria
,
$context
->
getContext
(
)
)
;
return
new
ProductReviewRouteResponse
(
$result
)
;
}
}
$this
->
getContainer
(
)
->
get
(
'cache.object'
)
->
invalidateTags
(
[
CachedProductReviewRoute::ALL_TAG
]
)
;
}
/** * @dataProvider criteriaProvider */
public
function
testCriteria
(
Criteria
$criteria
)
: void
{
$context
=
$this
->
createMock
(
SalesChannelContext::
class
)
;
$response
=
new
ProductReviewRouteResponse
(
new
EntitySearchResult
(
'product_review', 0,
new
ProductReviewCollection
(
)
, null,
$criteria
,
$context
->
getContext
(
)
)
)
;
$core
=
$this
->
createMock
(
ProductReviewRoute::
class
)
;
$core
->
expects
(
static
::
exactly
(
2
)
)
->
method
(
'load'
)
->
willReturn
(
$response
)
;
$route
=
new
CachedProductReviewRoute
(
$core
,
new
TagAwareAdapter
(
new
ArrayAdapter
(
100
)
)
,