protected function AjaxFormTestBase::assertAjaxCommand in Purge 8.3
Assert that a \Drupal\Core\Ajax\CloseModalDialogCommand is issued.
Parameters
\Drupal\Core\Ajax\AjaxResponse $ajax: The undecoded AjaxResponse object returned by the http_kernel.
string $command: The name of the command to assert.
string[] $parameters: Expected parameters present in the command array.
2 calls to AjaxFormTestBase::assertAjaxCommand()
- AjaxFormTestBase::assertAjaxCommandCloseModalDialog in modules/
purge_ui/ tests/ src/ Functional/ Form/ AjaxFormTestBase.php - Assert that a \Drupal\Core\Ajax\CloseModalDialogCommand is issued.
- AjaxFormTestBase::assertAjaxCommandReloadConfigForm in modules/
purge_ui/ tests/ src/ Functional/ Form/ AjaxFormTestBase.php - Assert that a \Drupal\purge_ui\Form\ReloadConfigFormCommand is issued.
File
- modules/
purge_ui/ tests/ src/ Functional/ Form/ AjaxFormTestBase.php, line 26
Class
- AjaxFormTestBase
- Testbase for Ajax-based purge_ui forms.
Namespace
Drupal\Tests\purge_ui\Functional\FormCode
protected function assertAjaxCommand(AjaxResponse $ajax, $command, array $parameters = []) : void {
$commands = $ajax
->getCommands();
$commandsString = var_export($commands, TRUE);
$match = array_search($command, array_column($commands, 'command'));
$this
->assertSame(TRUE, is_int($match), "Ajax command {$command} not found:\n " . $commandsString);
$this
->assertSame(TRUE, isset($commands[$match]));
foreach ($parameters as $parameter => $value) {
$this
->assertSame(TRUE, isset($commands[$match][$parameter]), "Ajax parameter '{$parameter}' = '{$value}' not found:\n " . $commandsString);
$this
->assertSame($commands[$match][$parameter], $value, "Ajax parameter '{$parameter}' = '{$value}' not equal:\n " . $commandsString);
}
}