function FileFieldTestBase::getLastFileId

Same name in other branches
  1. 9 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::getLastFileId()
  2. 8.9.x core/modules/file/src/Tests/FileFieldTestBase.php \Drupal\file\Tests\FileFieldTestBase::getLastFileId()
  3. 8.9.x core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::getLastFileId()
  4. 11.x core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::getLastFileId()

Retrieves the fid of the last inserted file.

7 calls to FileFieldTestBase::getLastFileId()
FileManagedFileElementTest::testFileNameTrim in core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
Tests file names have leading . removed.
FileManagedFileElementTest::testFileRemovedFromDisk in core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
Ensure a file entity can be saved when the file does not exist on disk.
FileManagedFileElementTest::testManagedFile in core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
Tests the managed_file element type.
FileManagedFileElementTest::testManagedFileRemoved in core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
Ensure that warning is shown if file on the field has been removed.
FileOnTranslatedEntityTest::testFileUsage in core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php
Tests if file field tracks file usages correctly on translated nodes.

... See full list

File

core/modules/file/tests/src/Functional/FileFieldTestBase.php, line 78

Class

FileFieldTestBase
Provides methods specifically for testing File module's field handling.

Namespace

Drupal\Tests\file\Functional

Code

public function getLastFileId() {
    return (int) \Drupal::entityQueryAggregate('file')->accessCheck(FALSE)
        ->aggregate('fid', 'max')
        ->execute()[0]['fid_max'];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.