comparison core/modules/tracker/src/Tests/Views/TrackerTestBase.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 <?php
2
3 namespace Drupal\tracker\Tests\Views;
4
5 @trigger_error(__NAMESPACE__ . '\TrackerTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\tracker\Functional\Views\TrackerTestBase', E_USER_DEPRECATED);
6
7 use Drupal\comment\Tests\CommentTestTrait;
8 use Drupal\Core\Language\LanguageInterface;
9 use Drupal\views\Tests\ViewTestBase;
10 use Drupal\views\Tests\ViewTestData;
11 use Drupal\comment\Entity\Comment;
12
13 /**
14 * Base class for all tracker tests.
15 *
16 * @deprecated Scheduled for removal in Drupal 9.0.0.
17 * Use \Drupal\Tests\tracker\Functional\Views\TrackerTestBase instead.
18 */
19 abstract class TrackerTestBase extends ViewTestBase {
20
21 use CommentTestTrait;
22
23 /**
24 * Modules to enable.
25 *
26 * @var array
27 */
28 public static $modules = ['comment', 'tracker', 'tracker_test_views'];
29
30 /**
31 * The node used for testing.
32 *
33 * @var \Drupal\node\NodeInterface
34 */
35 protected $node;
36
37 /**
38 * The comment used for testing.
39 *
40 * @var \Drupal\comment\CommentInterface
41 */
42 protected $comment;
43
44 protected function setUp($import_test_views = TRUE) {
45 parent::setUp($import_test_views);
46
47 ViewTestData::createTestViews(get_class($this), ['tracker_test_views']);
48
49 $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
50 // Add a comment field.
51 $this->addDefaultCommentField('node', 'page');
52
53 $permissions = ['access comments', 'create page content', 'post comments', 'skip comment approval'];
54 $account = $this->drupalCreateUser($permissions);
55
56 $this->drupalLogin($account);
57
58 $this->node = $this->drupalCreateNode([
59 'title' => $this->randomMachineName(8),
60 'uid' => $account->id(),
61 'status' => 1,
62 ]);
63
64 $this->comment = Comment::create([
65 'entity_id' => $this->node->id(),
66 'entity_type' => 'node',
67 'field_name' => 'comment',
68 'subject' => $this->randomMachineName(),
69 'comment_body[' . LanguageInterface::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomMachineName(20),
70 ]);
71
72 }
73
74 }