class RowEntityTest
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Kernel/Plugin/RowEntityTest.php \Drupal\Tests\views\Kernel\Plugin\RowEntityTest
Tests the generic entity row plugin.
@group views
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\views\Kernel\Plugin\RowEntityTest implements \Drupal\Tests\views\Kernel\ViewsKernelTestBase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of RowEntityTest
See also
\Drupal\views\Plugin\views\row\EntityRow
File
-
core/
modules/ views/ tests/ src/ Kernel/ Plugin/ RowEntityTest.php, line 17
Namespace
Drupal\Tests\views\Kernel\PluginView source
class RowEntityTest extends ViewsKernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'taxonomy',
'text',
'filter',
'field',
'system',
'node',
'user',
];
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_entity_row',
];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) : void {
parent::setUp();
$this->installEntitySchema('taxonomy_term');
$this->installConfig([
'taxonomy',
]);
}
/**
* Tests the entity row handler.
*/
public function testEntityRow() {
$vocab = Vocabulary::create([
'name' => $this->randomMachineName(),
'vid' => strtolower($this->randomMachineName()),
]);
$vocab->save();
$term = Term::create([
'name' => $this->randomMachineName(),
'vid' => $vocab->id(),
]);
$term->save();
$view = Views::getView('test_entity_row');
$build = $view->preview();
$this->render($build);
$this->assertText($term->getName(), 'The rendered entity appears as row in the view.');
// Tests the available view mode options.
$form = [];
$form_state = new FormState();
$form_state->set('view', $view->storage);
$view->rowPlugin
->buildOptionsForm($form, $form_state);
$this->assertTrue(isset($form['view_mode']['#options']['default']), 'Ensure that the default view mode is available');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.