public function CronKeyCangeTest::testCronKeyChange in Cron key change 2.x
Same name and namespace in other branches
- 8 tests/src/Functional/CronKeyCangeTest.php \Drupal\Tests\cronkeychange\Functional\CronKeyCangeTest::testCronKeyChange()
Tests the change cron key.
File
- tests/
src/ Functional/ CronKeyCangeTest.php, line 46
Class
- CronKeyCangeTest
- Tests the change cron key.
Namespace
Drupal\Tests\cronkeychange\FunctionalCode
public function testCronKeyChange() {
$original_cron_key = \Drupal::state()
->get('system.cron_key');
$this
->drupalGet('/admin/config/system/cron');
$visible_cron_key = trim($this
->getSession()
->getPage()
->find('xpath', '//*[@id="edit-current"]/text()[2]')
->getText());
$this
->assertEquals($original_cron_key, $visible_cron_key, 'Original value show correctly.');
$this
->drupalPostForm('admin/config/system/cron', [], t('Generate new key'));
$visible_cron_key = trim($this
->getSession()
->getPage()
->find('xpath', '//*[@id="edit-current"]/text()[2]')
->getText());
$this
->assertNotSame($visible_cron_key, '', 'Generated cron key is not null.');
$this
->assertNotEquals($original_cron_key, $visible_cron_key, 'Cron key is changed.');
}