Skip to content

Commit b35b1ff

Browse files
author
Cari Spruiell
committed
MAGETWO-38820: [Add join processors to search service] Tax Module - III
- Add joinProcessor to Tax/Model/TaxRuleRepository.php - updated associated unit test
1 parent 16b737e commit b35b1ff

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

app/code/Magento/Tax/Model/TaxRuleRepository.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,33 @@ class TaxRuleRepository implements TaxRuleRepositoryInterface
5252
*/
5353
protected $resource;
5454

55+
/**
56+
* @var \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface
57+
*/
58+
protected $joinProcessor;
59+
5560
/**
5661
* @param TaxRuleRegistry $taxRuleRegistry
5762
* @param TaxRuleSearchResultsInterfaceFactory $searchResultsFactory
5863
* @param RuleFactory $ruleFactory
5964
* @param CollectionFactory $collectionFactory
6065
* @param Resource $resource
66+
* @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor
6167
*/
6268
public function __construct(
6369
TaxRuleRegistry $taxRuleRegistry,
6470
TaxRuleSearchResultsInterfaceFactory $searchResultsFactory,
6571
RuleFactory $ruleFactory,
6672
CollectionFactory $collectionFactory,
67-
Resource $resource
73+
Resource $resource,
74+
\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor
6875
) {
6976
$this->taxRuleRegistry = $taxRuleRegistry;
7077
$this->taxRuleSearchResultsFactory = $searchResultsFactory;
7178
$this->taxRuleModelFactory = $ruleFactory;
7279
$this->collectionFactory = $collectionFactory;
7380
$this->resource = $resource;
81+
$this->joinProcessor = $joinProcessor;
7482
}
7583

7684
/**
@@ -133,6 +141,7 @@ public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria)
133141

134142
$fields = [];
135143
$collection = $this->collectionFactory->create();
144+
$this->joinProcessor->process($collection);
136145

137146
//Add filters from root filter group to the collection
138147
foreach ($searchCriteria->getFilterGroups() as $group) {

app/code/Magento/Tax/Test/Unit/Model/TaxRuleRepositoryTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class TaxRuleRepositoryTest extends \PHPUnit_Framework_TestCase
4646
*/
4747
protected $resource;
4848

49+
/**
50+
* @var \PHPUnit_Framework_MockObject_MockObject
51+
*/
52+
protected $extensionAttributesJoinProcessorMock;
53+
4954
/**
5055
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
5156
*/
@@ -78,13 +83,21 @@ protected function setUp()
7883
false
7984
);
8085
$this->resource = $this->getMock('\Magento\Tax\Model\Resource\Calculation\Rule', [], [], '', false);
86+
$this->extensionAttributesJoinProcessorMock = $this->getMock(
87+
'\Magento\Framework\Api\ExtensionAttribute\JoinProcessor',
88+
['process'],
89+
[],
90+
'',
91+
false
92+
);
8193

8294
$this->model = new TaxRuleRepository(
8395
$this->taxRuleRegistry,
8496
$this->searchResultFactory,
8597
$this->ruleFactory,
8698
$this->collectionFactory,
87-
$this->resource
99+
$this->resource,
100+
$this->extensionAttributesJoinProcessorMock
88101
);
89102
}
90103

@@ -181,6 +194,10 @@ public function testGetList()
181194
$filterMock = $this->getMock('\Magento\Framework\Api\Filter', [], [], '', false);
182195
$sortOrderMock = $this->getMock('\Magento\Framework\Api\SortOrder', [], [], '', false);
183196

197+
$this->extensionAttributesJoinProcessorMock->expects($this->once())
198+
->method('process')
199+
->with($collectionMock);
200+
184201
$this->searchResultsMock->expects($this->once())->method('setSearchCriteria')->with($searchCriteriaMock);
185202
$this->collectionFactory->expects($this->once())->method('create')->willReturn($collectionMock);
186203
$searchCriteriaMock->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroupMock]);

0 commit comments

Comments
 (0)