Commit 58198494 authored by larowlan's avatar larowlan

Issue #2901478 by Sam152, Jo Fitzgerald, timmillwood: Test...

Issue #2901478 by Sam152, Jo Fitzgerald, timmillwood: Test ModerationStateWidget::isApplicable with a BaseFieldOverride
parent 0d239c45
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\content_moderation\Kernel;
use Drupal\content_moderation\Plugin\Field\FieldWidget\ModerationStateWidget;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Form\FormState;
use Drupal\KernelTests\KernelTestBase;
......@@ -75,4 +76,17 @@ public function testWidgetNonModeratedEntity() {
$this->assertEquals(0, $entity->moderation_state->count());
}
/**
* @covers ::isApplicable
*/
public function testIsApplicable() {
// The moderation_state field definition should be applicable to our widget.
$fields = $this->container->get('entity_field.manager')->getFieldDefinitions('node', 'test_type');
$this->assertTrue(ModerationStateWidget::isApplicable($fields['moderation_state']));
$this->assertFalse(ModerationStateWidget::isApplicable($fields['status']));
// A config override should still be applicable.
$field_config = $fields['moderation_state']->getConfig('moderated');
$this->assertTrue(ModerationStateWidget::isApplicable($field_config));
}
}
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