ProcessorDeleteFormTest.php in Purge 8.3
File
modules/purge_ui/tests/src/Functional/Form/ProcessorDeleteFormTest.php
View source
<?php
namespace Drupal\Tests\purge_ui\Functional\Form;
use Drupal\purge_ui\Form\ProcessorDeleteForm;
class ProcessorDeleteFormTest extends AjaxFormTestBase {
public static $modules = [
'purge_ui',
'purge_processor_test',
];
protected $formClass = ProcessorDeleteForm::class;
protected $route = 'purge_ui.processor_delete_form';
protected $routeParameters = [
'id' => 'a',
];
protected $routeParametersInvalid = [
'id' => 'doesnotexist',
];
protected $routeTitle = 'Are you sure you want to delete the Processor A processor?';
public function setUp($switch_to_memory_queue = TRUE) : void {
parent::setUp($switch_to_memory_queue);
$this
->initializeProcessorsService([
'a',
]);
}
public function testNoPresence() : void {
$this
->drupalLogin($this->adminUser);
$this
->drupalGet($this
->getPath());
$this
->assertSession()
->responseContains('No');
}
public function testNoSubmit() : void {
$this
->drupalLogin($this->adminUser);
$ajax = $this
->postAjaxForm([], 'No');
$this
->assertAjaxCommandCloseModalDialog($ajax);
$this
->assertAjaxCommandsTotal($ajax, 1);
}
public function testDeleteProcessor() : void {
$this
->drupalLogin($this->adminUser);
$this
->drupalGet($this
->getPath());
$this
->assertSession()
->responseContains('Yes, delete this processor!');
$this
->assertSame([
'a',
], $this->purgeProcessors
->getPluginsEnabled());
$ajax = $this
->postAjaxForm([], 'Yes, delete this processor!');
$this
->assertAjaxCommandReloadConfigForm($ajax);
$this
->assertAjaxCommandCloseModalDialog($ajax);
$this
->assertAjaxCommandsTotal($ajax, 2);
$this->purgeProcessors
->reload();
$this
->assertSame(TRUE, is_array($this->purgeProcessors
->getPluginsEnabled()));
$this
->assertEmpty($this->purgeProcessors
->getPluginsEnabled());
}
}