public function PromotionTest::testDuplicate in Commerce Core 8.2
@covers ::createDuplicate
File
- modules/
promotion/ tests/ src/ Kernel/ Entity/ PromotionTest.php, line 194
Class
- PromotionTest
- Tests the Promotion entity.
Namespace
Drupal\Tests\commerce_promotion\Kernel\EntityCode
public function testDuplicate() {
$coupon = Coupon::create([
'code' => $this
->randomMachineName(),
'status' => TRUE,
]);
$coupon
->save();
$promotion = Promotion::create([
'name' => '10% off',
'coupons' => [
$coupon,
],
'status' => FALSE,
]);
$promotion
->save();
$this
->assertNotEmpty($promotion
->getCouponIds());
$duplicate_promotion = $promotion
->createDuplicate();
$this
->assertEquals('10% off', $duplicate_promotion
->label());
$this
->assertFalse($duplicate_promotion
->hasCoupons());
}