function BatchBuilderTest::testSetFile

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Batch/BatchBuilderTest.php \Drupal\Tests\Core\Batch\BatchBuilderTest::testSetFile()
  2. 8.9.x core/tests/Drupal/Tests/Core/Batch/BatchBuilderTest.php \Drupal\Tests\Core\Batch\BatchBuilderTest::testSetFile()
  3. 10 core/tests/Drupal/Tests/Core/Batch/BatchBuilderTest.php \Drupal\Tests\Core\Batch\BatchBuilderTest::testSetFile()

Tests setFile().

@covers ::setFile

File

core/tests/Drupal/Tests/Core/Batch/BatchBuilderTest.php, line 117

Class

BatchBuilderTest
Tests for the batch builder class.

Namespace

Drupal\Tests\Core\Batch

Code

public function testSetFile() : void {
    $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.