CredentialTestCheckTest.php in CloudFlare 8
File
modules/cloudflarepurger/tests/src/Unit/CredentialTestCheckTest.php
View source
<?php
namespace Drupal\Tests\cloudflarepurger\Unit;
use Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticCheckInterface;
use Drupal\cloudflarepurger\Plugin\Purge\DiagnosticCheck\CredentialCheck;
class CredentialTestCheckTest extends DiagnosticCheckTestBase {
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);
}
public function credentialCheckProvider() {
return [
[
NULL,
DiagnosticCheckInterface::SEVERITY_ERROR,
],
[
TRUE,
DiagnosticCheckInterface::SEVERITY_OK,
],
[
FALSE,
DiagnosticCheckInterface::SEVERITY_ERROR,
],
[
0,
DiagnosticCheckInterface::SEVERITY_ERROR,
],
[
1,
DiagnosticCheckInterface::SEVERITY_OK,
],
];
}
}