Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
DisableAutoGroupAssignDefaultTest.php
Go to the documentation of this file.
1 <?php
7 
8 class DisableAutoGroupAssignDefaultTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $model;
14 
18  protected $eavConfigMock;
19 
20  protected function setUp()
21  {
22  $this->eavConfigMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class)
23  ->disableOriginalConstructor()
24  ->getMock();
25 
26  $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
27  $this->model = $objectManager->getObject(
28  \Magento\Customer\Model\Config\Backend\CreateAccount\DisableAutoGroupAssignDefault::class,
29  [
30  'eavConfig' => $this->eavConfigMock,
31  ]
32  );
33  }
34 
35  public function testAfterSave()
36  {
37  $value = true;
38 
39  $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class)
40  ->setMethods(['save', 'setData'])
41  ->disableOriginalConstructor()
42  ->getMockForAbstractClass();
43 
44  $this->eavConfigMock->expects($this->once())
45  ->method('getAttribute')
46  ->with('customer', 'disable_auto_group_change')
47  ->willReturn($attributeMock);
48 
49  $attributeMock->expects($this->once())
50  ->method('setData')
51  ->with('default_value', $value);
52  $attributeMock->expects($this->once())
53  ->method('save');
54 
55  $this->model->setValue($value);
56 
57  $this->assertEquals($this->model, $this->model->afterSave());
58  }
59 }
$objectManager
Definition: bootstrap.php:17
$value
Definition: gender.phtml:16