function TestFileCreationTrait::compareFiles
Same name in other branches
- 9 core/tests/Drupal/Tests/TestFileCreationTrait.php \Drupal\Tests\TestFileCreationTrait::compareFiles()
- 10 core/tests/Drupal/Tests/TestFileCreationTrait.php \Drupal\Tests\TestFileCreationTrait::compareFiles()
- 11.x 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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.