function AjaxResponseTest::createCommandMockWithSettingsAndLibrariesAttachments
Creates a mock of a provided subclass of CommandInterface.
Adds given settings and libraries to assets mock that is attached to the command mock.
Parameters
string $command_class_name: The command class name to create the mock for.
array|null $settings: The settings to attach.
array|null $libraries: The libraries to attach.
string $command_name: The command name to pass to the mock.
1 call to AjaxResponseTest::createCommandMockWithSettingsAndLibrariesAttachments()
- AjaxResponseTest::testMergeWithOtherAjaxResponse in core/
tests/ Drupal/ Tests/ Core/ Ajax/ AjaxResponseTest.php - Tests the mergeWith() method.
File
-
core/
tests/ Drupal/ Tests/ Core/ Ajax/ AjaxResponseTest.php, line 158
Class
- AjaxResponseTest
- @coversDefaultClass \Drupal\Core\Ajax\AjaxResponse[[api-linebreak]] @group Ajax
Namespace
Drupal\Tests\Core\AjaxCode
private function createCommandMockWithSettingsAndLibrariesAttachments(string $command_class_name, array|null $settings, array|null $libraries, string $command_name) : CommandInterface {
$command = $this->createMock($command_class_name);
$command->expects($this->once())
->method('render')
->willReturn([
'command' => $command_name,
]);
$assets = $this->createMock('Drupal\\Core\\Asset\\AttachedAssetsInterface');
$assets->expects($this->once())
->method('getLibraries')
->willReturn($libraries);
$assets->expects($this->once())
->method('getSettings')
->willReturn($settings);
$command->expects($this->once())
->method('getAttachedAssets')
->willReturn($assets);
return $command;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.