/** * Check if all admin options are provided * * @param InputInterface $input * @return string[] */ public function validate(InputInterface $input) { $errors = []; $user = new \Magento\Framework\DataObject(); $user->setFirstname($input->getOption(AdminAccount::KEY_FIRST_NAME))->setLastname($input->getOption(AdminAccount::KEY_LAST_NAME))->setUsername($input->getOption(AdminAccount::KEY_USER))->setEmail($input->getOption(AdminAccount::KEY_EMAIL))->setPassword($input->getOption(AdminAccount::KEY_PASSWORD) === null ? '' : $input->getOption(AdminAccount::KEY_PASSWORD)); $validator = new \Magento\Framework\Validator\DataObject(); $this->validationRules->addUserInfoRules($validator); $this->validationRules->addPasswordRules($validator); if (!$validator->isValid($user)) { $errors = array_merge($errors, $validator->getMessages()); } return $errors; }
/** * Form data has not been set on the block, but there is customer data from the customer session. * The customer data is something other than 'region_id' so that code path is skipped. */ public function testGetFormDataNullFormDataCustomerFormData() { $data = new \Magento\Framework\DataObject(); $data->setFirstname('John'); $data->setCustomerData(1); $customerFormData = ['firstname' => 'John']; $this->_customerSession->expects($this->once())->method('getCustomerFormData')->will($this->returnValue($customerFormData)); $this->assertEquals($data, $this->_block->getFormData()); $this->assertEquals($data, $this->_block->getData(self::FORM_DATA)); }