You are here

public function FieldItemListTest::testDefaultValuesForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Field/FieldItemListTest.php \Drupal\Tests\Core\Field\FieldItemListTest::testDefaultValuesForm()

@covers ::defaultValuesForm

File

core/tests/Drupal/Tests/Core/Field/FieldItemListTest.php, line 163
Contains \Drupal\Tests\Core\Field\FieldItemListTest.

Class

FieldItemListTest
@coversDefaultClass \Drupal\Core\Field\FieldItemList @group Field

Namespace

Drupal\Tests\Core\Field

Code

public function testDefaultValuesForm() {
  $field_definition = $this
    ->getMock(FieldDefinitionInterface::class);
  $field_definition
    ->expects($this
    ->any())
    ->method('getType')
    ->willReturn('field_type');

  /** @var \Drupal\Core\Field\FieldItemList|\PHPUnit_Framework_MockObject_MockObject $field_list */
  $field_list = $this
    ->getMock(FieldItemList::class, [
    'defaultValueWidget',
  ], [
    $field_definition,
  ]);
  $field_list
    ->expects($this
    ->any())
    ->method('defaultValueWidget')
    ->willReturn(NULL);
  $form = [];
  $form_state = new FormState();
  $string_translation = $this
    ->getStringTranslationStub();
  $field_list
    ->setStringTranslation($string_translation);
  $this
    ->assertEquals('No widget available for: <em class="placeholder">field_type</em>.', $field_list
    ->defaultValuesForm($form, $form_state)['#markup']);
}