/** * @expectedException \Magento\Customer\Exception * @expectedExceptionMessage exception message */ public function testCreateCustomerWithPasswordHashException() { $storeId = 5; $customerData = array('id' => self::ID, 'email' => self::EMAIL, 'firstname' => self::FIRSTNAME, 'lastname' => self::LASTNAME, 'store_id' => $storeId, 'website_id' => self::WEBSITE_ID); $this->_customerBuilder->populateWithArray($customerData); $customerEntity = $this->_customerBuilder->create(); $customerDetails = $this->_customerDetailsBuilder->setCustomer($customerEntity)->create(); $this->_storeManagerMock->expects($this->once())->method('getStores')->will($this->returnValue(array())); $this->_converter = $this->getMock('Magento\\Customer\\Model\\Converter', array('getCustomerModel', 'createCustomerModel'), array(), '', false); $this->_converter->expects($this->once())->method('getCustomerModel')->will($this->returnValue($this->_customerModelMock)); $this->_converter->expects($this->once())->method('createCustomerModel')->will($this->throwException(new \Magento\Customer\Exception('exception message', 0))); $customerService = $this->_createService(); $customerService->createCustomerWithPasswordHash($customerDetails, '', ''); }