/** * Test the title generation. */ public function testTitleGeneration() { /** @var \Drupal\commerce_product\Entity\ProductVariationInterface $variation */ $variation = $this->createEntity('commerce_product_variation', ['type' => 'test_default', 'sku' => strtolower($this->randomMachineName())]); /** @var \Drupal\commerce_product\Entity\ProductInterface $product */ $product = $this->createEntity('commerce_product', ['type' => 'default', 'title' => 'My product', 'variations' => [$variation]]); $this->assertFalse($variation->getTitle()); $this->variationType->setGenerateTitle(TRUE); $this->variationType->save(); /** @var \Drupal\commerce_product\Entity\ProductVariationInterface $variation */ $variation = $this->createEntity('commerce_product_variation', ['type' => 'test_default', 'sku' => strtolower($this->randomMachineName())]); /** @var \Drupal\commerce_product\Entity\ProductInterface $product */ $product = $this->createEntity('commerce_product', ['type' => 'default', 'title' => 'My second product', 'variations' => [$variation]]); $this->assertEqual($variation->getTitle(), $product->getTitle()); // @todo Create attributes, then retest title generation. }