public function ReferenceWidgetTest::testIsApplicable in Select (or other) 8.3
Same name and namespace in other branches
- 8 tests/src/Unit/ReferenceWidgetTest.php \Drupal\Tests\select_or_other\Unit\ReferenceWidgetTest::testIsApplicable()
- 4.x tests/src/Unit/ReferenceWidgetTest.php \Drupal\Tests\select_or_other\Unit\ReferenceWidgetTest::testIsApplicable()
Tests if the widget correctly determines if it is applicable.
File
- Tests/
src/ Unit/ ReferenceWidgetTest.php, line 225
Class
- ReferenceWidgetTest
- Tests the form element implementation.
Namespace
Drupal\Tests\select_or_other\UnitCode
public function testIsApplicable() {
$entityReferenceSelection = $this
->getMockBuilder('Drupal\\Core\\Entity\\EntityReferenceSelection\\SelectionPluginManager')
->disableOriginalConstructor()
->getMock();
$entityReferenceSelection
->expects($this
->exactly(2))
->method('getInstance')
->willReturnOnConsecutiveCalls($this
->getMockForAbstractClass('Drupal\\Core\\Entity\\EntityReferenceSelection\\SelectionInterface'), $this
->getMockForAbstractClass('Drupal\\Core\\Entity\\EntityReferenceSelection\\SelectionWithAutocreateInterface'));
$this->containerMock
->expects($this
->any())
->method('get')
->with('plugin.manager.entity_reference_selection')
->willReturn($entityReferenceSelection);
$definition = $this
->getMockBuilder('Drupal\\Core\\Field\\FieldDefinitionInterface')
->getMockForAbstractClass();
$definition
->expects($this
->exactly(2))
->method('getSettings')
->willReturn([
'handler_settings' => [
'auto_create' => TRUE,
],
]);
/** @var \Drupal\Core\Field\FieldDefinitionInterface $definition */
$this
->assertFalse(ReferenceWidget::isApplicable($definition));
$this
->assertTrue(ReferenceWidget::isApplicable($definition));
}