function MakeUniqueEntityFieldTest::entityQueryExpects

Same name in other branches
  1. 8.9.x core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php \Drupal\Tests\migrate\Unit\process\MakeUniqueEntityFieldTest::entityQueryExpects()
  2. 10 core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php \Drupal\Tests\migrate\Unit\process\MakeUniqueEntityFieldTest::entityQueryExpects()
  3. 11.x core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php \Drupal\Tests\migrate\Unit\process\MakeUniqueEntityFieldTest::entityQueryExpects()

Helper function to add expectations to the mock entity query object.

Parameters

int $count: The number of unique values to be set up.

1 call to MakeUniqueEntityFieldTest::entityQueryExpects()
MakeUniqueEntityFieldTest::testMakeUniqueEntityField in core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php
Tests making an entity field value unique.

File

core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php, line 162

Class

MakeUniqueEntityFieldTest
@coversDefaultClass \Drupal\migrate\Plugin\migrate\process\MakeUniqueEntityField @group migrate

Namespace

Drupal\Tests\migrate\Unit\process

Code

protected function entityQueryExpects($count) {
    $this->entityQuery
        ->expects($this->exactly($count + 1))
        ->method('condition')
        ->willReturn($this->entityQuery);
    $this->entityQuery
        ->expects($this->exactly($count + 1))
        ->method('count')
        ->willReturn($this->entityQuery);
    $this->entityQuery
        ->expects($this->exactly($count + 1))
        ->method('execute')
        ->willReturnCallback(function () use (&$count) {
        return $count--;
    });
}

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