QueueChangeFormTest.php in Purge 8.3
File
modules/purge_ui/tests/src/Functional/Form/QueueChangeFormTest.php
View source
<?php
namespace Drupal\Tests\purge_ui\Functional\Form;
use Drupal\purge_ui\Form\QueueChangeForm;
class QueueChangeFormTest extends AjaxFormTestBase {
public static $modules = [
'purge_queue_test',
'purge_ui',
];
protected $formClass = QueueChangeForm::class;
protected $route = 'purge_ui.queue_change_form';
protected $routeTitle = 'Change queue engine';
public function testChangeForm() : void {
$this
->drupalLogin($this->adminUser);
$this
->drupalGet($this
->getPath());
$this
->assertSession()
->responseContains('Change queue engine');
$this
->assertSession()
->responseContains('The queue engine is the underlying plugin which stores');
$this
->assertSession()
->responseContains('when you change the queue, it will be emptied as well');
$this
->assertSession()
->responseContains('Description');
$this
->assertActionExists('edit-cancel', 'Cancel');
$this
->assertActionExists('edit-submit', 'Change');
$this
->assertSession()
->checkboxChecked('edit-plugin-id-memory');
}
public function testChangeFormSubmit() : void {
$this
->drupalLogin($this->adminUser);
$form = $this
->formInstance()
->buildForm([], $this
->getFormStateInstance());
$submitted = $this
->getFormStateInstance();
$submitted
->setValue('plugin_id', 'b');
$ajax = $this
->formInstance()
->changeQueue($form, $submitted);
$this
->assertAjaxCommandReloadConfigForm($ajax);
$this
->assertAjaxCommandCloseModalDialog($ajax);
$this
->assertAjaxCommandsTotal($ajax, 2);
$this
->drupalGet($this
->getPath());
$this
->assertSession()
->responseContains('Change queue engine');
$this
->assertSession()
->checkboxChecked('edit-plugin-id-b');
$ajax = $this
->postAjaxForm([], 'Cancel');
$this
->assertAjaxCommandCloseModalDialog($ajax);
$this
->assertAjaxCommandsTotal($ajax, 1);
}
}