You are here

public function CasServerConfigTest::testCasServerGuzzleConnectionOptions in CAS 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/CasServerConfigTest.php \Drupal\Tests\cas\Unit\CasServerConfigTest::testCasServerGuzzleConnectionOptions()

Test getCasServerGuzzleConnectionOptions.

@dataProvider casServerConnectionOptionsDataProvider

File

tests/src/Unit/CasServerConfigTest.php, line 52

Class

CasServerConfigTest
CasServerConfig unit tests.

Namespace

Drupal\Tests\cas\Unit

Code

public function testCasServerGuzzleConnectionOptions($sslVerifyMethod) {
  $configFactory = $this
    ->getConfigFactoryStub([
    'cas.settings' => [
      'server.hostname' => 'example.com',
      'server.protocol' => 'https',
      'server.port' => 443,
      'server.path' => '/cas',
      'server.version' => '1.0',
      'server.verify' => $sslVerifyMethod,
      'server.cert' => 'foo',
      'advanced.connection_timeout' => 30,
    ],
  ]);
  $serverConfig = CasServerConfig::createFromModuleConfig($configFactory
    ->get('cas.settings'));
  switch ($sslVerifyMethod) {
    case CasHelper::CA_CUSTOM:
      $this
        ->assertArrayEquals([
        'verify' => 'foo',
        'timeout' => 30,
      ], $serverConfig
        ->getCasServerGuzzleConnectionOptions());
      break;
    case CasHelper::CA_NONE:
      $this
        ->assertArrayEquals([
        'verify' => FALSE,
        'timeout' => 30,
      ], $serverConfig
        ->getCasServerGuzzleConnectionOptions());
      break;
    default:
      $this
        ->assertArrayEquals([
        'verify' => TRUE,
        'timeout' => 30,
      ], $serverConfig
        ->getCasServerGuzzleConnectionOptions());
      break;
  }
}