~canonical-sysadmins/drupal/7.x

« back to all changes in this revision

Viewing changes to modules/file/tests/file.test

  • Committer: Barry Price
  • Date: 2019-02-22 08:30:41 UTC
  • Revision ID: barry.price@canonical.com-20190222083041-3bflvt8znc00u3xo
Drupal 7.64 upgrade

Show diffs side-by-side

added added

removed removed

Lines of Context:
1875
1875
  }
1876
1876
 
1877
1877
}
 
1878
 
 
1879
/**
 
1880
 * Tests the file_scan_directory() function.
 
1881
 */
 
1882
class FileScanDirectory extends FileFieldTestCase {
 
1883
 
 
1884
  /**
 
1885
   * @var string
 
1886
   */
 
1887
  protected $path;
 
1888
 
 
1889
  /**
 
1890
   * {@inheritdoc}
 
1891
   */
 
1892
  public static function getInfo() {
 
1893
    return array(
 
1894
      'name' => 'File ScanDirectory',
 
1895
      'description' => 'Tests the file_scan_directory() function.',
 
1896
      'group' => 'File',
 
1897
    );
 
1898
  }
 
1899
 
 
1900
  /**
 
1901
   * {@inheritdoc}
 
1902
   */
 
1903
  function setUp() {
 
1904
    parent::setUp();
 
1905
 
 
1906
    $this->path = 'modules/file/tests/fixtures/file_scan_ignore';
 
1907
  }
 
1908
 
 
1909
  /**
 
1910
   * Tests file_scan_directory() obeys 'file_scan_ignore_directories' setting.
 
1911
   * If nomask is not passed as argument, it should use the default settings.
 
1912
   * If nomask is passed as argument, it should obey this rule.
 
1913
   */
 
1914
  public function testNoMask() {
 
1915
    $files = file_scan_directory($this->path, '/\.txt$/');
 
1916
    $this->assertEqual(3, count($files), '3 text files found when not ignoring directories.');
 
1917
 
 
1918
    global $conf;
 
1919
    $conf['file_scan_ignore_directories'] = array('frontend_framework');
 
1920
 
 
1921
    $files = file_scan_directory($this->path, '/\.txt$/');
 
1922
    $this->assertEqual(1, count($files), '1 text files found when ignoring directories called "frontend_framework".');
 
1923
 
 
1924
    // Make that directories specified by default still work when a new nomask is provided.
 
1925
    $files = file_scan_directory($this->path, '/\.txt$/', array('nomask' => '/^c.txt/'));
 
1926
    $this->assertEqual(2, count($files), '2 text files found when an "nomask" option is passed in.');
 
1927
 
 
1928
    // Ensure that the directories in file_scan_ignore_directories are escaped using preg_quote.
 
1929
    $conf['file_scan_ignore_directories'] = array('frontend.*');
 
1930
    $files = file_scan_directory($this->path, '/\.txt$/');
 
1931
    $this->assertEqual(3, count($files), '2 text files found when ignoring a directory that is not there.');
 
1932
  }
 
1933
 
 
1934
}