protected function TestFileCreationTrait::compareFiles in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/TestFileCreationTrait.php \Drupal\Tests\TestFileCreationTrait::compareFiles()
- 9 core/tests/Drupal/Tests/TestFileCreationTrait.php \Drupal\Tests\TestFileCreationTrait::compareFiles()
Compares two files based on size and file name.
Callback for uasort() within \TestFileCreationTrait::getTestFiles().
Parameters
object $file1: The first file.
object $file2: The second class.
Return value
int
File
- core/
tests/ Drupal/ Tests/ TestFileCreationTrait.php, line 113
Class
- TestFileCreationTrait
- Provides methods to create test files from given values.
Namespace
Drupal\TestsCode
protected function compareFiles($file1, $file2) {
$compare_size = filesize($file1->uri) - filesize($file2->uri);
if ($compare_size) {
// Sort by file size.
return $compare_size;
}
else {
// The files were the same size, so sort alphabetically.
return strnatcmp($file1->name, $file2->name);
}
}