/** * @magentoDataFixture Magento/Customer/_files/customer.php * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @magentoAppArea adminhtml */ public function testRemoveByEmail() { $customer = $this->_model->retrieve(self::CUSTOMER_ID); $this->assertInstanceOf('\\Magento\\Customer\\Model\\Customer', $customer); $customer->delete(); $this->_model->removeByEmail(self::CUSTOMER_EMAIL, self::WEBSITE_ID); $this->_model->retrieveByEmail(self::CUSTOMER_EMAIL, $customer->getWebsiteId()); }
public function testRemoveByEmail() { $this->customer->expects($this->exactly(2))->method('loadByEmail')->with(self::CUSTOMER_EMAIL)->will($this->returnValue($this->customer)); $this->customer->expects($this->any())->method('getId')->will($this->returnValue(self::CUSTOMER_ID)); $this->customer->expects($this->any())->method('getEmail')->will($this->returnValue(self::CUSTOMER_EMAIL)); $this->customer->expects($this->any())->method('getWebsiteId')->will($this->returnValue(self::WEBSITE_ID)); $this->customer->expects($this->any())->method('setEmail')->will($this->returnValue($this->customer)); $this->customer->expects($this->any())->method('setWebsiteId')->will($this->returnValue($this->customer)); $this->customerFactory->expects($this->exactly(2))->method('create')->will($this->returnValue($this->customer)); $actual = $this->customerRegistry->retrieveByEmail(self::CUSTOMER_EMAIL, self::WEBSITE_ID); $this->assertEquals($this->customer, $actual); $this->customerRegistry->removeByEmail(self::CUSTOMER_EMAIL, self::WEBSITE_ID); $actual = $this->customerRegistry->retrieveByEmail(self::CUSTOMER_EMAIL, self::WEBSITE_ID); $this->assertEquals($this->customer, $actual); }