You are here

public function CredentialTestCheckTest::testCredentialTestCheck in CloudFlare 8

Tests that CredentialTestCheck Responds as expected with test purge rates.

@dataProvider credentialCheckProvider

@covers \Drupal\cloudflarepurger\Plugin\Purge\DiagnosticCheck\CredentialCheck

Parameters

int $cred_status: The current API rate to test.

int $expected_severity: The expected diagnostic severity.

File

modules/cloudflarepurger/tests/src/Unit/CredentialTestCheckTest.php, line 27

Class

CredentialTestCheckTest
Tests that purge_requirements() passes on our diagnostic checks.

Namespace

Drupal\Tests\cloudflarepurger\Unit

Code

public function testCredentialTestCheck($cred_status, $expected_severity) {
  $config_factory = $this
    ->createMock('\\Drupal\\Core\\Config\\ConfigFactoryInterface');
  $config = $this
    ->getMockBuilder('Drupal\\Core\\Config\\Config')
    ->disableOriginalConstructor()
    ->getMock();
  $config
    ->expects($this
    ->atLeastOnce())
    ->method('get')
    ->with('valid_credentials')
    ->will($this
    ->returnValue($cred_status));
  $config_factory
    ->expects($this
    ->once())
    ->method('get')
    ->will($this
    ->returnValue($config));
  $credential_check = new CredentialCheck([], '23123', 'this is a definition', $config_factory);
  $actual_severity = $credential_check
    ->run();
  $this
    ->assertEquals($expected_severity, $actual_severity);
}