You are here

private function S3fsTest::cacheBatchExecute in S3 File System 4.0.x

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/S3fsTest.php \Drupal\Tests\s3fs\Functional\S3fsTest::cacheBatchExecute()

Create and execute a S3fsRefreshCacheBatch job.

Parameters

array $config: S3fs Config array to be used for the batch.

1 call to S3fsTest::cacheBatchExecute()
S3fsTest::testCacheRefresh in tests/src/Functional/S3fsTest.php
Test the cache refresh.

File

tests/src/Functional/S3fsTest.php, line 333

Class

S3fsTest
S3 File System Tests.

Namespace

Drupal\Tests\s3fs\Functional

Code

private function cacheBatchExecute(array $config) {
  $cacheBatchService = \Drupal::service('s3fs.refresh_cache_batch');

  // This should match S3fsRefreshCacheBatch->execute() to just before
  // PHP_SAPI check and a rewrite of $this.
  // Create batch.
  $batch_builder = $cacheBatchService
    ->getBatch();
  $args = [
    $config,
  ];
  $batch_builder
    ->addOperation([
    S3fsRefreshCacheBatch::class,
    'refreshCacheOperation',
  ], $args);
  batch_set($batch_builder
    ->toArray());
  $batch =& batch_get();

  // End copy from S3fsRefreshCacheBatch->execute().
  // We intentionally cut out the PHP_SAPI check and go to executing it.
  $batch['progressive'] = FALSE;
  $batch['file'] = drupal_get_path('module', 's3fs') . 'src/Batch/S3fsRefreshCacheBatch.php';
  batch_process();
}