Newer
Older
catch
committed
<?php
namespace Drupal\tracker\Tests\Views;
catch
committed
@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);
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Core\Language\LanguageInterface;
catch
committed
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\comment\Entity\Comment;
catch
committed
/**
* Base class for all tracker tests.
catch
committed
*
* @deprecated Scheduled for removal in Drupal 9.0.0.
* Use \Drupal\Tests\tracker\Functional\Views\TrackerTestBase instead.
catch
committed
*/
abstract class TrackerTestBase extends ViewTestBase {
use CommentTestTrait;
catch
committed
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['comment', 'tracker', 'tracker_test_views'];
catch
committed
/**
* The node used for testing.
*
* @var \Drupal\node\NodeInterface
*/
protected $node;
/**
* The comment used for testing.
*
* @var \Drupal\comment\CommentInterface
*/
protected $comment;
catch
committed
protected function setUp() {
parent::setUp();
ViewTestData::createTestViews(get_class($this), ['tracker_test_views']);
catch
committed
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Add a comment field.
$this->addDefaultCommentField('node', 'page');
catch
committed
$permissions = ['access comments', 'create page content', 'post comments', 'skip comment approval'];
catch
committed
$account = $this->drupalCreateUser($permissions);
$this->drupalLogin($account);
$this->node = $this->drupalCreateNode([
Alex Pott
committed
'title' => $this->randomMachineName(8),
catch
committed
'uid' => $account->id(),
'status' => 1,
]);
catch
committed
$this->comment = Comment::create([
'entity_id' => $this->node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
Alex Pott
committed
'subject' => $this->randomMachineName(),
'comment_body[' . LanguageInterface::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomMachineName(20),
]);