protected function SitemapTaxonomyTestBase::createNodeWithTerms in Sitemap 8
Same name and namespace in other branches
- 8.2 src/Tests/SitemapTaxonomyTestBase.php \Drupal\sitemap\Tests\SitemapTaxonomyTestBase::createNodeWithTerms()
- 2.0.x src/Tests/SitemapTaxonomyTestBase.php \Drupal\sitemap\Tests\SitemapTaxonomyTestBase::createNodeWithTerms()
Create node and assign tags to it.
Parameters
array $terms: An array of taxonomy terms to apply to the node.
2 calls to SitemapTaxonomyTestBase::createNodeWithTerms()
- SitemapTaxonomyTermsTest::testNodeCounts in src/
Tests/ SitemapTaxonomyTermsTest.php - Tests appearance of node counts.
- SitemapTaxonomyTermsTest::testTermThreshold in src/
Tests/ SitemapTaxonomyTermsTest.php - Tests the term_threshold setting.
File
- src/
Tests/ SitemapTaxonomyTestBase.php, line 118
Class
- SitemapTaxonomyTestBase
- Base class for some Sitemap test cases.
Namespace
Drupal\sitemap\TestsCode
protected function createNodeWithTerms(array $terms = []) {
if (empty($terms)) {
$this->terms = $this
->createTerms($this->vocabulary);
}
// Add an entityreference field to a node bundle.
$this
->addEntityreferenceField();
$values = [];
foreach ($terms as $term) {
$values[] = $term
->getName();
}
$title = $this
->randomString();
$edit = [
'title[0][value]' => $title,
$this->fieldTagsName . '[target_id]' => implode(',', $values),
];
$this
->drupalPostForm('node/add/article', $edit, t('Save'));
}