summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Rowlands2017-10-10 07:38:44 +1000
committerLee Rowlands2017-10-10 07:38:44 +1000
commit581984949d8726e9df8ea2f0697c4abb2e7523cf (patch)
tree9deccfdca76c3266b80d8ebb2308a2209ae9ccc4
parent0d239c45bcb3f3276bbf4a59f17514239a7e8724 (diff)
Issue #2901478 by Sam152, Jo Fitzgerald, timmillwood: Test ModerationStateWidget::isApplicable with a BaseFieldOverride
-rw-r--r--core/modules/content_moderation/tests/src/Kernel/ModerationStateWidgetTest.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/modules/content_moderation/tests/src/Kernel/ModerationStateWidgetTest.php b/core/modules/content_moderation/tests/src/Kernel/ModerationStateWidgetTest.php
index 76d797d..c40e753 100644
--- a/core/modules/content_moderation/tests/src/Kernel/ModerationStateWidgetTest.php
+++ b/core/modules/content_moderation/tests/src/Kernel/ModerationStateWidgetTest.php
@@ -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 @@ class ModerationStateWidgetTest extends KernelTestBase {
$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));
+ }
+
}