ComposerDependenciesCheckMock.php in CloudFlare 8
File
tests/modules/cloudflare_form_tester/src/Mocks/ComposerDependenciesCheckMock.php
View source
<?php
namespace Drupal\cloudflare_form_tester\Mocks;
use Psr\Log\LoggerInterface;
use Drupal\cloudflare\Exception\ComposerDependencyException;
use Drupal\cloudflare\CloudFlareComposerDependenciesCheckInterface;
class ComposerDependenciesCheckMock implements CloudFlareComposerDependenciesCheckInterface {
public static $areDependenciesMet = NULL;
protected $logger;
public static function create(LoggerInterface $logger) {
return new static($logger);
}
public function __construct(LoggerInterface $logger) {
$this->logger = $logger;
}
public function check() {
$are_dependencies_met = \Drupal::state()
->get('cloudflaretesting.assertComposerDependenciesMet');
if (!$are_dependencies_met) {
$this->logger
->critical(self::ERROR_MESSAGE);
}
return $are_dependencies_met;
}
public function assert() {
if (!$this
->check()) {
throw new ComposerDependencyException(self::ERROR_MESSAGE);
}
}
public static function mockComposerDependenciesMet($are_dependencies_met) {
\Drupal::state()
->set('cloudflaretesting.assertComposerDependenciesMet', $are_dependencies_met);
}
}