RangeViewsTestBase.php in Range 8
File
tests/src/Functional/Views/RangeViewsTestBase.php
View source
<?php
namespace Drupal\Tests\range\Functional\Views;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\views\Functional\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
abstract class RangeViewsTestBase extends ViewTestBase {
protected $defaultTheme = 'stark';
protected static $modules = [
'range_test',
'node',
'range',
];
protected $entityTypeId = 'node';
protected $bundle = 'test_bundle';
protected $fieldName = 'field_range_integer';
protected $nodes = [];
protected function setUp($import_test_views = TRUE) : void {
parent::setUp();
$node_type = NodeType::create([
'type' => $this->bundle,
'name' => $this->bundle,
]);
$node_type
->save();
$fieldStorage = FieldStorageConfig::create([
'field_name' => $this->fieldName,
'entity_type' => $this->entityTypeId,
'type' => 'range_integer',
]);
$fieldStorage
->save();
$field = FieldConfig::create([
'field_storage' => $fieldStorage,
'bundle' => $this->bundle,
'required' => TRUE,
]);
$field
->save();
$this->container
->get('views.views_data')
->clear();
$this->map = [
'nid' => 'nid',
];
ViewTestData::createTestViews(get_class($this), [
'range_test',
]);
}
}