I Want To Generate A Unique Email Address For Checkout

Hint: It’ll do it for you

This is presuming that you are using the guest checkout, though it works equally well when registering during checkout.

Because the checkout uses the customer identity all we need to do is give the customer identity a different email address. Magium already provides a mechanism for doing that.


namespace Tests\Magium\Magento\Checkout;

use Magium\Magento\AbstractMagentoTestCase;
use Magium\Magento\Actions\Cart\AddItemToCart;
use Magium\Magento\Actions\Checkout\RegisterNewCustomerCheckout;
use Magium\Magento\Extractors\Checkout\OrderId;

class RegisterNewCustomerCheckoutTest extends AbstractMagentoTestCase

    public function testBasicCheckout()
        $addToCart = $this->getAction(AddItemToCart::ACTION);
        /* @var $addToCart \Magium\Magento\Actions\Cart\AddItemToCart */

         $customerCheckout= $this->getAction(RegisterNewCustomerCheckout::ACTION);
        /* @var $customerCheckout \Magium\Magento\Actions\Checkout\RegisterNewCustomerCheckout */


        self::assertNotEquals('[email protected]', $this->getIdentity()->getEmailAddress());


The key to this test is the last line where we get the email address and assert that it is not “[email protected]”, which is the default. We can then use this identity to log in, out, and whatnot.

Doing It Manually

You can also do it manually which is, as you might expect, stupid-easy.

<?php class CustomerAuthenticationTest extends AbstractMagentoTestCase { public function testGetDefaultCustomerAddress() { $this->getIdentity()->generateUniqueEmailAddress(); } public function testGetCustomeDomainCustomerAddress() { $this->getIdentity()->generateUniqueEmailAddress('eschrade.com'); } }