You are here

protected function ThemeTest::compareFiles in Image Lazyloader 8

Compare two files based on size and file name.

File

tests/src/Kernel/ThemeTest.php, line 232

Class

ThemeTest
Tests Lazyloaders theme integration.

Namespace

Drupal\Tests\lazyloader\Kernel

Code

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);
  }
}