public function itExportsToXMLWithCrossReferencesEscaped()
 {
     $body = 'See art #290';
     $escaped_body = 'See art # 290';
     $comment = new Tracker_Artifact_Changeset_Comment(1, $this->changeset, 0, 0, 101, $this->timestamp, $body, 'html', 0);
     $xml = '<?xml version="1.0" encoding="UTF-8"?>
             <comments/>';
     $changeset_node = new SimpleXMLElement($xml);
     $comment->exportToXML($changeset_node);
     $this->assertNotNull($changeset_node->comment);
     $this->assertNotNull($changeset_node->comment->submitted_by);
     $this->assertNotNull($changeset_node->comment->submitted_on);
     $this->assertNotNull($changeset_node->comment->body);
     $this->assertEqual((string) $changeset_node->comment->submitted_by, 'ldap_01');
     $this->assertEqual($changeset_node->comment->submitted_by['format'], 'ldap');
     $this->assertEqual((string) $changeset_node->comment->submitted_on, '2015-06-09T17:18:27+02:00');
     $this->assertEqual($changeset_node->comment->submitted_on['format'], 'ISO8601');
     $this->assertEqual((string) $changeset_node->comment->body, $escaped_body);
     $this->assertEqual($changeset_node->comment->body['format'], 'html');
 }
 public function itExportsToXML()
 {
     $user = aUser()->withId(101)->withLdapId('ldap_01')->withUserName('user_01')->build();
     $changeset = aChangeset()->build();
     $timestamp = '1433863107';
     $body = '<b> My comment 01</b>';
     $comment = new Tracker_Artifact_Changeset_Comment(1, $changeset, 0, 0, 101, $timestamp, $body, 'html', 0);
     $xml = '<?xml version="1.0" encoding="UTF-8"?>
             <comments/>';
     $changeset_node = new SimpleXMLElement($xml);
     stub($this->user_manager)->getUserById(101)->returns($user);
     $comment->exportToXML($changeset_node);
     $this->assertNotNull($changeset_node->comment);
     $this->assertNotNull($changeset_node->comment->submitted_by);
     $this->assertNotNull($changeset_node->comment->submitted_on);
     $this->assertNotNull($changeset_node->comment->body);
     $this->assertEqual((string) $changeset_node->comment->submitted_by, 'ldap_01');
     $this->assertEqual($changeset_node->comment->submitted_by['format'], 'ldap');
     $this->assertEqual((string) $changeset_node->comment->submitted_on, '2015-06-09T17:18:27+02:00');
     $this->assertEqual($changeset_node->comment->submitted_on['format'], 'ISO8601');
     $this->assertEqual((string) $changeset_node->comment->body, $body);
     $this->assertEqual($changeset_node->comment->body['format'], 'html');
 }
예제 #3
0
 /**
  * Returns HTML code to display the artifact history
  *
  * @param Codendi_Request $request The data from the user
  *
  * @return String The valid followup comment format
  */
 public function validateCommentFormat($request, $comment_format_field_name)
 {
     $comment_format = $request->get($comment_format_field_name);
     return Tracker_Artifact_Changeset_Comment::checkCommentFormat($comment_format);
 }
 public function __construct(Tracker_Artifact_Changeset $changeset)
 {
     parent::__construct(0, $changeset, 0, 0, $changeset->getSubmittedBy(), $changeset->getSubmittedOn(), '', Tracker_Artifact_Changeset_Comment::TEXT_COMMENT, -1);
 }
 private function storeComment(Tracker_Artifact $artifact, $comment, PFUser $submitter, $submitted_on, $comment_format, $changeset_id)
 {
     $comment_format = Tracker_Artifact_Changeset_Comment::checkCommentFormat($comment_format);
     $comment_added = $this->changeset_comment_dao->createNewVersion($changeset_id, $comment, $submitter->getId(), $submitted_on, 0, $comment_format);
     if (!$comment_added) {
         return false;
     }
     $this->reference_manager->extractCrossRef($comment, $artifact->getId(), Tracker_Artifact::REFERENCE_NATURE, $artifact->getTracker()->getGroupID(), $submitter->getId(), $artifact->getTracker()->getItemName());
     return true;
 }