/**
  * @covers ::getOptions
  */
 public function testGetOptions()
 {
     $this->pluginDefinition['options'] = array('attributes' => array('class' => array('example')));
     $this->setupLocalTaskDefault();
     $route_match = new RouteMatch('', new Route('/'));
     $this->assertEquals($this->pluginDefinition['options'], $this->localTaskBase->getOptions($route_match));
     $this->localTaskBase->setActive(TRUE);
     $this->assertEquals(array('attributes' => array('class' => array('example', 'active'))), $this->localTaskBase->getOptions($route_match));
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function getCacheTags()
 {
     // @todo https://www.drupal.org/node/2779933 write a test for this.
     $tags = parent::getCacheTags();
     // Tab changes if node or node-type is modified.
     $tags = array_merge($tags, $this->entity->getCacheTags());
     $tags[] = $this->entity->getEntityType()->getBundleEntityType() . ':' . $this->entity->bundle();
     return $tags;
 }
 /**
  * Tests the getOption method.
  *
  * @see \Drupal\Core\Menu\LocalTaskDefault::getOption()
  */
 public function testGetOptions()
 {
     $this->pluginDefinition['options'] = array('attributes' => array('class' => array('example')));
     $this->setupLocalTaskDefault();
     $request = Request::create('/');
     $this->assertEquals($this->pluginDefinition['options'], $this->localTaskBase->getOptions($request));
     $this->localTaskBase->setActive(TRUE);
     $this->assertEquals(array('attributes' => array('class' => array('example', 'active'))), $this->localTaskBase->getOptions($request));
 }
 /**
  * @covers ::getCacheContexts
  * @covers ::getCacheTags
  * @covers ::getCacheMaxAge
  */
 public function testCacheabilityMetadata()
 {
     $this->pluginDefinition['cache_contexts'] = ['route'];
     $this->pluginDefinition['cache_tags'] = ['kitten'];
     $this->pluginDefinition['cache_max_age'] = 3600;
     $this->setupLocalTaskDefault();
     $this->assertEquals(['route'], $this->localTaskBase->getCacheContexts());
     $this->assertEquals(['kitten'], $this->localTaskBase->getCacheTags());
     $this->assertEquals(3600, $this->localTaskBase->getCacheMaxAge());
 }
 /**
  * Construct the UnapprovedComments object.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param array $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\comment\CommentStorageInterface $comment_storage
  *   The comment storage service.
  */
 public function __construct(array $configuration, $plugin_id, array $plugin_definition, CommentStorageInterface $comment_storage)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->commentStorage = $comment_storage;
 }