25 private $converterPoolMock;
30 private $providerMock;
40 private $converterMock;
44 $this->productMock = $this->createMock(Product::class);
45 $this->converterPoolMock = $this->createMock(ConverterPool::class);
46 $this->providerMock = $this->createMock(CollectionProviderInterface::class);
47 $this->converterMock = $this->createMock(ConverterInterface::class);
49 $this->model =
new CollectionProvider($this->converterPoolMock, [
'crosssell' => $this->providerMock]);
57 $linkedProductOneMock = $this->createMock(Product::class);
58 $linkedProductTwoMock = $this->createMock(Product::class);
59 $linkedProductThreeMock = $this->createMock(Product::class);
61 $linkedProductOneMock->expects($this->once())->method(
'getId')->willReturn(1);
62 $linkedProductTwoMock->expects($this->once())->method(
'getId')->willReturn(2);
63 $linkedProductThreeMock->expects($this->once())->method(
'getId')->willReturn(3);
65 $this->converterPoolMock->expects($this->once())
66 ->method(
'getConverter')
68 ->willReturn($this->converterMock);
71 [$linkedProductOneMock, [
'name' =>
'Product One',
'position' => 10]],
72 [$linkedProductTwoMock, [
'name' =>
'Product Two',
'position' => 2]],
73 [$linkedProductThreeMock, [
'name' =>
'Product Three',
'position' => 2]],
76 $this->converterMock->expects($this->exactly(3))->method(
'convert')->willReturnMap(
$map);
78 $this->providerMock->expects($this->once())
79 ->method(
'getLinkedProducts')
80 ->with($this->productMock)
83 $linkedProductOneMock,
84 $linkedProductTwoMock,
85 $linkedProductThreeMock
90 2 => [
'name' =>
'Product Two',
'position' => 2],
91 3 => [
'name' =>
'Product Three',
'position' => 2],
92 10 => [
'name' =>
'Product One',
'position' => 10],
95 $actualResult = $this->model->getCollection($this->productMock,
'crosssell');
97 $this->assertEquals($expectedResult, $actualResult,
'Sort order of linked products in incorrect');
108 $this->model->getCollection($this->productMock,
'upsell');
testGetCollectionWithMissingProviders()