public function testUploadPath() { /** @var \Drupal\node\NodeStorageInterface $node_storage */
$node_storage =
$this->container->
get('entity_type.manager'
)->
getStorage('node'
);
$field_name =
strtolower($this->
randomMachineName());
$type_name = 'article';
$this->
createFileField($field_name, 'node',
$type_name);
/** @var \Drupal\file\FileInterface $test_file */
$test_file =
$this->
getTestFile('text'
);
// Create a new node.
$nid =
$this->
uploadNodeFile($test_file,
$field_name,
$type_name);
// Check that the file was uploaded to the correct location.
$node_storage->
resetCache([$nid]);
$node =
$node_storage->
load($nid);
/** @var \Drupal\file\FileInterface $node_file */
$node_file =
$node->
{$field_name}->entity;
$date_formatter =
$this->container->
get('date.formatter'
);
$expected_filename =
'public://' .
$date_formatter->
format(REQUEST_TIME, 'custom', 'Y'
) . '-' .
$date_formatter->
format(REQUEST_TIME, 'custom', 'm'
) . '/' .