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