class ViewsDataIntegrationTest
Same name and namespace in other branches
- 11.x core/modules/content_moderation/tests/src/Kernel/ViewsDataIntegrationTest.php \Drupal\Tests\content_moderation\Kernel\ViewsDataIntegrationTest
Tests the views integration of content_moderation.
@group content_moderation
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\content_moderation\Kernel\ViewsDataIntegrationTest uses \Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait 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 ViewsDataIntegrationTest
File
-
core/
modules/ content_moderation/ tests/ src/ Kernel/ ViewsDataIntegrationTest.php, line 16
Namespace
Drupal\Tests\content_moderation\KernelView source
class ViewsDataIntegrationTest extends ViewsKernelTestBase {
use ContentModerationTestTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'content_moderation_test_views',
'node',
'content_moderation',
'workflows',
'entity_test',
];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) : void {
parent::setUp($import_test_views);
$this->installEntitySchema('node');
$this->installEntitySchema('entity_test_mulrevpub');
$this->installEntitySchema('user');
$this->installEntitySchema('content_moderation_state');
$this->installSchema('node', 'node_access');
$this->installConfig('content_moderation');
$node_type = NodeType::create([
'type' => 'page',
]);
$node_type->save();
$workflow = $this->createEditorialWorkflow();
$workflow->getTypePlugin()
->addEntityTypeAndBundle('node', 'page');
$workflow->getTypePlugin()
->addEntityTypeAndBundle('entity_test_mulrevpub', 'entity_test_mulrevpub');
$workflow->save();
$this->installConfig('content_moderation_test_views');
}
/**
* Tests the content moderation state views field.
*/
public function testContentModerationStateField() {
$node = Node::create([
'type' => 'page',
'title' => 'Test title',
]);
$node->moderation_state->value = 'published';
$node->save();
$view = Views::getView('test_content_moderation_field_state_test');
$view->execute();
$expected_result = [
[
'title' => 'Test title',
'moderation_state' => 'published',
],
];
$this->assertIdenticalResultset($view, $expected_result, [
'title' => 'title',
'moderation_state' => 'moderation_state',
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.