Fix for Create product reference field

  1.   public function testTestTest() {
  2.  
  3.     // Test creating a Product Display content type
  4.     $type = array(
  5.       'type' => 'product_display',
  6.       'name' => st('Product Display'),
  7.       'base' => 'node_content',
  8.       'description' => st('Use <em>product displays</em> to display products for sale to your customers.'),
  9.       'custom' => 1,
  10.       'modified' => 1,
  11.       'locked' => 0,
  12.     );
  13.     $type = node_type_set_defaults($type);
  14.     node_type_save($type);
  15.     node_add_body_field($type);
  16.  
  17.     // Add a product reference field to the product node type.
  18.     $field = array(
  19.       'field_name' => 'field_product',
  20.       'type' => 'commerce_product_reference',
  21.       'cardinality' => 1,
  22.       'translatable' => FALSE,
  23.     );
  24.     field_create_field($field);
  25.  
  26.     $instance = array(
  27.       'field_name' => 'field_product',
  28.       'entity_type' => 'node',
  29.       'label' => 'Product',
  30.       'bundle' => 'product',
  31.       'description' => 'Choose a product to display for sale.',
  32.       'required' => TRUE,
  33.  
  34.       'widget' => array(
  35.         'type' => 'options_select',
  36.       ),
  37.  
  38.       'display' => array(
  39.         'full' => array(
  40.           'label' => 'hidden',
  41.           'type' => 'commerce_cart_add_to_cart_form',
  42.         ),
  43.         'teaser' => array(
  44.           'label' => 'hidden',
  45.           'type' => 'commerce_cart_add_to_cart_form',
  46.         ),
  47.       ),
  48.     );
  49.     field_create_instance($instance);
  50.  
  51.     cache_clear_all();
  52.     menu_rebuild();
  53.  
  54.     $this->drupalLogin($this->site_admin);
  55.     $this->drupalGet('node/add/product-display');
  56.     $this->assertOptionSelected('field_product-und', '_none', 'Dummy Product Display reference field shows up on node add page');
  57.  
  58.     $this->drupalGet('admin/structure/types/manage/product_display/fields');
  59.     $this->drupalGet('admin/structure/types/manage/product_display/display');
  60.   }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.