You are here

protected function ServiceTestTrait::initializeService in Purge 8.3

Initialize the requested service as $this->$variable (or reload).

Parameters

string $variable: The place to put the loaded/reloaded service, defaults to $this->service.

string $service: The name of the service to load, defaults to $this->serviceId.

16 calls to ServiceTestTrait::initializeService()
ServiceSmokeAndFireTest::testIsSystemOnFireReturnsCheck in tests/src/Kernel/DiagnosticCheck/ServiceSmokeAndFireTest.php
Tests \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::isSystemOnFire()
ServiceSmokeAndFireTest::testIsSystemOnFireReturnsFalse in tests/src/Kernel/DiagnosticCheck/ServiceSmokeAndFireTest.php
Tests \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::isSystemOnFire()
ServiceSmokeAndFireTest::testIsSystemShowingSmokeReturnsFalse in tests/src/Kernel/DiagnosticCheck/ServiceSmokeAndFireTest.php
Tests \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::isSystemShowingSmoke()
ServiceTest::testCount in tests/src/Kernel/Processor/ServiceTest.php
Tests \Drupal\purge\Plugin\Purge\Processor\ProcessorsService::count.
ServiceTest::testCount in tests/src/Kernel/Queuer/ServiceTest.php
Tests \Drupal\purge\Plugin\Purge\Queuer\QueuersService::count.

... See full list

File

tests/src/Traits/ServiceTestTrait.php, line 45

Class

ServiceTestTrait
Properties and methods for services.yml exposed classes.

Namespace

Drupal\Tests\purge\Traits

Code

protected function initializeService($variable = 'service', $service = NULL) : void {
  if (is_null($this->{$variable})) {
    if (is_null($service)) {
      $this->{$variable} = $this->container
        ->get($this->serviceId);
    }
    else {
      $this->{$variable} = $this->container
        ->get($service);
    }
  }
  if ($this->{$variable} instanceof ServiceInterface) {
    $this->{$variable}
      ->reload();
  }
}