You are here

protected function WardenManagerTest::expectConfigFactoryAccess in Warden 8

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/Service/WardenManagerTest.php \Drupal\Tests\warden\Unit\Service\WardenManagerTest::expectConfigFactoryAccess()
  2. 3.x tests/src/Unit/Service/WardenManagerTest.php \Drupal\Tests\warden\Unit\Service\WardenManagerTest::expectConfigFactoryAccess()

Expect access to the config factory via the WardenManager constructor.

1 call to WardenManagerTest::expectConfigFactoryAccess()
WardenManagerTest::setUp in tests/src/Unit/Service/WardenManagerTest.php

File

tests/src/Unit/Service/WardenManagerTest.php, line 60

Class

WardenManagerTest
@coversDefaultClass \Drupal\warden\Service\WardenManager @group warden

Namespace

Drupal\Tests\warden\Unit\Service

Code

protected function expectConfigFactoryAccess() {
  $wardenConfig = $this
    ->getMock('Drupal\\Core\\Config\\Config', array(), array(), '', FALSE);
  $systemConfig = $this
    ->getMock('Drupal\\Core\\Config\\Config', array(), array(), '', FALSE);
  $this->configFactory
    ->expects($this
    ->any())
    ->method('get')
    ->will($this
    ->returnCallback(function ($setting_name) use ($wardenConfig, $systemConfig) {
    $settings = [
      'warden.settings' => $wardenConfig,
      'system.site' => $systemConfig,
    ];
    return $settings[$setting_name];
  }));
  $systemConfig
    ->expects($this
    ->once())
    ->method('get')
    ->with('name')
    ->willReturn('My Website');
  $wardenConfig
    ->expects($this
    ->any())
    ->method('get')
    ->will($this
    ->returnCallback(function ($setting_name) {
    $settings = [
      'warden_preg_match_contrib' => '{^modules\\/contrib\\/*}',
      'warden_preg_match_custom' => '{^modules\\/custom\\/*}',
      'warden_match_custom' => TRUE,
      'warden_match_contrib' => TRUE,
      'warden_token' => $this->token,
      'warden_server_host_path' => 'http://warden.example.com',
      'warden_http_username' => '',
      'warden_http_password' => '',
      'warden_certificate_path' => '',
    ];
    return $settings[$setting_name];
  }));
}