function FileReferencesDeprecationTest::testFileReferences
Same name and namespace in other branches
- 11.x core/modules/file/tests/src/Kernel/FileReferencesDeprecationTest.php \Drupal\Tests\file\Kernel\FileReferencesDeprecationTest::testFileReferences()
Tests basic file reference cases.
File
-
core/
modules/ file/ tests/ src/ Kernel/ FileReferencesDeprecationTest.php, line 29
Class
Namespace
Drupal\Tests\file\KernelCode
public function testFileReferences() : void {
$this->expectUserDeprecationMessage('file_get_file_references is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \\Drupal::service(\\Drupal\\file\\FileReferenceResolver::class)->getReferences($file) instead. See https://www.drupal.org/node/3573884');
$this->expectUserDeprecationMessage('file_field_find_file_reference_column is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. There is no replacement. See https://www.drupal.org/node/3573884');
$this->enableModules([
'node',
]);
$this->installEntitySchema('node');
$this->installSchema('node', [
'node_access',
]);
NodeType::create([
'type' => 'page',
'name' => 'Page',
])->save();
// Create a file field attached to 'page' node-type.
FieldStorageConfig::create([
'type' => 'file',
'entity_type' => 'node',
'field_name' => 'field_file',
])->save();
FieldConfig::create([
'entity_type' => 'node',
'bundle' => 'page',
'field_name' => 'field_file',
'label' => 'File',
])->save();
// Create a node, attach a file and add a Romanian translation.
$node = Node::create([
'type' => 'page',
'title' => 'Page',
]);
$node->set('field_file', $file = $this->createFile())
->save();
$node = Node::load($node->id());
$this->assertEquals([
'field_file' => [
'node' => [
$node->id() => $node,
],
],
], file_get_file_references($file));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.