public function SubscriptionTest::testTrialTimestamps in Commerce Recurring Framework 8
Tests the automatic timestamp generation for trials.
@covers ::preSave
File
- tests/
src/ Kernel/ Entity/ SubscriptionTest.php, line 271
Class
- SubscriptionTest
- Tests the subscription entity.
Namespace
Drupal\Tests\commerce_recurring\Kernel\EntityCode
public function testTrialTimestamps() {
$configuration = $this->billingSchedule
->getPluginConfiguration();
$configuration['trial_interval'] = [
'number' => '1',
'unit' => 'hour',
];
$this->billingSchedule
->setPluginConfiguration($configuration);
$this->billingSchedule
->save();
$trial_subscription = Subscription::create([
'type' => 'product_variation',
'store_id' => $this->store
->id(),
'billing_schedule' => $this->billingSchedule,
'uid' => 0,
'payment_method' => $this->paymentMethod,
'title' => 'My subscription',
'purchased_entity' => $this->variation,
'quantity' => 2,
'unit_price' => new Price('2', 'USD'),
'state' => 'trial',
'trial_starts' => 1550250000,
]);
$trial_subscription
->save();
$this
->assertEquals(1550250000, $trial_subscription
->getTrialStartTime());
$this
->assertEquals(1550250000 + 3600, $trial_subscription
->getTrialEndTime());
$this
->assertEquals(1550250000 + 3600, $trial_subscription
->getStartTime());
}