Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InlineEditUpdaterTest.php
Go to the documentation of this file.
1 <?php
7 
11 
12 class InlineEditUpdaterTest extends \PHPUnit\Framework\TestCase
13 {
15  protected $validationRules;
16 
18  protected $validationRule;
19 
21  protected $column;
22 
24  protected $component;
25 
26  protected function setUp()
27  {
28  $this->validationRules = $this->getMockBuilder(
29  \Magento\Customer\Ui\Component\Listing\Column\ValidationRules::class
30  )->disableOriginalConstructor()->getMock();
31 
32  $this->validationRule = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class)
33  ->disableOriginalConstructor()
34  ->getMock();
35 
36  $this->column = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponentInterface::class)
37  ->disableOriginalConstructor()
38  ->getMock();
39 
40  $this->component = new InlineEditUpdater($this->validationRules);
41  }
42 
43  public function testApplyEditing()
44  {
45  $this->column->expects($this->once())
46  ->method('getConfiguration')
47  ->willReturn([
48  'visible' => true,
49  ]);
50  $this->validationRules->expects($this->once())
51  ->method('getValidationRules')
52  ->with(true, [$this->validationRule])
53  ->willReturn([
54  'validate-email' => true,
55  'required-entry' => true
56  ]);
57  $this->column->expects($this->once())
58  ->method('setData')
59  ->with(
60  'config',
61  [
62  'visible' => true,
63  'editor' => [
64  'editorType' => 'text',
65  'validation' => [
66  'validate-email' => true,
67  'required-entry' => true,
68  ]
69  ]
70  ]
71  );
72 
73  $this->component->applyEditing($this->column, 'text', [$this->validationRule], true);
74  }
75 }