You are here

protected function CommerceCheckoutLoginTestBase::prepareAnonymousEnvironment in Commerce Checkout Login 7.2

Helper function to prepare an anonymous enviroment, it sets the user, products and prepares a cart.

1 call to CommerceCheckoutLoginTestBase::prepareAnonymousEnvironment()
CommerceCheckoutLoginTestBase::startCheckoutProcess in tests/CommerceCheckoutLoginTestBase.test

File

tests/CommerceCheckoutLoginTestBase.test, line 42
Contains the test class for Commerce checkout login module tests.

Class

CommerceCheckoutLoginTestBase
Class for commerce checkout login testing.

Code

protected function prepareAnonymousEnvironment() {

  // Login as admin user to grant permissions.
  $this
    ->drupalLogin($this->siteAdministratorAccount);
  $this
    ->enablePermissionForRoles('access checkout', array(
    DRUPAL_ANONYMOUS_RID,
    DRUPAL_AUTHENTICATED_RID,
  ));
  $this
    ->createDummyProductDisplayContentType();
  $this->testProduct = $this
    ->createDummyProduct();
  $this->testProductNode = $this
    ->createDummyProductNode(array(
    $this->testProduct->product_id,
  ), $this
    ->randomName());
  $this
    ->ensureUserIsAnonymous();

  // Submit the add to cart form.
  $this
    ->drupalPost('node/' . $this->testProductNode->nid, array(), t('Add to cart'));
  $this
    ->setCurrentOrder();
  $this->lastInsertedUserId = $this
    ->getLastAddedUserId();
}