You are here

protected function SiteMapTestBase::createTerms in Site map 8

Create taxonomy terms.

Parameters

object $vocabulary: Taxonomy vocabulary.

Return value

array List of tags.

4 calls to SiteMapTestBase::createTerms()
SiteMapCategoriesTest::testCategoriesDepth in src/Tests/SiteMapCategoriesTest.php
Tests categories depth.
SiteMapCategoriesTest::testCategoryCountThreshold in src/Tests/SiteMapCategoriesTest.php
Tests category count threshold.
SiteMapRssTest::testIncludeRssLinks in src/Tests/SiteMapRssTest.php
Tests include RSS links.
SiteMapRssTest::testRssFeedDepth in src/Tests/SiteMapRssTest.php
Tests RSS feed depth.

File

src/Tests/SiteMapTestBase.php, line 91

Class

SiteMapTestBase
Base class for Site Map test cases.

Namespace

Drupal\site_map\Tests

Code

protected function createTerms($vocabulary) {
  $terms = array(
    $this
      ->createTerm($vocabulary),
    $this
      ->createTerm($vocabulary),
    $this
      ->createTerm($vocabulary),
  );

  // Make term 2 child of term 1, term 3 child of term 2.
  $edit = array(
    // Term 1.
    'terms[tid:' . $terms[0]
      ->id() . ':0][term][tid]' => $terms[0]
      ->id(),
    'terms[tid:' . $terms[0]
      ->id() . ':0][term][parent]' => 0,
    'terms[tid:' . $terms[0]
      ->id() . ':0][term][depth]' => 0,
    'terms[tid:' . $terms[0]
      ->id() . ':0][weight]' => 0,
    // Term 2.
    'terms[tid:' . $terms[1]
      ->id() . ':0][term][tid]' => $terms[1]
      ->id(),
    'terms[tid:' . $terms[1]
      ->id() . ':0][term][parent]' => $terms[0]
      ->id(),
    'terms[tid:' . $terms[1]
      ->id() . ':0][term][depth]' => 1,
    'terms[tid:' . $terms[1]
      ->id() . ':0][weight]' => 0,
    // Term 3.
    'terms[tid:' . $terms[2]
      ->id() . ':0][term][tid]' => $terms[2]
      ->id(),
    'terms[tid:' . $terms[2]
      ->id() . ':0][term][parent]' => $terms[1]
      ->id(),
    'terms[tid:' . $terms[2]
      ->id() . ':0][term][depth]' => 2,
    'terms[tid:' . $terms[2]
      ->id() . ':0][weight]' => 0,
  );
  $this
    ->drupalPostForm('admin/structure/taxonomy/manage/' . $vocabulary
    ->get('vid') . '/overview', $edit, t('Save'));
  return $terms;
}