Skip to content

Commit ff56be5

Browse files
#21853: Allow mview indexers to use different entity columns - unit & static tests fix.
1 parent 392dbf6 commit ff56be5

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php

+29-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class SubscriptionTest extends TestCase
4444
protected $viewMock;
4545

4646
/** @var string */
47-
private $tableName;
47+
private $tableName = 'thisTableName';
4848

4949
protected function setUp(): void
5050
{
@@ -210,9 +210,14 @@ public function testCreate()
210210
$otherViewMock->expects($this->exactly(1))
211211
->method('getId')
212212
->willReturn('other_id');
213-
$otherViewMock->expects($this->exactly(1))
213+
$otherViewMock->expects($this->exactly(4))
214214
->method('getSubscriptions')
215-
->willReturn([['name' => $this->tableName], ['name' => 'otherTableName']]);
215+
->willReturn(
216+
[
217+
$this->tableName => ['name' => $this->tableName, 'column' => 'columnName'],
218+
'otherTableName' => ['name' => 'otherTableName', 'column' => 'columnName']
219+
]
220+
);
216221
$otherViewMock->expects($this->exactly(3))
217222
->method('getChangelog')
218223
->willReturn($otherChangelogMock);
@@ -234,6 +239,17 @@ public function testCreate()
234239
->method('createTrigger')
235240
->with($triggerMock);
236241

242+
$this->tableName = 'thisTableName';
243+
244+
$this->viewMock->expects($this->exactly(3))
245+
->method('getSubscriptions')
246+
->willReturn(
247+
[
248+
$this->tableName => ['name' => $this->tableName, 'column' => 'columnName'],
249+
'otherTableName' => ['name' => 'otherTableName', 'column' => 'columnName']
250+
]
251+
);
252+
237253
$this->model->create();
238254
}
239255

@@ -285,6 +301,7 @@ public function testRemove()
285301
true,
286302
[]
287303
);
304+
288305
$otherViewMock->expects($this->exactly(1))
289306
->method('getId')
290307
->willReturn('other_id');
@@ -293,6 +310,15 @@ public function testRemove()
293310
->method('getChangelog')
294311
->willReturn($otherChangelogMock);
295312

313+
$otherViewMock->expects($this->any())
314+
->method('getSubscriptions')
315+
->willReturn(
316+
[
317+
$this->tableName => ['name' => $this->tableName, 'column' => 'columnName'],
318+
'otherTableName' => ['name' => 'otherTableName', 'column' => 'columnName']
319+
]
320+
);
321+
296322
$this->viewMock->expects($this->exactly(3))
297323
->method('getId')
298324
->willReturn('this_id');

lib/internal/Magento/Framework/Mview/View/Subscription.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
use Magento\Framework\Mview\View\StateInterface;
1212

1313
/**
14-
* Class Subscription
15-
*
16-
* @package Magento\Framework\Mview\View
14+
* Mview subscription.
1715
*/
1816
class Subscription implements SubscriptionInterface
1917
{
@@ -202,7 +200,7 @@ protected function buildStatement($event, $view)
202200
// We will use column name from it.
203201
$subscriptions = $view->getSubscriptions() ?? [];
204202
if (empty($subscriptions[$this->getTableName()])) {
205-
return '';
203+
return '';
206204
}
207205

208206
$subscription = $subscriptions[$this->getTableName()];

0 commit comments

Comments
 (0)