EvaTestBase.php in EVA: Entity Views Attachment 8.2
File
tests/src/Functional/EvaTestBase.php
View source
<?php
namespace Drupal\Tests\eva\Functional;
use Drupal\Tests\BrowserTestBase;
abstract class EvaTestBase extends BrowserTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'eva',
'eva_test',
'node',
'views',
'user',
'text',
];
protected $articleCount = 20;
protected $pageCount = 10;
protected $nids = [];
protected function setUp() {
parent::setUp();
$this
->makeNodes();
}
protected function makeNodes() {
$node = $this
->createNode([
'title' => 'Test Eva',
'type' => 'just_eva',
]);
$this->nids['just_eva'] = $node
->id();
$this->nids['pages'] = [];
for ($i = 0; $i < $this->pageCount; $i++) {
$node = $this
->createNode([
'title' => sprintf('Page %d', $i + 1),
'type' => 'page_with_related_articles',
]);
$this->nids['pages'][] = $node
->id();
}
for ($i = 0; $i < $this->articleCount; $i++) {
$node = $this
->createNode([
'title' => sprintf('Article %d', $i + 1),
'type' => 'mini',
]);
$k = array_rand($this->nids['pages'], 1);
$node->field_page[] = $this->nids['pages'][$k];
$node
->save();
}
}
}