Example #1
0
 /**
  * @dataProvider refreshAclDataProvider
  * @param $isUserPassedViaParams
  */
 public function testRefreshAcl($isUserPassedViaParams)
 {
     $aclMock = $this->getMockBuilder('Magento\\Framework\\Acl')->disableOriginalConstructor()->getMock();
     $this->aclBuilder->expects($this->any())->method('getAcl')->willReturn($aclMock);
     $userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->setMethods(['getReloadAclFlag', 'setReloadAclFlag', 'unsetData', 'save'])->disableOriginalConstructor()->getMock();
     $userMock->expects($this->any())->method('getReloadAclFlag')->willReturn(true);
     $userMock->expects($this->once())->method('setReloadAclFlag')->with('0')->willReturnSelf();
     $userMock->expects($this->once())->method('save');
     $this->storage->expects($this->once())->method('setAcl')->with($aclMock);
     $this->storage->expects($this->any())->method('getAcl')->willReturn($aclMock);
     if ($isUserPassedViaParams) {
         $this->session->refreshAcl($userMock);
     } else {
         $this->storage->expects($this->once())->method('getUser')->willReturn($userMock);
         $this->session->refreshAcl();
     }
     $this->assertSame($aclMock, $this->session->getAcl());
 }