Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / tracker / tests / src / Functional / Views / TrackerTestBase.php
1 <?php
2
3 namespace Drupal\Tests\tracker\Functional\Views;
4
5 use Drupal\comment\Tests\CommentTestTrait;
6 use Drupal\Core\Language\LanguageInterface;
7 use Drupal\Tests\views\Functional\ViewTestBase;
8 use Drupal\views\Tests\ViewTestData;
9 use Drupal\comment\Entity\Comment;
10
11 /**
12  * Base class for all tracker tests.
13  */
14 abstract class TrackerTestBase extends ViewTestBase {
15
16   use CommentTestTrait;
17
18   /**
19    * Modules to enable.
20    *
21    * @var array
22    */
23   public static $modules = ['comment', 'tracker', 'tracker_test_views'];
24
25   /**
26    * The node used for testing.
27    *
28    * @var \Drupal\node\NodeInterface
29    */
30   protected $node;
31
32   /**
33    * The comment used for testing.
34    *
35    * @var \Drupal\comment\CommentInterface
36    */
37   protected $comment;
38
39   protected function setUp($import_test_views = TRUE) {
40     parent::setUp($import_test_views);
41
42     ViewTestData::createTestViews(get_class($this), ['tracker_test_views']);
43
44     $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
45     // Add a comment field.
46     $this->addDefaultCommentField('node', 'page');
47
48     $permissions = ['access comments', 'create page content', 'post comments', 'skip comment approval'];
49     $account = $this->drupalCreateUser($permissions);
50
51     $this->drupalLogin($account);
52
53     $this->node = $this->drupalCreateNode([
54       'title' => $this->randomMachineName(8),
55       'uid' => $account->id(),
56       'status' => 1,
57     ]);
58
59     $this->comment = Comment::create([
60       'entity_id' => $this->node->id(),
61       'entity_type' => 'node',
62       'field_name' => 'comment',
63       'subject' => $this->randomMachineName(),
64       'comment_body[' . LanguageInterface::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomMachineName(20),
65     ]);
66
67   }
68
69 }