You are here

public function ContentLoaderTest::testPopulateFieldCardinalityTooMuchData in YAML Content 8

@covers ::populateField

File

tests/src/Unit/ContentLoader/ContentLoaderTest.php, line 112

Class

ContentLoaderTest
Test generic functionality of the ContentLoader class.

Namespace

Drupal\Tests\yaml_content\Unit\ContentLoader

Code

public function testPopulateFieldCardinalityTooMuchData() {
  $field_definition = new BaseFieldDefinition();
  $field_definition
    ->setCardinality(1);
  $field = new FieldItemList($field_definition, 'foobar');
  $field_data = [
    [],
    [],
    [],
  ];
  $this
    ->expectException(\InvalidArgumentException::class);
  $this
    ->expectExceptionMessage("'foobar' cannot hold more than 1 values. 3 values were parsed from the YAML file.");
  $this->contentLoader
    ->populateField($field, $field_data);
}