/** * @magentoDataFixture Magento/Customer/_files/inactive_customer.php * @magentoAppArea frontend * @expectedException \Magento\Framework\Exception\State\InvalidTransitionException */ public function testActivateCustomerAlreadyActive() { /** @var \Magento\Customer\Model\Customer $customerModel */ $customerModel = $this->_objectManager->create('Magento\\Customer\\Model\\Customer'); $customerModel->load(1); $key = $customerModel->getConfirmation(); $this->_customerAccountService->activateCustomer($customerModel->getId(), $key); // activate it one more time to produce an exception $this->_customerAccountService->activateCustomer($customerModel->getId(), $key); }