You are here

public function DateRecurModularOscarTest::testWidget in Recurring Date Field Modular Widgets 8

Same name and namespace in other branches
  1. 3.x tests/src/Functional/DateRecurModularOscarTest.php \Drupal\Tests\date_recur_modular\Functional\DateRecurModularOscarTest::testWidget()
  2. 2.x tests/src/Functional/DateRecurModularOscarTest.php \Drupal\Tests\date_recur_modular\Functional\DateRecurModularOscarTest::testWidget()

Tests field widget input is converted to appropriate database values.

@dataProvider providerTestWidget

Parameters

array $values: Array of form fields to submit.

array $expected: Array of expected field normalized values.

bool $clickAllDay: Whether to click the all day toggle.

File

tests/src/Functional/DateRecurModularOscarTest.php, line 66

Class

DateRecurModularOscarTest
Tests Oscar Widget.

Namespace

Drupal\Tests\date_recur_modular\Functional

Code

public function testWidget(array $values, array $expected, $clickAllDay = FALSE) : void {
  $entity = DrEntityTest::create();
  $entity
    ->save();
  $this
    ->drupalGet($entity
    ->toUrl('edit-form'));
  if ($clickAllDay) {
    $this
      ->getSession()
      ->getPage()
      ->find('css', '.parts--is-all-day .form-radios> *:nth-child(1) label')
      ->click();
  }
  $this
    ->drupalPostForm(NULL, $values, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('has been updated.');
  $entity = DrEntityTest::load($entity
    ->id());
  $this
    ->assertEquals($expected, $entity->dr[0]
    ->getValue());
}