You are here

protected function WebTestBase::drupalCompareFiles in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/WebTestBase.php \Drupal\simpletest\WebTestBase::drupalCompareFiles()

Compare two files based on size and file name.

File

core/modules/simpletest/src/WebTestBase.php, line 561
Contains \Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function drupalCompareFiles($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);
  }
}