Issue #2850353 by timmillwood, Pavan B S, Sam152: Test content_moderation with a non-bundleable content entity
parent
73b750b27c
commit
0aa52f7e7a
|
@ -53,6 +53,7 @@ class ContentModerationStateTest extends KernelTestBase {
|
||||||
$this->installEntitySchema('user');
|
$this->installEntitySchema('user');
|
||||||
$this->installEntitySchema('entity_test_with_bundle');
|
$this->installEntitySchema('entity_test_with_bundle');
|
||||||
$this->installEntitySchema('entity_test_rev');
|
$this->installEntitySchema('entity_test_rev');
|
||||||
|
$this->installEntitySchema('entity_test_no_bundle');
|
||||||
$this->installEntitySchema('entity_test_mulrevpub');
|
$this->installEntitySchema('entity_test_mulrevpub');
|
||||||
$this->installEntitySchema('block_content');
|
$this->installEntitySchema('block_content');
|
||||||
$this->installEntitySchema('content_moderation_state');
|
$this->installEntitySchema('content_moderation_state');
|
||||||
|
@ -178,7 +179,10 @@ class ContentModerationStateTest extends KernelTestBase {
|
||||||
],
|
],
|
||||||
'Entity Test with revisions' => [
|
'Entity Test with revisions' => [
|
||||||
'entity_test_rev',
|
'entity_test_rev',
|
||||||
]
|
],
|
||||||
|
'Entity without bundle' => [
|
||||||
|
'entity_test_no_bundle',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,6 +404,7 @@ class ContentModerationStateTest extends KernelTestBase {
|
||||||
// Test both a config and non-config based bundle and entity type.
|
// Test both a config and non-config based bundle and entity type.
|
||||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
$workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example');
|
||||||
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev');
|
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_rev', 'entity_test_rev');
|
||||||
|
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_no_bundle', 'entity_test_no_bundle');
|
||||||
$workflow->save();
|
$workflow->save();
|
||||||
|
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
|
@ -412,9 +417,11 @@ class ContentModerationStateTest extends KernelTestBase {
|
||||||
],
|
],
|
||||||
], $workflow->getDependencies());
|
], $workflow->getDependencies());
|
||||||
|
|
||||||
$entity_types = $workflow->getTypePlugin()->getEntityTypes();
|
$this->assertEquals([
|
||||||
$this->assertTrue(in_array('node', $entity_types));
|
'entity_test_no_bundle',
|
||||||
$this->assertTrue(in_array('entity_test_rev', $entity_types));
|
'entity_test_rev',
|
||||||
|
'node'
|
||||||
|
], $workflow->getTypePlugin()->getEntityTypes());
|
||||||
|
|
||||||
// Delete the node type and ensure it is removed from the workflow.
|
// Delete the node type and ensure it is removed from the workflow.
|
||||||
$node_type->delete();
|
$node_type->delete();
|
||||||
|
@ -426,7 +433,7 @@ class ContentModerationStateTest extends KernelTestBase {
|
||||||
$this->container->get('config.manager')->uninstall('module', 'entity_test');
|
$this->container->get('config.manager')->uninstall('module', 'entity_test');
|
||||||
$workflow = Workflow::load('editorial');
|
$workflow = Workflow::load('editorial');
|
||||||
$entity_types = $workflow->getTypePlugin()->getEntityTypes();
|
$entity_types = $workflow->getTypePlugin()->getEntityTypes();
|
||||||
$this->assertFalse(in_array('entity_test_rev', $entity_types));
|
$this->assertEquals([], $entity_types);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?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 {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue