public function TransitionManagerTest::testValidate in Lightning Scheduler 8
@covers ::validate
@dataProvider providerValidate
File
- tests/
src/ Kernel/ TransitionManagerTest.php, line 33
Class
- TransitionManagerTest
- @coversDefaultClass \Drupal\lightning_scheduler\TransitionManager
Namespace
Drupal\Tests\lightning_scheduler\KernelCode
public function testValidate($value, $expected_error = NULL) {
$element = [
'#value' => Json::encode($value),
'#name' => 'test_element',
'#parents' => [
'test_element',
],
];
$form_state = new FormState();
$form_state
->setFormObject($this
->prophesize(FormInterface::class)
->reveal());
TransitionManager::validate($element, $form_state);
$errors = $form_state
->getErrors();
$errors = array_map('strval', $errors);
$errors = array_map('strip_tags', $errors);
if ($expected_error) {
$this
->assertContains($expected_error, $errors);
}
else {
$this
->assertEmpty($errors);
}
}