View source
<?php
namespace Drupal\Tests\scheduler\Functional;
class SchedulerAdminSettingsTest extends SchedulerBrowserTestBase {
public function testAdminSettings() {
$this
->drupalLogin($this->adminUser);
$this
->assertFalse($this
->config('scheduler.settings')
->get('allow_date_only'), 'The default setting for allow_date_only is False.');
$this
->assertEquals($this
->config('scheduler.settings')
->get('default_time'), '00:00:00', 'The default config setting for default_time is 00:00:00');
$this
->assertFalse($this
->config('scheduler.settings')
->get('hide_seconds'), 'The default setting for hide_seconds is False.');
$settings = [
'allow_date_only' => TRUE,
'default_time' => '6:30',
];
$this
->drupalPostForm('admin/config/content/scheduler', $settings, 'Save configuration');
$this
->assertTrue($this
->config('scheduler.settings')
->get('allow_date_only'), 'The config setting for allow_date_only is stored correctly.');
$this
->assertEquals('06:30:00', $this
->config('scheduler.settings')
->get('default_time'), 'The config setting for default_time is stored correctly.');
$settings = [
'allow_date_only' => TRUE,
'default_time' => '123',
];
$this
->drupalPostForm('admin/config/content/scheduler', $settings, 'Save configuration');
$this
->assertEquals('06:30:00', $this
->config('scheduler.settings')
->get('default_time'), 'The config setting for default_time has not changed.');
$this
->assertSession()
->pageTextContains('The default time should be in the format HH:MM:SS');
$settings = [
'hide_seconds' => TRUE,
];
$this
->drupalPostForm('admin/config/content/scheduler', $settings, 'Save configuration');
$this
->assertTrue($this
->config('scheduler.settings')
->get('hide_seconds'), 'The config setting for hide_seconds is stored correctly.');
$this
->assertEquals('06:30', $this
->config('scheduler.settings')
->get('default_time'), 'The config setting for default_time is stored correctly.');
$settings = [
'default_time' => '456',
];
$this
->drupalPostForm('admin/config/content/scheduler', $settings, 'Save configuration');
$this
->assertEquals('06:30', $this
->config('scheduler.settings')
->get('default_time'), 'The config setting for default_time has not changed.');
$this
->assertSession()
->pageTextMatches('/The default time should be in the format HH:MM[^:S]/');
$this
->drupalGet('admin/reports/status');
}
}