/** * This test is designed to execute all code paths of Form\Register::getFormData() when testing the * Form\Register::restoreSessionData() method. */ public function testRestoreSessionData() { $data = new \Magento\Framework\DataObject(); $data->setRegionId(self::REGION_ID_ATTRIBUTE_VALUE); $data->setCustomerData(1); $data[self::REGION_ID_ATTRIBUTE_CODE] = (int) self::REGION_ID_ATTRIBUTE_VALUE; $customerFormData = [self::REGION_ID_ATTRIBUTE_CODE => self::REGION_ID_ATTRIBUTE_VALUE]; $this->_customerSession->expects($this->once())->method('getCustomerFormData')->will($this->returnValue($customerFormData)); $form = $this->getMock('Magento\\Customer\\Model\\Metadata\\Form', [], [], '', false); $request = $this->getMockForAbstractClass('Magento\\Framework\\App\\RequestInterface', [], '', false); $formData = $this->_block->getFormData(); $form->expects($this->once())->method('prepareRequest')->with($formData->getData())->will($this->returnValue($request)); $form->expects($this->once())->method('extractData')->with($request, null, false)->will($this->returnValue($customerFormData)); $form->expects($this->once())->method('restoreData')->will($this->returnValue($customerFormData)); $block = $this->_block->restoreSessionData($form, null, false); $this->assertSame($this->_block, $block); $this->assertEquals($data, $block->getData(self::FORM_DATA)); }