43 $this->configurableAttributeHandler = $this->createMock(
46 $this->resourceHelperMock = $this->createMock(\
Magento\Catalog\Model\
ResourceModel\Helper::class);
47 $this->collectionMock = $this->createMock(
50 $this->resourceHelperMock->expects(
58 $this->returnValue($this->labelPart)
60 $this->configurableAttributeHandler->expects(
63 'getApplicableAttributes' 65 $this->returnValue($this->collectionMock)
70 $this->collectionMock->expects(
75 $this->returnValueMap($valueMap)
77 $this->attributeMock = $this->createPartialMock(
79 [
'getId',
'getFrontendLabel',
'getAttributeCode',
'getSource']
81 $this->collectionMock->expects(
86 $this->returnValue([
'id' => $this->attributeMock])
88 $this->suggestedListModel = new \Magento\ConfigurableProduct\Model\SuggestedAttributeList(
89 $this->configurableAttributeHandler,
90 $this->resourceHelperMock
97 $result[
'id'] = [
'id' =>
'id',
'label' =>
'label',
'code' =>
'code',
'options' =>
'options'];
98 $this->attributeMock->expects($this->once())->method(
'getId')->will($this->returnValue(
'id'));
99 $this->attributeMock->expects($this->once())->method(
'getFrontendLabel')->will($this->returnValue(
'label'));
100 $this->attributeMock->expects($this->once())->method(
'getAttributeCode')->will($this->returnValue(
'code'));
101 $this->attributeMock->expects($this->once())->method(
'getSource')->will($this->returnValue(
$source));
102 $source->expects($this->once())->method(
'getAllOptions')->with(
false)->will($this->returnValue(
'options'));
103 $this->configurableAttributeHandler->expects($this->once())->method(
'isAttributeApplicable')
104 ->with($this->attributeMock)->willReturn(
true);
106 $this->assertEquals(
$result, $this->suggestedListModel->getSuggestedAttributes($this->labelPart));
111 $this->attributeMock->expects($this->never())->method(
'getId');
112 $this->attributeMock->expects($this->never())->method(
'getFrontendLabel');
113 $this->attributeMock->expects($this->never())->method(
'getAttributeCode');
114 $this->attributeMock->expects($this->never())->method(
'getSource');
115 $this->configurableAttributeHandler->expects($this->once())->method(
'isAttributeApplicable')
116 ->with($this->attributeMock)->willReturn(
false);
118 $this->assertEquals([], $this->suggestedListModel->getSuggestedAttributes($this->labelPart));
testGetSuggestedAttributesIfTheyApplicable()
$configurableAttributeHandler
testGetSuggestedAttributesIfTheyNotApplicable()