You are here

protected function CommerceProductReferenceSynonymsBehaviorWebTestCase::createProduct in Synonyms 7

Supportive function.

Create an entity of necessary entity type (in our test it's commerce product).

Parameters

string $label: Label to use for the entity that is about to be created

string $bundle: Bundle to use for the entity that is about to be created

Return value

object Fully loaded entity object of the just created entity

1 call to CommerceProductReferenceSynonymsBehaviorWebTestCase::createProduct()
CommerceProductReferenceSynonymsBehaviorWebTestCase::testCommerceProductReference in synonyms_commerce/synonyms_commerce.test
Test synonyms extraction for 'commerce_product_reference' field type.

File

synonyms_commerce/synonyms_commerce.test, line 839
Tests for the Synonyms Commerce module.

Class

CommerceProductReferenceSynonymsBehaviorWebTestCase
Test CommerceProductReferenceSynonymsBehavior class.

Code

protected function createProduct($label = NULL, $bundle = 'product') {
  if (is_null($label)) {
    $label = $this
      ->randomName();
  }
  $entity = commerce_product_new($bundle);
  $entity->title = $label;
  $entity->sku = drupal_html_id($label);
  commerce_product_save($entity);
  return $entity;
}