Verified Commit e4a77089 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...

Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault plugin doesn't add cache tags

(cherry picked from commit 6d3cdb77)
parent d3adef26
Loading
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -197,6 +197,19 @@ public function getArgument() {
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {
    $tags = parent::getCacheTags();
    if (!empty($this->options['node'])) {
      if (($node = $this->routeMatch->getParameter('node')) && $node instanceof NodeInterface) {
        $tags = Cache::mergeTags($tags, $node->getCacheTags());
      }
    }
    return $tags;
  }

  /**
   * {@inheritdoc}
   */
+3 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ public function testNodePath() {

    $expected = implode(',', [$this->term1->id(), $this->term2->id()]);
    $this->assertEquals($expected, $view->argument['tid']->getDefaultArgument());
    $this->assertEquals($this->nodes[0]->getCacheTags(), $view->argument['tid']->getPlugin('argument_default')->getCacheTags());
    $view->destroy();
  }

@@ -83,6 +84,7 @@ public function testNodePathWithViewSelection() {

    $expected = implode(',', [$this->term1->id(), $this->term2->id()]);
    $this->assertEquals($expected, $view->argument['tid']->getDefaultArgument());
    $this->assertEquals($this->nodes[0]->getCacheTags(), $view->argument['tid']->getPlugin('argument_default')->getCacheTags());
  }

  public function testTermPath() {
@@ -90,6 +92,7 @@ public function testTermPath() {

    $expected = $this->term1->id();
    $this->assertEquals($expected, $view->argument['tid']->getDefaultArgument());
    $this->assertEmpty($view->argument['tid']->getPlugin('argument_default')->getCacheTags());
  }

}