function BatchBuilderTest::testSetFile
Tests setFile().
@covers ::setFile
      
    
File
- 
              core/tests/ Drupal/ Tests/ Core/ Batch/ BatchBuilderTest.php, line 115 
Class
- BatchBuilderTest
- Tests for the batch builder class.
Namespace
Drupal\Tests\Core\BatchCode
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)
    ->setFinishCallback('_batch_test_finished_1')
    ->addOperation('_batch_test_callback_1', [])
    ->toArray();
  $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');
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
