function CommentStatisticsUnitTest::fetchObjectCallback

Same name in other branches
  1. 9 core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php \Drupal\Tests\comment\Unit\CommentStatisticsUnitTest::fetchObjectCallback()
  2. 8.9.x core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php \Drupal\Tests\comment\Unit\CommentStatisticsUnitTest::fetchObjectCallback()
  3. 11.x core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php \Drupal\Tests\comment\Unit\CommentStatisticsUnitTest::fetchObjectCallback()

Return value callback for fetchObject() function on mocked object.

Return value

bool|string 'Something' on first, 'something-else' on second and FALSE for the other calls to function.

File

core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php, line 115

Class

CommentStatisticsUnitTest
@coversDefaultClass \Drupal\comment\CommentStatistics @group comment

Namespace

Drupal\Tests\comment\Unit

Code

public function fetchObjectCallback() {
    $this->callsToFetch++;
    switch ($this->callsToFetch) {
        case 1:
            return 'something';
        case 2:
            return 'something-else';
        default:
            return FALSE;
    }
}

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