You are here

public function BatchBuilderTest::testAddOperation in Drupal 8

Same name and namespace in other branches
  1. 9 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 227

Class

BatchBuilderTest
Tests for the batch builder class.

Namespace

Drupal\Tests\Core\Batch

Code

public function testAddOperation() {
  $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']);
}