comparison core/modules/comment/tests/src/Functional/CommentNonNodeTest.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 7a779792577d
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
8 use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; 8 use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
9 use Drupal\comment\Tests\CommentTestTrait; 9 use Drupal\comment\Tests\CommentTestTrait;
10 use Drupal\entity_test\Entity\EntityTest; 10 use Drupal\entity_test\Entity\EntityTest;
11 use Drupal\field\Entity\FieldConfig; 11 use Drupal\field\Entity\FieldConfig;
12 use Drupal\field\Entity\FieldStorageConfig; 12 use Drupal\field\Entity\FieldStorageConfig;
13 use Drupal\field_ui\Tests\FieldUiTestTrait;
14 use Drupal\Tests\BrowserTestBase; 13 use Drupal\Tests\BrowserTestBase;
15 use Drupal\Core\Entity\EntityInterface; 14 use Drupal\Core\Entity\EntityInterface;
15 use Drupal\Tests\field_ui\Traits\FieldUiTestTrait;
16 use Drupal\user\RoleInterface; 16 use Drupal\user\RoleInterface;
17 17
18 /** 18 /**
19 * Tests commenting on a test entity. 19 * Tests commenting on a test entity.
20 * 20 *
188 $regex .= '<a id="comment-' . $comment->id() . '"(.*?)'; 188 $regex .= '<a id="comment-' . $comment->id() . '"(.*?)';
189 $regex .= $comment->getSubject() . '(.*?)'; 189 $regex .= $comment->getSubject() . '(.*?)';
190 $regex .= $comment->comment_body->value . '(.*?)'; 190 $regex .= $comment->comment_body->value . '(.*?)';
191 $regex .= '/s'; 191 $regex .= '/s';
192 192
193 return (boolean) preg_match($regex, $this->getRawContent()); 193 return (boolean) preg_match($regex, $this->getSession()->getPage()->getContent());
194 } 194 }
195 else { 195 else {
196 return FALSE; 196 return FALSE;
197 } 197 }
198 } 198 }
202 * 202 *
203 * @return bool 203 * @return bool
204 * Contact info is available. 204 * Contact info is available.
205 */ 205 */
206 public function commentContactInfoAvailable() { 206 public function commentContactInfoAvailable() {
207 return preg_match('/(input).*?(name="name").*?(input).*?(name="mail").*?(input).*?(name="homepage")/s', $this->getRawContent()); 207 return preg_match('/(input).*?(name="name").*?(input).*?(name="mail").*?(input).*?(name="homepage")/s', $this->getSession()->getPage()->getContent());
208 } 208 }
209 209
210 /** 210 /**
211 * Performs the specified operation on the specified comment. 211 * Performs the specified operation on the specified comment.
212 * 212 *
241 * @return int 241 * @return int
242 * Comment ID. 242 * Comment ID.
243 */ 243 */
244 public function getUnapprovedComment($subject) { 244 public function getUnapprovedComment($subject) {
245 $this->drupalGet('admin/content/comment/approval'); 245 $this->drupalGet('admin/content/comment/approval');
246 preg_match('/href="(.*?)#comment-([^"]+)"(.*?)>(' . $subject . ')/', $this->getRawContent(), $match); 246 preg_match('/href="(.*?)#comment-([^"]+)"(.*?)>(' . $subject . ')/', $this->getSession()->getPage()->getContent(), $match);
247 247
248 return $match[2]; 248 return $match[2];
249 } 249 }
250 250
251 /** 251 /**
252 * Tests anonymous comment functionality. 252 * Tests anonymous comment functionality.
253 */ 253 */
254 public function testCommentFunctionality() { 254 public function testCommentFunctionality() {
255 $limited_user = $this->drupalCreateUser([ 255 $limited_user = $this->drupalCreateUser([
256 'administer entity_test fields' 256 'administer entity_test fields',
257 ]); 257 ]);
258 $this->drupalLogin($limited_user); 258 $this->drupalLogin($limited_user);
259 // Test that default field exists. 259 // Test that default field exists.
260 $this->drupalGet('entity_test/structure/entity_test/fields'); 260 $this->drupalGet('entity_test/structure/entity_test/fields');
261 $this->assertText(t('Comments')); 261 $this->assertText(t('Comments'));