protected function SitemapTaxonomyTestBase::createNodeWithTerms in Sitemap 2.0.x
Same name and namespace in other branches
- 8.2 src/Tests/SitemapTaxonomyTestBase.php \Drupal\sitemap\Tests\SitemapTaxonomyTestBase::createNodeWithTerms()
- 8 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.
Throws
\Exception
5 calls to SitemapTaxonomyTestBase::createNodeWithTerms()
- SitemapTaxonomyTermsTest::linkSettingsTest in src/
Tests/ SitemapTaxonomyTermsTest.php - Helper function for testing link settings.
- SitemapTaxonomyTermsTest::testNestedTermLinks in src/
Tests/ SitemapTaxonomyTermsTest.php - Tests the nested term link settings.
- SitemapTaxonomyTermsTest::testNodeCounts in src/
Tests/ SitemapTaxonomyTermsTest.php - Tests appearance of node counts.
- SitemapTaxonomyTermsTest::testTermThreshold in src/
Tests/ SitemapTaxonomyTermsTest.php - Tests the term_threshold setting.
- SitemapTaxonomyTermsTest::testVocabularyDepth in src/
Tests/ SitemapTaxonomyTermsTest.php - Tests vocabulary depth settings.
File
- src/
Tests/ SitemapTaxonomyTestBase.php, line 129
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'));
}