DateRecurModularSierraTest.php in Recurring Date Field Modular Widgets 2.x
File
tests/src/Functional/DateRecurModularSierraTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\date_recur_modular\Functional;
use Drupal\date_recur_entity_test\Entity\DrEntityTest;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class DateRecurModularSierraTest extends WebDriverTestBase {
protected static $modules = [
'date_recur_modular',
'date_recur_entity_test',
'entity_test',
'datetime',
'datetime_range',
'date_recur',
'field',
'user',
'system',
];
protected function setUp() : void {
parent::setUp();
$display = \Drupal::service('entity_display.repository')
->getFormDisplay('dr_entity_test', 'dr_entity_test', 'default');
$component = $display
->getComponent('dr');
$component['region'] = 'content';
$component['type'] = 'date_recur_modular_sierra';
$component['settings'] = [];
$display
->setComponent('dr', $component);
$display
->save();
$user = $this
->drupalCreateUser([
'administer entity_test content',
]);
$user->timezone = 'Asia/Singapore';
$user
->save();
$this
->drupalLogin($user);
}
public function testUserNoTimeZone() : void {
\Drupal::configFactory()
->getEditable('system.date')
->set('timezone.user.configurable', FALSE)
->save();
$user = $this
->drupalCreateUser([
'administer entity_test content',
]);
$user->timezone = '';
$user
->save();
$this
->assertNull($user->timezone->value);
$this
->drupalLogin($user);
$entity = DrEntityTest::create();
$entity->dr = [
'value' => '2015-05-13T14:00:00',
'end_value' => '2015-05-14T13:59:59',
'rrule' => 'FREQ=WEEKLY;INTERVAL=1;COUNT=1',
'timezone' => 'Asia/Singapore',
];
$entity
->save();
$this
->drupalGet($entity
->toUrl('edit-form'));
$this
->assertSession()
->checkboxChecked('dr[0][is_all_day]');
$entity = DrEntityTest::create();
$entity->dr = [
'value' => '2015-05-13T14:00:00',
'end_value' => '2015-05-14T13:58:59',
'rrule' => 'FREQ=WEEKLY;INTERVAL=1;COUNT=1',
'timezone' => 'Asia/Singapore',
];
$entity
->save();
$this
->drupalGet($entity
->toUrl('edit-form'));
$this
->assertSession()
->checkboxNotChecked('dr[0][is_all_day]');
}
}