You are here

public function FileLogRotationTest::provideRotationConfig in File Log 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Unit/FileLogRotationTest.php \Drupal\Tests\filelog\Unit\FileLogRotationTest::provideRotationConfig()

Provide configuration and state for the rotation test.

Return value

array All datasets for ::testRotation()

File

tests/src/Unit/FileLogRotationTest.php, line 175

Class

FileLogRotationTest
Tests the log rotation of the file logger.

Namespace

Drupal\Tests\filelog\Unit

Code

public function provideRotationConfig() : array {
  $config = [
    'schedule' => 'daily',
    'delete' => FALSE,
    'destination' => 'archive/[date:custom:Y/m/d].log',
    'gzip' => FALSE,
  ];
  $data[] = [
    'timestamp' => 86400,
    'config' => $config,
    'files' => [
      LogFileManager::FILENAME,
    ],
  ];
  $data[] = [
    'timestamp' => 86399,
    'config' => $config,
    'files' => [
      'archive/1970/01/01.log',
    ],
  ];
  $config['schedule'] = 'weekly';

  // 70/1/1 was a Thursday. Go back three days to the beginning of the week.
  $data[] = [
    'timestamp' => -259200,
    'config' => $config,
    'files' => [
      LogFileManager::FILENAME,
    ],
  ];
  $data[] = [
    'timestamp' => -259201,
    'config' => $config,
    'files' => [
      'archive/1969/12/28.log',
    ],
  ];
  $config['schedule'] = 'monthly';
  $data[] = [
    'timestamp' => 0,
    'config' => $config,
    'files' => [
      LogFileManager::FILENAME,
    ],
  ];
  $data[] = [
    'timestamp' => -1,
    'config' => $config,
    'files' => [
      'archive/1969/12/31.log',
    ],
  ];
  $config['gzip'] = TRUE;
  $data[] = [
    'timestamp' => -1,
    'config' => $config,
    'files' => [
      'archive/1969/12/31.log.gz',
    ],
  ];
  $config['delete'] = TRUE;
  $data[] = [
    'timestamp' => -1,
    'config' => $config,
    'files' => [],
  ];
  $config['schedule'] = 'never';
  $data[] = [
    // About three years.
    'timestamp' => -100000000,
    'config' => $config,
    'files' => [
      LogFileManager::FILENAME,
    ],
  ];
  return $data;
}