Skip to content

Commit c93b59c

Browse files
Merge remote-tracking branch '37550/2.4-develop' into octcommpr
2 parents c73145e + 24de63e commit c93b59c

File tree

2 files changed

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

2 files changed

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

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Framework\Api\SearchCriteria\CollectionProcessor;
77

@@ -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)