Commit 0aa52f7e authored by alexpott's avatar alexpott

Issue #2850353 by timmillwood, Pavan B S, Sam152: Test content_moderation with...

Issue #2850353 by timmillwood, Pavan B S, Sam152: Test content_moderation with a non-bundleable content entity
parent 73b750b2
......@@ -53,6 +53,7 @@ protected function setUp() {
$this->installEntitySchema('user');
$this->installEntitySchema('entity_test_with_bundle');
$this->installEntitySchema('entity_test_rev');
$this->installEntitySchema('entity_test_no_bundle');
$this->installEntitySchema('entity_test_mulrevpub');
$this->installEntitySchema('block_content');
$this->installEntitySchema('content_moderation_state');
......@@ -178,7 +179,10 @@ public function basicModerationTestCases() {
],
'Entity Test with revisions' => [
'entity_test_rev',
]
],
'Entity without bundle' => [
'entity_test_no_bundle',
],
];
}
......@@ -400,6 +404,7 @@ public function testWorkflowDependencies() {
// Test both a config and non-config based bundle and entity type.
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev');
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_no_bundle', 'entity_test_no_bundle');
$workflow->save();
$this->assertEquals([
......@@ -412,9 +417,11 @@ public function testWorkflowDependencies() {
],
], $workflow->getDependencies());
$entity_types = $workflow->getTypePlugin()->getEntityTypes();
$this->assertTrue(in_array('node', $entity_types));
$this->assertTrue(in_array('entity_test_rev', $entity_types));
$this->assertEquals([
'entity_test_no_bundle',
'entity_test_rev',
'node'
], $workflow->getTypePlugin()->getEntityTypes());
// Delete the node type and ensure it is removed from the workflow.
$node_type->delete();
......@@ -426,7 +433,7 @@ public function testWorkflowDependencies() {
$this->container->get('config.manager')->uninstall('module', 'entity_test');
$workflow = Workflow::load('editorial');
$entity_types = $workflow->getTypePlugin()->getEntityTypes();
$this->assertFalse(in_array('entity_test_rev', $entity_types));
$this->assertEquals([], $entity_types);
}
/**
......
<?php
namespace Drupal\entity_test\Entity;
/**
* Test entity class with no bundle.
*
* @ContentEntityType(
* id = "entity_test_no_bundle",
* label = @Translation("Entity Test without bundle"),
* base_table = "entity_test_no_bundle",
* entity_keys = {
* "id" = "id",
* "revision" = "revision_id",
* },
* admin_permission = "administer entity_test content",
* links = {
* "add-form" = "/entity_test_no_bundle/add",
* },
* )
*/
class EntityTestNoBundle extends EntityTest {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment