You are here

public function LoggingConfigFormTest::setUp in Purge 8.3

Set up the test object.

Parameters

bool $switch_to_memory_queue: Whether to switch the default queue to the memory backend or not.

Overrides FormTestBase::setUp

File

modules/purge_ui/tests/src/Functional/Form/LoggingConfigFormTest.php, line 38

Class

LoggingConfigFormTest
Tests \Drupal\purge_ui\Form\LoggingConfigForm.

Namespace

Drupal\Tests\purge_ui\Functional\Form

Code

public function setUp($switch_to_memory_queue = TRUE) : void {
  parent::setUp($switch_to_memory_queue);
  $defaults = [
    [
      'id' => 'testchannel',
      'grants' => [
        2,
        4,
        1,
      ],
    ],
  ];

  // Set a mocked logger as service.
  $this->purgeLogger = $this
    ->createMock('Drupal\\purge\\Logger\\LoggerServiceInterface');
  $this->purgeLogger
    ->method('getChannels')
    ->willReturn($defaults);
  $this->purgeLogger
    ->method('hasChannel')
    ->will($this
    ->returnCallback(function ($subject) {
    return $subject === 'testchannel';
  }));
  $this->container
    ->set('purge.logger', $this->purgeLogger);
}