public function FileFieldSourcesTestBase::createPermanentFileEntity in FileField Sources 8
Create permanent file entity.
Return value
object Permanent file entity.
4 calls to FileFieldSourcesTestBase::createPermanentFileEntity()
- ImceSourceTest::testImceSourceEnabled in tests/
src/ Functional/ ImceSourceTest.php - Tests imce source enabled.
- MultipleValuesTest::setUp in tests/
src/ Functional/ MultipleValuesTest.php - Sets up for multiple values test case.
- ReferenceSourceTest::testAutocompletion in tests/
src/ Functional/ ReferenceSourceTest.php - Test autocompletion.
- ReferenceSourceTest::testReferenceSourceEnabled in tests/
src/ Functional/ ReferenceSourceTest.php - Tests reference source enabled.
File
- tests/
src/ Functional/ FileFieldSourcesTestBase.php, line 140
Class
- FileFieldSourcesTestBase
- Base class for File Field Sources test cases.
Namespace
Drupal\Tests\filefield_sources\FunctionalCode
public function createPermanentFileEntity() {
$file = $this
->createTemporaryFileEntity();
// Only permanent file can be referred.
$file->status = FILE_STATUS_PERMANENT;
// Author has permission to access file.
$file->uid = $this->adminUser
->id();
$file
->save();
// Permanent file must be used by an entity.
\Drupal::service('file.usage')
->add($file, 'file', 'node', $this->node
->id());
return $file;
}