class SettingsValidatorTest
@covers \Drupal\package_manager\Validator\SettingsValidator @group package_manager @internal
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait
- class \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait, \Drupal\Tests\package_manager\Traits\ComposerStagerTestTrait, \Drupal\Tests\package_manager\Traits\FixtureManipulatorTrait, \Drupal\Tests\package_manager\Traits\FixtureUtilityTrait, \Drupal\package_manager\StatusCheckTrait, \Drupal\Tests\package_manager\Traits\ValidationTestTrait
- class \Drupal\Tests\package_manager\Kernel\SettingsValidatorTest extends \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase
- class \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait, \Drupal\Tests\package_manager\Traits\ComposerStagerTestTrait, \Drupal\Tests\package_manager\Traits\FixtureManipulatorTrait, \Drupal\Tests\package_manager\Traits\FixtureUtilityTrait, \Drupal\package_manager\StatusCheckTrait, \Drupal\Tests\package_manager\Traits\ValidationTestTrait
Expanded class hierarchy of SettingsValidatorTest
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ SettingsValidatorTest.php, line 16
Namespace
Drupal\Tests\package_manager\KernelView source
class SettingsValidatorTest extends PackageManagerKernelTestBase {
/**
* Data provider for testSettingsValidation().
*
* @return mixed[][]
* The test cases.
*/
public static function providerSettingsValidation() : array {
$result = ValidationResult::createError([
t('The <code>update_fetch_with_http_fallback</code> setting must be disabled.'),
]);
return [
'HTTP fallback enabled' => [
TRUE,
[
$result,
],
],
'HTTP fallback disabled' => [
FALSE,
[],
],
];
}
/**
* Tests settings validation before starting an update.
*
* @param bool $setting
* The value of the update_fetch_with_http_fallback setting.
* @param \Drupal\package_manager\ValidationResult[] $expected_results
* The expected validation results.
*
* @dataProvider providerSettingsValidation
*/
public function testSettingsValidation(bool $setting, array $expected_results) : void {
$this->setSetting('update_fetch_with_http_fallback', $setting);
$this->assertStatusCheckResults($expected_results);
$this->assertResults($expected_results, PreCreateEvent::class);
}
/**
* Tests settings validation during pre-apply.
*
* @param bool $setting
* The value of the update_fetch_with_http_fallback setting.
* @param \Drupal\package_manager\ValidationResult[] $expected_results
* The expected validation results.
*
* @dataProvider providerSettingsValidation
*/
public function testSettingsValidationDuringPreApply(bool $setting, array $expected_results) : void {
$this->addEventTestListener(function () use ($setting) : void {
$this->setSetting('update_fetch_with_http_fallback', $setting);
});
$this->assertResults($expected_results, PreApplyEvent::class);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.