public function CacheFlushCronUI::editForm in CacheFlush 8
Edit form test.
File
- modules/
cacheflush_cron/ tests/ src/ Functional/ CacheFlushCronUI.php, line 62
Class
- CacheFlushCronUI
- Test cacheflush Cron UI.
Namespace
Drupal\Tests\cacheflush_cron\FunctionalCode
public function editForm() {
$this
->drupalGet('admin/structure/cacheflush/add');
$this
->assertResponse(200);
$this
->assertRaw(t('Enable cron job for this preset.'));
// Test Entity create.
$data = [
'title' => 'NewEntityTitle',
'cron' => 1,
];
$this
->drupalPostForm('admin/structure/cacheflush/add', $data, t('Save'));
$entities = array_values(cacheflush_load_multiple_by_properties([
'title' => 'NewEntityTitle',
]));
$this
->assertEqual($entities[0]
->getTitle(), 'NewEntityTitle', 'Entity successfully created.');
$this
->drupalGet('cacheflush/' . $entities[0]
->id() . '/edit');
$this
->assertResponse(200);
$this
->assertFieldByName('cron', 1, 'Cron checkbox is checked.');
$this
->assertLink(t('Edit'));
$data['cron'] = 0;
$this
->drupalPostForm('cacheflush/' . $entities[0]
->id() . '/edit', $data, t('Save'));
$entities = array_values(cacheflush_load_multiple_by_properties([
'title' => 'NewEntityTitle',
]));
$this
->drupalGet('cacheflush/' . $entities[0]
->id() . '/edit');
$this
->assertResponse(200);
$this
->assertFieldByName('cron', 0, 'Cron checkbox is NOT checked.');
// Test Entity create.
$data = [
'title' => 'NewEntityTitle2',
];
// Test that the Edit link should not be in UI if no CronJob created yet.
$this
->drupalPostForm('admin/structure/cacheflush/add', $data, t('Save'));
$entities = array_values(cacheflush_load_multiple_by_properties([
'title' => 'NewEntityTitle2',
]));
$this
->assertEqual($entities[0]
->getTitle(), 'NewEntityTitle2', 'Entity successfully created.');
$this
->drupalGet('cacheflush/' . $entities[0]
->id() . '/edit');
$this
->assertResponse(200);
$this
->assertFieldByName('cron', 0, 'Cron checkbox is NOT checked.');
$this
->assertNoLink('Edit');
}