comparison core/modules/comment/tests/src/Functional/CommentPreviewTest.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
137 137
138 $edit = []; 138 $edit = [];
139 $date = new DrupalDateTime('2008-03-02 17:23'); 139 $date = new DrupalDateTime('2008-03-02 17:23');
140 $edit['subject[0][value]'] = $this->randomMachineName(8); 140 $edit['subject[0][value]'] = $this->randomMachineName(8);
141 $edit['comment_body[0][value]'] = $this->randomMachineName(16); 141 $edit['comment_body[0][value]'] = $this->randomMachineName(16);
142 $edit['uid'] = $web_user->getUsername() . ' (' . $web_user->id() . ')'; 142 $edit['uid'] = $web_user->getAccountName() . ' (' . $web_user->id() . ')';
143 $edit['date[date]'] = $date->format('Y-m-d'); 143 $edit['date[date]'] = $date->format('Y-m-d');
144 $edit['date[time]'] = $date->format('H:i:s'); 144 $edit['date[time]'] = $date->format('H:i:s');
145 $raw_date = $date->getTimestamp(); 145 $raw_date = $date->getTimestamp();
146 $expected_text_date = format_date($raw_date); 146 $expected_text_date = $this->container->get('date.formatter')->format($raw_date);
147 $expected_form_date = $date->format('Y-m-d'); 147 $expected_form_date = $date->format('Y-m-d');
148 $expected_form_time = $date->format('H:i:s'); 148 $expected_form_time = $date->format('H:i:s');
149 $comment = $this->postComment($this->node, $edit['subject[0][value]'], $edit['comment_body[0][value]'], TRUE); 149 $comment = $this->postComment($this->node, $edit['subject[0][value]'], $edit['comment_body[0][value]'], TRUE);
150 $this->drupalPostForm('comment/' . $comment->id() . '/edit', $edit, t('Preview')); 150 $this->drupalPostForm('comment/' . $comment->id() . '/edit', $edit, t('Preview'));
151 151
152 // Check that the preview is displaying the subject, comment, author and date correctly. 152 // Check that the preview is displaying the subject, comment, author and date correctly.
153 $this->assertTitle(t('Preview comment | Drupal'), 'Page title is "Preview comment".'); 153 $this->assertTitle(t('Preview comment | Drupal'), 'Page title is "Preview comment".');
154 $this->assertText($edit['subject[0][value]'], 'Subject displayed.'); 154 $this->assertText($edit['subject[0][value]'], 'Subject displayed.');
155 $this->assertText($edit['comment_body[0][value]'], 'Comment displayed.'); 155 $this->assertText($edit['comment_body[0][value]'], 'Comment displayed.');
156 $this->assertText($web_user->getUsername(), 'Author displayed.'); 156 $this->assertText($web_user->getAccountName(), 'Author displayed.');
157 $this->assertText($expected_text_date, 'Date displayed.'); 157 $this->assertText($expected_text_date, 'Date displayed.');
158 158
159 // Check that the subject, comment, author and date fields are displayed with the correct values. 159 // Check that the subject, comment, author and date fields are displayed with the correct values.
160 $this->assertFieldByName('subject[0][value]', $edit['subject[0][value]'], 'Subject field displayed.'); 160 $this->assertFieldByName('subject[0][value]', $edit['subject[0][value]'], 'Subject field displayed.');
161 $this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.'); 161 $this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.');