Skip to content
Snippets Groups Projects
Verified Commit ad50981a authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3028621 by jungle, John Cook: BatchBuilder included files fails

parent d22493e7
Branches
Tags
8 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
......@@ -205,12 +205,18 @@ public function setErrorMessage($message) {
* The path should be relative to base_path(), and thus should be built using
* drupal_get_path(). Defaults to {module_name}.module.
*
* The file needs to be set before using ::addOperation(),
* ::setFinishCallback(), or any other function that uses callbacks from the
* file. This is so that PHP knows about the included functions.
*
* @param string $filename
* The path to the file.
*
* @return $this
*/
public function setFile($filename) {
include_once $filename;
$this->file = $filename;
return $this;
}
......
......@@ -113,11 +113,20 @@ public function testSetErrorMessage() {
* @covers ::setFile
*/
public function testSetFile() {
$filename = dirname(__DIR__, 6) . '/core/modules/system/tests/modules/batch_test/batch_test.callbacks.inc';
$this->assertIsNotCallable('_batch_test_callback_1');
$this->assertIsNotCallable('_batch_test_finished_1');
$batch = (new BatchBuilder())
->setFile('filename.php')
->setFile($filename)
->setFinishCallback('_batch_test_finished_1')
->addOperation('_batch_test_callback_1', [])
->toArray();
$this->assertEquals('filename.php', $batch['file']);
$this->assertEquals($filename, $batch['file']);
$this->assertEquals([['_batch_test_callback_1', []]], $batch['operations']);
$this->assertEquals('_batch_test_finished_1', $batch['finished']);
$this->assertIsCallable('_batch_test_callback_1');
$this->assertIsCallable('_batch_test_finished_1');
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment