Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
ProductReviewCollection 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
{
static
::
assertSame
(
'product-description-reviews',
$this
->productDescriptionReviewResolver->
getType
(
)
)
;
}
$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
)
)
,
$this
->
getContainer
(
)
->
get
(
EntityCacheKeyGenerator::
class
)
,
$this
->systemConfigServiceMock->
method
(
'get'
)
->
with
(
'core.listing.showReview'
)
->
willReturn
(
true
)
;
$requestBag
=
new
RequestDataBag
(
[
'test' => 'test'
]
)
;
$request
=
new
Request
(
[
'test' => 'test'
]
)
;
$productReview
=
new
ProductReviewEntity
(
)
;
$productReview
->
setUniqueIdentifier
(
$ids
->
get
(
'productReview'
)
)
;
$reviewResult
=
new
ReviewLoaderResult
(
'review',
1,
new
ProductReviewCollection
(
[
$productReview
]
)
,
null,
new
Criteria
(
)
,
Context::
createDefaultContext
(
)
)
;
$this
->productReviewLoaderMock->
method
(
'load'
)
->
with
(
$request
,
$this
->
createMock
(
SalesChannelContext::
class
)
)
->
willReturn
(
$reviewResult
)
;
$response
=
$this
->controller->
loadReviews
(
$request
,