protected function RateWidgetTest::setUp in Rate 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ RateWidgetTest.php, line 45
Class
- RateWidgetTest
- Tests for the Rate widget.
Namespace
Drupal\Tests\rate\FunctionalCode
protected function setUp() {
parent::setUp();
// Dummy user 1.
$this
->createUser();
// Enable voting on test entities.
$this
->config('rate.settings')
->set('enabled_types_widgets.entity_test', [
'entity_test' => [
'widget_type' => 'number_up_down',
'use_ajax' => FALSE,
],
])
->set('use_ajax', FALSE)
->save();
$display = \Drupal::service('entity_display.repository')
->getViewDisplay('entity_test', 'entity_test', 'default');
$display
->setComponent('rate_vote_widget', [
'weight' => 3,
]);
$display
->save();
// A common role for each user. Using a separate role, which is the default,
// would not provide properly-similar user accounts to test caching.
$role = $this
->createRole([
'access content',
'cast rate vote on entity_test of entity_test',
'view test entity',
]);
foreach (range(1, 2) as $i) {
$this->webUsers[$i] = $this
->createUser();
$this->webUsers[$i]
->addRole($role);
$this->webUsers[$i]
->save();
}
$this->testEntity = EntityTest::create([
'name' => $this
->randomString(),
]);
$this->testEntity
->save();
}