public function TransitionManagerTest::testValidate in Lightning Workflow 8.3
Same name and namespace in other branches
- 8.2 modules/lightning_scheduler/tests/src/Kernel/TransitionManagerTest.php \Drupal\Tests\lightning_scheduler\Kernel\TransitionManagerTest::testValidate()
@covers ::validate
@dataProvider providerValidate
File
- modules/
lightning_scheduler/ tests/ src/ Kernel/ TransitionManagerTest.php, line 35
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);
}
}