function BatchBuilderTest::testAddOperation

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

Tests addOperation().

@covers ::addOperation

File

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

Class

BatchBuilderTest
Tests for the batch builder class.

Namespace

Drupal\Tests\Core\Batch

Code

public function testAddOperation() : void {
    $batch_builder = new BatchBuilder();
    $batch = $batch_builder->addOperation('\\Drupal\\Tests\\Core\\Batch\\BatchBuilderTest::operationCallback')
        ->toArray();
    $this->assertEquals([
        [
            '\\Drupal\\Tests\\Core\\Batch\\BatchBuilderTest::operationCallback',
            [],
        ],
    ], $batch['operations']);
    $batch = $batch_builder->addOperation('\\Drupal\\Tests\\Core\\Batch\\BatchBuilderTest::operationCallback', [
        2,
    ])
        ->addOperation('\\Drupal\\Tests\\Core\\Batch\\BatchBuilderTest::operationCallback', [
        3,
    ])
        ->toArray();
    $this->assertEquals([
        [
            '\\Drupal\\Tests\\Core\\Batch\\BatchBuilderTest::operationCallback',
            [],
        ],
        [
            '\\Drupal\\Tests\\Core\\Batch\\BatchBuilderTest::operationCallback',
            [
                2,
            ],
        ],
        [
            '\\Drupal\\Tests\\Core\\Batch\\BatchBuilderTest::operationCallback',
            [
                3,
            ],
        ],
    ], $batch['operations']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.