public function BillingScheduleTest::testBillingScheduleCreation in Commerce Recurring Framework 8
Tests creating a billing schedule.
File
- tests/
src/ FunctionalJavascript/ BillingScheduleTest.php, line 38
Class
- BillingScheduleTest
- Tests the billing schedule UI.
Namespace
Drupal\Tests\commerce_recurring\FunctionalJavascriptCode
public function testBillingScheduleCreation() {
$this
->drupalGet('admin/commerce/config/billing-schedules');
$page = $this
->getSession()
->getPage();
$page
->clickLink('Add billing schedule');
$this
->assertSession()
->addressEquals('admin/commerce/config/billing-schedules/add');
$page
->fillField('label', 'Test');
$this
->getSession()
->wait(1000, 'jQuery("#edit-label-machine-name-suffix .machine-name-value").html() == "test"');
$values = [
'billingType' => BillingScheduleInterface::BILLING_TYPE_POSTPAID,
'displayLabel' => 'Awesome test',
'dunning[retry][0]' => '1',
'dunning[retry][1]' => '2',
'dunning[retry][2]' => '3',
'dunning[unpaid_subscription_state]' => 'canceled',
'plugin' => 'fixed',
'configuration[fixed][trial_interval][allow_trials]' => 1,
'configuration[fixed][trial_interval][number]' => '2',
'configuration[fixed][trial_interval][unit]' => 'month',
'configuration[fixed][interval][number]' => '2',
'configuration[fixed][interval][unit]' => 'month',
'configuration[fixed][start_day]' => '4',
'prorater' => 'proportional',
];
$this
->submitForm($values, 'Save');
$this
->assertSession()
->addressEquals('admin/commerce/config/billing-schedules');
$this
->assertSession()
->responseContains('Test');
$billing_schedule = BillingSchedule::load('test');
$this
->assertEquals('test', $billing_schedule
->id());
$this
->assertEquals('Test', $billing_schedule
->label());
$this
->assertEquals('Awesome test', $billing_schedule
->getDisplayLabel());
$this
->assertEquals(BillingScheduleInterface::BILLING_TYPE_POSTPAID, $billing_schedule
->getBillingType());
$this
->assertEquals([
1,
2,
3,
], $billing_schedule
->getRetrySchedule());
$this
->assertEquals('canceled', $billing_schedule
->getUnpaidSubscriptionState());
$this
->assertEquals('fixed', $billing_schedule
->getPluginId());
$this
->assertTrue($billing_schedule
->getPlugin()
->allowTrials());
$this
->assertEquals([
'interval' => [
'number' => '2',
'unit' => 'month',
],
'start_month' => '1',
'start_day' => '4',
'trial_interval' => [
'number' => '2',
'unit' => 'month',
],
], $billing_schedule
->getPluginConfiguration());
$this
->assertEquals($billing_schedule
->getPluginConfiguration(), $billing_schedule
->getPlugin()
->getConfiguration());
$this
->assertEquals('proportional', $billing_schedule
->getProraterId());
}