You are here

public function FileHashTest::testFileHashGenerate in File Hash 8

Tests file hash bulk generation.

File

tests/src/Functional/FileHashTest.php, line 126

Class

FileHashTest
File Hash tests.

Namespace

Drupal\Tests\filehash\Functional

Code

public function testFileHashGenerate() {
  $this
    ->drupalGet('admin/config/media/filehash');
  $fields = [
    'algos[sha1]' => FALSE,
  ];
  $this
    ->submitForm($fields, $this
    ->t('Save configuration'));
  do {
    $file = $this
      ->getTestFile('text');
    $file
      ->save();
  } while ($file
    ->id() < 5);
  $this
    ->drupalGet('admin/config/media/filehash');
  $fields = [
    'algos[sha1]' => TRUE,
  ];
  $this
    ->submitForm($fields, $this
    ->t('Save configuration'));
  $this
    ->drupalGet('admin/config/media/filehash/generate');
  $this
    ->submitForm([], $this
    ->t('Generate'));
  $this
    ->assertSession()
    ->pageTextContains('Processed 5 files.');
}