19 private $customAttributeFactory;
29 private $variationMatrix;
38 $this->customAttributeFactory = $this->createMock(\
Magento\Framework\Api\AttributeValueFactory::class);
40 $this->product = $this->createPartialMock(
41 \
Magento\Catalog\Model\Product::class,
42 [
'getData',
'getPrice',
'getName',
'getSku',
'__wakeup',
'getCustomAttributes']
45 $this->productFactory = $this->createPartialMock(\
Magento\Catalog\Model\ProductFactory::class, [
'create']);
47 $this->variationMatrix = $this->createMock(
51 $this->model = new \Magento\ConfigurableProduct\Model\ProductVariationsBuilder(
52 $this->productFactory,
53 $this->customAttributeFactory,
54 $this->variationMatrix
60 $output = $this->createPartialMock(
61 \
Magento\Catalog\Model\Product::class,
62 [
'setPrice',
'__wakeup',
'setData',
'getCustomAttributes',
'setName',
'setSku',
'setVisibility']
64 $attributes = [10 => [
'attribute_code' =>
'sort_order']];
66 [10 => [
'value' => 15,
'price' => [
'pricing_value' => 10]]],
68 $this->variationMatrix->expects($this->once())
69 ->method(
'getVariations')
71 ->willReturn($variations);
73 $this->productFactory->expects($this->once())->method(
'create')->willReturn(
$output);
75 $this->product->expects($this->once())->method(
'getData')->willReturn(
$productData);
76 $this->product->expects($this->once())->method(
'getName')->willReturn(
'simple');
77 $this->product->expects($this->once())->method(
'getSku')->willReturn(
'simple-sku');
78 $this->product->expects($this->once())->method(
'getPrice')->willReturn(10);
84 ->method(
'setAttributeCode')
93 $this->customAttributeFactory->expects($this->once())
97 $output->expects($this->once())->method(
'getCustomAttributes')->willReturn([]);
99 $output->expects($this->at(2))->method(
'setData')->with(
'custom_attributes', [
'sort_order' =>
$attribute]);
100 $output->expects($this->once())->method(
'setPrice')->with(10);
101 $output->expects($this->once())->method(
'setName')->with(
'simple-15');
102 $output->expects($this->once())->method(
'setSku')->with(
'simple-sku-15');
103 $output->expects($this->once())->method(
'setVisibility')
104 ->with(\
Magento\Catalog\Model\
Product\Visibility::VISIBILITY_NOT_VISIBLE);