From 2dd2b7dea4bb227708a0047a9d875846316c8ffc Mon Sep 17 00:00:00 2001
From: Dmytro Poperechnyy <dpoperechnyy@magento.com>
Date: Thu, 14 Dec 2017 10:18:59 +0200
Subject: [PATCH] MAGETWO-81802: Magento 2.2.0rc23: Customer Grid Indexer not
 working

- Add unit test;
---
 .../Unit/Handler/AttributeHandlerTest.php     | 57 +++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 lib/internal/Magento/Framework/Indexer/Test/Unit/Handler/AttributeHandlerTest.php

diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/Handler/AttributeHandlerTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/Handler/AttributeHandlerTest.php
new file mode 100644
index 00000000000..82b178e0ff4
--- /dev/null
+++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/Handler/AttributeHandlerTest.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+namespace Magento\Framework\Indexer\Test\Unit\Handler;
+
+use Magento\Framework\Indexer\Handler\AttributeHandler;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\App\ResourceConnection\SourceProviderInterface;
+
+class AttributeHandlerTest extends \PHPUnit\Framework\TestCase
+{
+    /**
+     * @var SourceProviderInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    private $source;
+
+    /**
+     * @var AttributeHandler
+     */
+    private $subject;
+
+    protected function setUp()
+    {
+        $this->source = $this->getMockBuilder(SourceProviderInterface::class)
+            ->disableOriginalConstructor()
+            ->getMockForAbstractClass();
+
+        $objectManager = new ObjectManager($this);
+
+        $this->subject = $objectManager->getObject(
+            AttributeHandler::class,
+            []
+        );
+    }
+
+    public function testPrepareSql()
+    {
+        $alias = 'e';
+        $fieldInfo = [
+            'name' => 'is_approved',
+            'origin' => 'is_approved',
+            'type' => 'searchable',
+            'dataType' => 'varchar',
+            'entity' => 'customer',
+            'bind' => null
+        ];
+        $this->source->expects($this->once())
+            ->method('addFieldToSelect')
+            ->with('is_approved', 'left')
+            ->willReturnSelf();
+
+        $this->subject->prepareSql($this->source, $alias, $fieldInfo);
+    }
+}
-- 
GitLab