BlogTestBase.php in Blog 3.x
File
tests/src/Functional/BlogTestBase.php
View source
<?php
namespace Drupal\Tests\blog\Functional;
use Drupal\Tests\BrowserTestBase;
abstract class BlogTestBase extends BrowserTestBase {
protected $defaultTheme = 'stark';
protected static $modules = [
'blog',
];
protected $blogNodes1, $blogNodes2, $articleNodes1, $articleNodes2;
protected $blogger1, $blogger2, $bloggerNoEntries;
protected function setUp() : void {
parent::setUp();
$this
->createContentType([
'type' => 'article',
]);
$this->blogger1 = $this
->drupalCreateUser([
'create article content',
'create blog_post content',
]);
$this->blogger2 = $this
->drupalCreateUser([
'create article content',
'create blog_post content',
]);
$this->bloggerNoEntries = $this
->drupalCreateUser([
'create blog_post content',
]);
$this->blogNodes1 = [];
$this->blogNodes2 = [];
$this->articleNodes1 = [];
$this->articleNodes2 = [];
for ($i = 0; $i < 10; $i++) {
$node = $this
->createNode([
'type' => 'blog_post',
'title' => $this
->randomMachineName(32),
'uid' => $i % 2 ? $this->blogger1
->id() : $this->blogger2
->id(),
]);
if ($i % 2) {
$this->blogNodes1[$node
->id()] = $node;
}
else {
$this->blogNodes2[$node
->id()] = $node;
}
}
for ($i = 0; $i < 10; $i++) {
$node = $this
->createNode([
'type' => 'article',
'title' => $this
->randomMachineName(32),
'uid' => $i % 2 ? $this->blogger1
->id() : $this->blogger2
->id(),
]);
if ($i % 2) {
$this->articleNodes1[$node
->id()] = $node;
}
else {
$this->articleNodes2[$node
->id()] = $node;
}
}
}
}