Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 4a2284c

Browse files
committed
MAGETWO-90109: Customer Grid Indexer not working #10838
1 parent eb09566 commit 4a2284c

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

lib/internal/Magento/Framework/Indexer/Handler/AttributeHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function prepareSql(SourceProviderInterface $source, $alias, $fieldInfo)
3535
'left'
3636
);
3737
} else {
38-
$source->addAttributeToSelect($fieldInfo['origin'], 'left');
38+
$source->addFieldToSelect($fieldInfo['origin'], 'left');
3939
}
4040
}
4141
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Framework\Indexer\Test\Unit\Handler;
9+
10+
use Magento\Framework\Indexer\Handler\AttributeHandler;
11+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
12+
use Magento\Framework\App\ResourceConnection\SourceProviderInterface;
13+
14+
/**
15+
* Unit test for Magento\Framework\Indexer\Handler\AttributeHandler.
16+
*/
17+
class AttributeHandlerTest extends \PHPUnit\Framework\TestCase
18+
{
19+
/**
20+
* @var SourceProviderInterface|\PHPUnit_Framework_MockObject_MockObject
21+
*/
22+
private $source;
23+
24+
/**
25+
* @var AttributeHandler
26+
*/
27+
private $subject;
28+
29+
/**
30+
* @inheritdoc
31+
*/
32+
protected function setUp()
33+
{
34+
$this->source = $this->getMockBuilder(SourceProviderInterface::class)
35+
->disableOriginalConstructor()
36+
->getMockForAbstractClass();
37+
38+
$objectManager = new ObjectManager($this);
39+
40+
$this->subject = $objectManager->getObject(AttributeHandler::class);
41+
}
42+
43+
public function testPrepareSql()
44+
{
45+
$alias = 'e';
46+
$fieldInfo = [
47+
'name' => 'is_approved',
48+
'origin' => 'is_approved',
49+
'type' => 'searchable',
50+
'dataType' => 'varchar',
51+
'entity' => 'customer',
52+
'bind' => null,
53+
];
54+
$this->source->expects($this->once())
55+
->method('addFieldToSelect')
56+
->with('is_approved', 'left')
57+
->willReturnSelf();
58+
59+
$this->subject->prepareSql($this->source, $alias, $fieldInfo);
60+
}
61+
}

0 commit comments

Comments
 (0)