$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);
$this->
assertSameSize($upload_files_node_creation,
$node->
{$field_name}, 'Node was successfully saved with multiple files.'
);
// Try to upload exactly the allowed number of files on revision.
$this->
uploadNodeFile($test_file,
$field_name,
$node->
id(), 1
);
$node =
$node_storage->
loadUnchanged($nid);
$this->
assertCount($cardinality,
$node->
{$field_name}, 'Node was successfully revised to maximum number of files.'
);
// Try to upload exactly the allowed number of files, new node.
$upload_files =
[$test_file,
$test_file,
$test_file];
$nid =
$this->
uploadNodeFiles($upload_files,
$field_name,
$type_name, TRUE,
[]);