function RedirectUITest::createTerm in Redirect 8
Returns a new term with random properties in vocabulary $vid.
1 call to RedirectUITest::createTerm()
- RedirectUITest::testAutomaticRedirects in tests/
src/ Functional/ RedirectUITest.php - Tests redirects being automatically created upon path alias change.
File
- tests/
src/ Functional/ RedirectUITest.php, line 210
Class
- RedirectUITest
- UI tests for redirect module.
Namespace
Drupal\Tests\redirect\FunctionalCode
function createTerm($vocabulary) {
$filter_formats = filter_formats();
$format = array_pop($filter_formats);
$term = Term::create([
'name' => $this
->randomMachineName(),
'description' => [
'value' => $this
->randomMachineName(),
// Use the first available text format.
'format' => $format
->id(),
],
'vid' => $vocabulary
->id(),
'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'path' => [
'alias' => '/term_test_alias',
],
]);
$term
->save();
return $term;
}