Chris@16: vocab = $this->createVocabulary(); Chris@16: $this->commentType = CommentType::create([ Chris@16: 'id' => 'taxonomy_comment', Chris@16: 'label' => 'Taxonomy comment', Chris@16: 'description' => '', Chris@16: 'target_entity_type_id' => 'taxonomy_term', Chris@16: ]); Chris@16: $this->commentType->save(); Chris@16: $this->addDefaultCommentField( Chris@16: 'taxonomy_term', Chris@16: $this->vocab->id(), Chris@16: 'field_comment', Chris@16: CommentItemInterface::OPEN, Chris@16: $this->commentType->id() Chris@16: ); Chris@16: } Chris@16: Chris@16: /** Chris@16: * Tests CSS classes on comments. Chris@16: */ Chris@16: public function testEntityChanges() { Chris@16: $this->drupalLogin($this->webUser); Chris@16: // Create a new node. Chris@16: $term = $this->createTerm($this->vocab, ['uid' => $this->webUser->id()]); Chris@16: Chris@16: // Add a comment. Chris@16: /** @var \Drupal\comment\CommentInterface $comment */ Chris@16: $comment = Comment::create([ Chris@16: 'entity_id' => $term->id(), Chris@16: 'entity_type' => 'taxonomy_term', Chris@16: 'field_name' => 'field_comment', Chris@16: 'uid' => $this->webUser->id(), Chris@16: 'status' => CommentInterface::PUBLISHED, Chris@16: 'subject' => $this->randomMachineName(), Chris@16: 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED, Chris@16: 'comment_body' => [LanguageInterface::LANGCODE_NOT_SPECIFIED => [$this->randomMachineName()]], Chris@16: ]); Chris@16: $comment->save(); Chris@16: Chris@16: // Request the node with the comment. Chris@16: $this->drupalGet('taxonomy/term/' . $term->id()); Chris@16: $settings = $this->getDrupalSettings(); Chris@16: $this->assertFalse(isset($settings['ajaxPageState']['libraries']) && in_array('comment/drupal.comment-new-indicator', explode(',', $settings['ajaxPageState']['libraries'])), 'drupal.comment-new-indicator library is present.'); Chris@16: $this->assertFalse(isset($settings['history']['lastReadTimestamps']) && in_array($term->id(), array_keys($settings['history']['lastReadTimestamps'])), 'history.lastReadTimestamps is present.'); Chris@16: } Chris@16: Chris@16: }