You are here

function BpcDisplayTestCase::testWizardNodeCreation in Commerce Bulk Product Creation 7.2

Tests wizard-style display node creation.

File

modules/bpc_display/bpc_display.test, line 61
Tests for Commerce BPC display node creation

Class

BpcDisplayTestCase
@file Tests for Commerce BPC display node creation

Code

function testWizardNodeCreation() {
  $this
    ->setDisplaySetting(array(
    'creation_method' => 'wizard',
    'auto_node_title_pattern' => 'Title: [bulk_defaults:entered_title]',
  ));

  // "Create product" submission should still redirect to the product list.
  $this
    ->submitBulkForm();
  $this
    ->assertUrl('admin/commerce/products');

  // With only one display node type, we should directly go to the populated
  // node form.
  $this
    ->submitBulkForm('Create products and Create display');

  // The 3rd and 4th product have been created in this round.
  $this
    ->assertTitle('Create product_display | Drupal');
  $this
    ->assertNodeFormPopulated(array(
    3,
    4,
  ));
  $this
    ->createDummyProductDisplayContentType('product_display2', TRUE, 'field_product', -1);
  $this
    ->setDisplaySetting(array(
    'auto_content_type' => 'product_display2',
  ));

  // With two display node types, and a preselected node type, we should
  // to directly to that node form.
  $this
    ->submitBulkForm('Create products and Create display');
  $this
    ->assertTitle('Create product_display2 | Drupal');

  // The 3rd and 4th product have been created in this round.
  $this
    ->assertNodeFormPopulated(array(
    5,
    6,
  ));
  $this
    ->setDisplaySetting(array(
    'auto_content_type' => '_none',
  ));
  $this
    ->submitBulkForm('Create products and Create display');

  // With two display node types and no preselected node type, we should
  // be shown a selection form.
  $this
    ->assertTitle('Create display node | Drupal');
  $this
    ->drupalPost($this
    ->getUrl(), array(
    'node_type' => 'product_display',
  ), 'Create node');
  $this
    ->assertTitle('Create product_display | Drupal');
  $this
    ->assertNodeFormPopulated(array(
    7,
    8,
  ));
}