public function MergeTermsTest::validatesSelectedTerms in Term Merge 8
Checks the form validation for the merge terms form.
@test
@dataProvider validatesSelectedTermsTestDataProvider
Parameters
array $selectedTerms: The selected term ids.
bool $expectingErrors: If a validation error is expected.
File
- tests/
src/ Kernel/ Form/ MergeTermsTest.php, line 108
Class
- MergeTermsTest
- Tests the term merge form.
Namespace
Drupal\Tests\term_merge\Kernel\FormCode
public function validatesSelectedTerms(array $selectedTerms, $expectingErrors) {
$vocabulary = $this
->createVocabulary();
$this
->createTerm($vocabulary);
$this
->createTerm($vocabulary);
$this
->createTerm($vocabulary);
$sut = $this
->createSubjectUnderTest();
$formState = new FormState();
$formState
->setValue('terms', $selectedTerms);
$form = $sut
->buildForm([], $formState, $vocabulary);
$sut
->validateForm($form, $formState);
self::assertSame($expectingErrors, !empty($formState
->getErrors()));
}