function CronSuspendQueueDelayTest::setUp

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Cron/CronSuspendQueueDelayTest.php \Drupal\Tests\Core\Cron\CronSuspendQueueDelayTest::setUp()
  2. 10 core/tests/Drupal/Tests/Core/Cron/CronSuspendQueueDelayTest.php \Drupal\Tests\Core\Cron\CronSuspendQueueDelayTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Cron/CronSuspendQueueDelayTest.php, line 46

Class

CronSuspendQueueDelayTest
Test Cron handling of suspended queues with a delay.

Namespace

Drupal\Tests\Core\Cron

Code

protected function setUp() : void {
  parent::setUp();
  $lock = $this->createStub(LockBackendInterface::class);
  $lock->method('acquire')
    ->willReturn(TRUE);
  $this->cronConstructorArguments = [
    'moduleHandler' => $this->createStub(ModuleHandlerInterface::class),
    'lock' => $lock,
    'queueFactory' => $this->createStub(QueueFactory::class),
    'state' => $this->createStub(StateInterface::class),
    'accountSwitcher' => $this->createStub(AccountSwitcherInterface::class),
    'logger' => $this->createStub(LoggerInterface::class),
    'queueManager' => $this->createMock(QueueWorkerManagerInterface::class),
    'time' => $this->createStub(TimeInterface::class),
    'queue_config' => [],
  ];
  // Capture error logs.
  $config = $this->createMock(ImmutableConfig::class);
  $config->method('get')
    ->with('logging')
    ->willReturn(0);
  $configFactory = $this->createMock(ConfigFactoryInterface::class);
  $configFactory->method('get')
    ->with('system.cron')
    ->willReturn($config);
  $container = new ContainerBuilder();
  $container->set('config.factory', $configFactory);
  \Drupal::setContainer($container);
}

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