$this->
assertEmpty($node->
{$field_name}->target_id, 'Node was successfully saved without any files.'
);
// Try to upload more files than allowed on revision.
$upload_files_node_revision =
[$test_file,
$test_file,
$test_file,
$test_file];
foreach ($upload_files_node_revision as $i =>
$file) { $edit['files[test_file_field_1_0][' .
$i . ']'
] = \Drupal::
service('file_system'
)->
realpath($test_file->
getFileUri());
} // @todo: Replace after https://www.drupal.org/project/drupal/issues/2917885
$this->
drupalGet('node/' .
$node->
id() . '/edit'
);
$this->
assertSession()->
fieldExists('files[test_file_field_1_0][]'
);
$submit_xpath =
$this->
assertSession()->
buttonExists('Save'
)->
getXpath();
$client =
$this->
getSession()->
getDriver()->
getClient();
$form =
$client->
getCrawler()->
filterXPath($submit_xpath)->
form();
$client->
request($form->
getMethod(),
$form->
getUri(),
$form->
getPhpValues(),
$edit);
$node =
$node_storage->
loadUnchanged($nid);
$this->
assertCount($cardinality,
$node->
{$field_name}, 'More files than allowed could not be saved to node.'
);
$upload_files_node_creation =
[$test_file,
$test_file];
// Try to upload multiple files, but fewer than the maximum.
$nid =
$this->
uploadNodeFiles($upload_files_node_creation,
$field_name,
$type_name, TRUE,
[]);
$node =
$node_storage->
loadUnchanged($nid);