Skip to content

Commit 2fe04a0

Browse files
committed
#27504 fix joinprocessor behavior with consecutive calls
1 parent 5676386 commit 2fe04a0

File tree

2 files changed

+62
-0
lines changed
  • dev/tests/integration/testsuite/Magento/Framework/Api/SearchCriteria/CollectionProcessor
  • lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor

2 files changed

+62
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Magento\Framework\Api\SearchCriteria\CollectionProcessor;
5+
6+
use Magento\Framework\Api\SearchCriteria\CollectionProcessor\JoinProcessor\CustomJoinInterface;
7+
use Magento\Framework\Api\SearchCriteriaBuilder;
8+
use Magento\Framework\Data\Collection\AbstractDb;
9+
use PHPUnit\Framework\TestCase;
10+
11+
class JoinProcessorTest extends TestCase
12+
{
13+
/**
14+
* @var \Magento\Framework\ObjectManagerInterface
15+
*/
16+
private $objectManager;
17+
18+
protected function setUp(): void
19+
{
20+
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
21+
}
22+
23+
/**
24+
* Test proper application of the join processor for consecutive calls with different collections.
25+
*
26+
* @return void
27+
*/
28+
public function testMultipleCollections(): void
29+
{
30+
$customJoinMock = $this->getMockBuilder(CustomJoinInterface::class)
31+
->getMock();
32+
33+
$customJoinMock->expects($this->exactly(2))
34+
->method('apply');
35+
36+
$joinProcessor = $this->objectManager->create(JoinProcessor::class, [
37+
'customJoins' => [
38+
'test_join' => $customJoinMock,
39+
],
40+
'fieldMapping' => [
41+
'test_field' => 'test_join',
42+
],
43+
]);
44+
45+
$searchCriteria = $this->objectManager->create(SearchCriteriaBuilder::class)
46+
->addFilter('test_field', 'test')
47+
->create();
48+
49+
$collection1 = $this->getMockBuilder(AbstractDb::class)
50+
->disableOriginalConstructor()
51+
->getMockForAbstractClass();
52+
53+
$collection2 = $this->getMockBuilder(AbstractDb::class)
54+
->disableOriginalConstructor()
55+
->getMockForAbstractClass();
56+
57+
$joinProcessor->process($searchCriteria, $collection1);
58+
$joinProcessor->process($searchCriteria, $collection2);
59+
}
60+
}

lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/JoinProcessor.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public function process(SearchCriteriaInterface $searchCriteria, AbstractDb $col
7272
}
7373
}
7474
}
75+
76+
$this->appliedFields = [];
7577
}
7678

7779
/**

0 commit comments

Comments
 (0)