You are here

protected function FeedsMockingTrait::getMockedAccountSwitcher in Feeds 8.3

Returns a mocked AccountSwitcher object.

The returned object verifies that if switchTo() is called, switchBack() is also called.

Return value

\Drupal\Core\Session\AccountSwitcherInterface A mocked AccountSwitcher object.

3 calls to FeedsMockingTrait::getMockedAccountSwitcher()
FeedQueueWorkerBaseTest::test in tests/src/Unit/Plugin/QueueWorker/FeedQueueWorkerBaseTest.php
Tests various methods on the FeedQueueWorkerBase class.
FeedRefreshTest::setUp in tests/src/Unit/Plugin/QueueWorker/FeedRefreshTest.php
FeedsExecutableTest::setUp in tests/src/Unit/FeedsExecutableTest.php

File

tests/src/Traits/FeedsMockingTrait.php, line 62

Class

FeedsMockingTrait
Provides methods for mocking certain Feeds classes.

Namespace

Drupal\Tests\feeds\Traits

Code

protected function getMockedAccountSwitcher() {
  $switcher = $this
    ->prophesize(AccountSwitcherInterface::class);
  $switcher
    ->switchTo(Argument::type(AccountInterface::class))
    ->will(function () use ($switcher) {
    $switcher
      ->switchBack()
      ->shouldBeCalled();
    return $switcher
      ->reveal();
  });
  return $switcher
    ->reveal();
}