You are here

public function DateRecurModularOscarTest::testAllDayToggle 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::testAllDayToggle()
  2. 2.x tests/src/Functional/DateRecurModularOscarTest.php \Drupal\Tests\date_recur_modular\Functional\DateRecurModularOscarTest::testAllDayToggle()

Tests all-day toggle visibility.

File

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

Class

DateRecurModularOscarTest
Tests Oscar Widget.

Namespace

Drupal\Tests\date_recur_modular\Functional

Code

public function testAllDayToggle() : void {
  $entity = DrEntityTest::create();
  $entity
    ->save();
  $this
    ->drupalGet($entity
    ->toUrl('edit-form'));

  // By default toggle is enabled, so it should be visible.
  // Assert each container exists before checking the all-day element.
  $this
    ->assertSession()
    ->elementExists('css', '.parts--times');

  // Must have all-day toggle.
  $this
    ->assertSession()
    ->elementExists('css', '.parts--times .parts--is-all-day');

  // @todo replace in 8.8: See 2835616.
  $display = \entity_get_form_display('dr_entity_test', 'dr_entity_test', 'default');
  $component = $display
    ->getComponent('dr');
  $component['settings']['all_day_toggle'] = FALSE;
  $display
    ->setComponent('dr', $component);
  $display
    ->save();
  $this
    ->drupalGet($entity
    ->toUrl('edit-form'));
  $this
    ->assertSession()
    ->elementExists('css', '.parts--times');
  $this
    ->assertSession()
    ->elementNotExists('css', '.parts--times .parts--is-all-day');
}