SchedulerAdminSettingsTest.php in Scheduler 2.x
File
tests/src/Functional/SchedulerAdminSettingsTest.php
View source
<?php
namespace Drupal\Tests\scheduler\Functional;
class SchedulerAdminSettingsTest extends SchedulerBrowserTestBase {
public function testAdminSettings() {
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/config/content/scheduler');
$this
->assertSession()
->pageTextContains('No entity types returned by media module for use in Media Scheduler Plugin');
$this
->schedulerMediaSetUp();
$this
->SchedulerCommerceProductSetUp();
$this
->assertFalse($this
->config('scheduler.settings')
->get('allow_date_only'), 'The default setting for allow_date_only is False.');
$this
->assertEquals('00:00:00', $this
->config('scheduler.settings')
->get('default_time'), '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
->drupalGet('admin/config/content/scheduler');
$this
->submitForm($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
->drupalGet('admin/config/content/scheduler');
$this
->submitForm($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
->drupalGet('admin/config/content/scheduler');
$this
->submitForm($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
->drupalGet('admin/config/content/scheduler');
$this
->submitForm($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');
}
}