class CredentialTestCheckTest in CloudFlare 8
Tests that purge_requirements() passes on our diagnostic checks.
@group cloudflarepurger
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\cloudflarepurger\Unit\DiagnosticCheckTestBase
- class \Drupal\Tests\cloudflarepurger\Unit\CredentialTestCheckTest
- class \Drupal\Tests\cloudflarepurger\Unit\DiagnosticCheckTestBase
Expanded class hierarchy of CredentialTestCheckTest
File
- modules/
cloudflarepurger/ tests/ src/ Unit/ CredentialTestCheckTest.php, line 13
Namespace
Drupal\Tests\cloudflarepurger\UnitView source
class CredentialTestCheckTest extends DiagnosticCheckTestBase {
/**
* Tests that CredentialTestCheck Responds as expected with test purge rates.
*
* @param int $cred_status
* The current API rate to test.
* @param int $expected_severity
* The expected diagnostic severity.
*
* @dataProvider credentialCheckProvider
*
* @covers \Drupal\cloudflarepurger\Plugin\Purge\DiagnosticCheck\CredentialCheck
*/
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);
}
/**
* PhpUnit provider to api rate limits.
*/
public function credentialCheckProvider() {
return [
[
NULL,
DiagnosticCheckInterface::SEVERITY_ERROR,
],
[
TRUE,
DiagnosticCheckInterface::SEVERITY_OK,
],
[
FALSE,
DiagnosticCheckInterface::SEVERITY_ERROR,
],
[
0,
DiagnosticCheckInterface::SEVERITY_ERROR,
],
[
1,
DiagnosticCheckInterface::SEVERITY_OK,
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CredentialTestCheckTest:: |
public | function | PhpUnit provider to api rate limits. | |
CredentialTestCheckTest:: |
public | function | Tests that CredentialTestCheck Responds as expected with test purge rates. | |
DiagnosticCheckTestBase:: |
protected | property | Tracks rate limits associated with CloudFlare Api. | |
DiagnosticCheckTestBase:: |
protected | property | Provides check for composer dependencies. | |
DiagnosticCheckTestBase:: |
protected | property | The dependency injection container. | |
DiagnosticCheckTestBase:: |
protected | property | Tracks Drupal states. | |
DiagnosticCheckTestBase:: |
protected | property | Provides timestamps. | |
DiagnosticCheckTestBase:: |
public | function |
Overrides UnitTestCase:: |
1 |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |