public function LegacyForumTest::testGetParents in Drupal 8
Tests the getParents() method.
@expectedDeprecation Drupal\forum\ForumManager::getParents() is deprecated in drupal:8.1.0 and is removed from drupal:9.0.0. Call loadAllParents() on taxonomy term storage directly. See https://www.drupal.org/node/3069599
File
- core/modules/ forum/ tests/ src/ Kernel/ LegacyForumTest.php, line 46 
Class
- LegacyForumTest
- Tests Legacy forum code.
Namespace
Drupal\Tests\forum\KernelCode
public function testGetParents() {
  // Add a forum.
  $forum = $this->termStorage
    ->create([
    'name' => 'Forum',
    'vid' => 'forums',
    'forum_container' => 1,
  ]);
  $forum
    ->save();
  // Add a container.
  $subforum = $this->termStorage
    ->create([
    'name' => 'Subforum',
    'vid' => 'forums',
    'forum_container' => 0,
    'parent' => $forum
      ->id(),
  ]);
  $subforum
    ->save();
  $legacy_parents = \Drupal::service('forum_manager')
    ->getParents($subforum
    ->id());
  $parents = $this->termStorage
    ->loadAllParents($subforum
    ->id());
  $this
    ->assertSame($parents, $legacy_parents);
}