class ConditionPluginBaseTest
Tests Drupal\Core\Condition\ConditionPluginBase.
Attributes
#[CoversClass(ConditionPluginBase::class)]
#[Group('Condition')]
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\Core\Condition\ConditionPluginBaseTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of ConditionPluginBaseTest
File
-
core/
tests/ Drupal/ Tests/ Core/ Condition/ ConditionPluginBaseTest.php, line 17
Namespace
Drupal\Tests\Core\ConditionView source
class ConditionPluginBaseTest extends UnitTestCase {
/**
* Tests that the negate form value is cast to a boolean on validation.
*/
public function testValidateConfigurationForm(mixed $value, bool $expected) : void {
$condition = new TestConditionPluginBase([], '', '');
$form = [];
$form_state = new FormState();
$form_state->setValue('negate', $value);
$condition->validateConfigurationForm($form, $form_state);
$this->assertSame($expected, $form_state->getValue('negate'));
}
/**
* Data provider for testValidateConfigurationForm().
*/
public static function providerTestValidateConfigurationForm() : \Iterator {
yield 'unchecked checkbox' => [
0,
FALSE,
];
yield 'checked checkbox' => [
1,
TRUE,
];
yield 'unchecked checkbox as string' => [
'0',
FALSE,
];
yield 'checked checkbox as string' => [
'1',
TRUE,
];
yield 'empty string' => [
'',
FALSE,
];
yield 'boolean false' => [
FALSE,
FALSE,
];
yield 'boolean true' => [
TRUE,
TRUE,
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.