PurgerMoveFormDownTest.php in Purge 8.3
File
modules/purge_ui/tests/src/Functional/Form/PurgerMoveFormDownTest.php
View source
<?php
namespace Drupal\Tests\purge_ui\Functional;
use Drupal\purge_ui\Form\PurgerMoveForm;
use Drupal\Tests\purge_ui\Functional\Form\AjaxFormTestBase;
class PurgerMoveFormDownTest extends AjaxFormTestBase {
public static $modules = [
'purge_ui',
'purge_purger_test',
];
protected $formClass = PurgerMoveForm::class;
protected $formId = 'purge_ui.purger_move_form';
protected $route = 'purge_ui.purger_move_down_form';
protected $routeParameters = [
'id' => 'id0',
'direction' => 'down',
];
protected $routeParametersInvalid = [
'id' => 'doesnotexist',
'direction' => 'down',
];
protected $routeTitle = 'Do you want to move Purger A down in the execution order?';
public function setUp($switch_to_memory_queue = TRUE) : void {
parent::setUp($switch_to_memory_queue);
$this
->initializePurgersService([
'a',
'b',
'c',
]);
}
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 testMoveDown() : void {
$this
->drupalLogin($this->adminUser);
$this
->assertEquals([
'a',
'b',
'c',
], array_values($this->purgePurgers
->getPluginsEnabled()));
$this
->drupalGet($this
->getPath());
$this
->assertSession()
->responseContains($this->routeTitle);
$ajax = $this
->postAjaxForm([], 'Yes!');
$this
->assertAjaxCommandCloseModalDialog($ajax);
$this
->assertAjaxCommandReloadConfigForm($ajax);
$this->purgePurgers
->reload();
$this
->assertEquals([
'b',
'a',
'c',
], array_values($this->purgePurgers
->getPluginsEnabled()));
}
}