Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AttributeHandlerTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 
17 class AttributeHandlerTest extends \PHPUnit\Framework\TestCase
18 {
22  private $source;
23 
27  private $subject;
28 
32  protected function setUp()
33  {
34  $this->source = $this->getMockBuilder(SourceProviderInterface::class)
35  ->disableOriginalConstructor()
36  ->setMethods(['joinAttribute'])
37  ->getMockForAbstractClass();
38 
39  $objectManager = new ObjectManager($this);
40 
41  $this->subject = $objectManager->getObject(AttributeHandler::class);
42  }
43 
45  {
46  $alias = 'e';
47  $fieldInfo = [
48  'name' => 'is_approved',
49  'origin' => 'is_approved',
50  'type' => 'searchable',
51  'dataType' => 'varchar',
52  'entity' => 'customer',
53  'bind' => 'test',
54  ];
55 
56  $this->source->expects($this->once())
57  ->method('joinAttribute')
58  ->with(
59  $fieldInfo['name'],
60  $fieldInfo['entity'] . '/' . $fieldInfo['origin'],
61  $fieldInfo['bind'],
62  null,
63  'left'
64  )
65  ->willReturnSelf();
66 
67  $this->subject->prepareSql($this->source, $alias, $fieldInfo);
68  }
69 
70  public function testPrepareSqlWithoutBind()
71  {
72  $alias = 'e';
73  $fieldInfo = [
74  'name' => 'is_approved',
75  'origin' => 'is_approved',
76  'type' => 'searchable',
77  'dataType' => 'varchar',
78  'entity' => 'customer',
79  ];
80  $this->source->expects($this->once())
81  ->method('addFieldToSelect')
82  ->with('is_approved', 'left');
83 
84  $this->subject->prepareSql($this->source, $alias, $fieldInfo);
85  }
86 }
$objectManager
Definition: bootstrap.php:17
if(!trim($html)) $alias
Definition: details.phtml:20