'id' =>
$d, 'position' => 4, 'media' =>
['fileName' => 'd'
]],
['id' =>
$b, 'position' => 2, 'media' =>
['fileName' => 'b'
]],
['id' =>
$a, 'position' => 1, 'media' =>
['fileName' => 'a'
]],
['id' =>
$c, 'position' => 3, 'media' =>
['fileName' => 'c'
]],
],
];
$this->repository->
create([$data], Context::
createDefaultContext());
$criteria =
new Criteria([$id]);
$criteria->
getAssociation('media'
) ->
setLimit(3
) ->
addSorting(new FieldSorting('product_media.position', FieldSorting::ASCENDING
));
$product =
$this->repository->
search($criteria, Context::
createDefaultContext()) ->
first();
$ids =
$product->
getMedia()->
map(fn (ProductMediaEntity
$a) =>
$a->
getId());
$order =
[$a,
$b,
$c];
static::
assertEquals($order,
array_values($ids));
$criteria =
new Criteria([$id]);