Issue #2850353 by timmillwood, Pavan B S, Sam152: Test content_moderation with a non-bundleable content entity

8.4.x
Alex Pott 2017-04-14 07:59:40 +01:00
parent 73b750b27c
commit 0aa52f7e7a
2 changed files with 36 additions and 5 deletions

View File

@ -53,6 +53,7 @@ class ContentModerationStateTest extends KernelTestBase {
$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 @@ class ContentModerationStateTest extends KernelTestBase {
],
'Entity Test with revisions' => [
'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.
$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 @@ class ContentModerationStateTest extends KernelTestBase {
],
], $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 @@ class ContentModerationStateTest extends KernelTestBase {
$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);
}
/**

View File

@ -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 {
}