You are here

public function FileValidatorTest::dataProviderFilesToTree in Mini site 8

Data provider for testFilesToTree().

File

tests/src/Unit/FileValidatorTest.php, line 98

Class

FileValidatorTest
Class FileValidatorTest.

Namespace

Drupal\Tests\minisite\Unit

Code

public function dataProviderFilesToTree() {
  return [
    // Root files.
    [
      [
        'file.txt',
      ],
      [
        'file.txt' => 'file.txt',
      ],
    ],
    [
      [
        'file1.txt',
        'file2.txt',
      ],
      [
        'file1.txt' => 'file1.txt',
        'file2.txt' => 'file2.txt',
      ],
    ],
    // Simple dirs.
    [
      [
        'dir1/',
      ],
      [
        'dir1' => [
          '.' => 'dir1/',
        ],
      ],
    ],
    [
      [
        'dir1/',
        'dir2/',
      ],
      [
        'dir1' => [
          '.' => 'dir1/',
        ],
        'dir2' => [
          '.' => 'dir2/',
        ],
      ],
    ],
    // Dirs with files.
    [
      [
        'dir1/file1.txt',
        'dir2/file2.txt',
      ],
      [
        'dir1' => [
          '.' => 'dir1/',
          'file1.txt' => 'dir1/file1.txt',
        ],
        'dir2' => [
          '.' => 'dir2/',
          'file2.txt' => 'dir2/file2.txt',
        ],
      ],
    ],
    [
      [
        'dir1/dir11/dir111/',
      ],
      [
        'dir1' => [
          '.' => 'dir1/',
          'dir11' => [
            '.' => 'dir1/dir11/',
            'dir111' => [
              '.' => 'dir1/dir11/dir111/',
            ],
          ],
        ],
      ],
    ],
    [
      [
        'dir1/file11.txt',
        'dir2/file21.txt',
        'dir2/file22.txt',
        'dir3/',
        'dir4/dir41/',
      ],
      [
        'dir1' => [
          '.' => 'dir1/',
          'file11.txt' => 'dir1/file11.txt',
        ],
        'dir2' => [
          '.' => 'dir2/',
          'file21.txt' => 'dir2/file21.txt',
          'file22.txt' => 'dir2/file22.txt',
        ],
        'dir3' => [
          '.' => 'dir3/',
        ],
        'dir4' => [
          '.' => 'dir4/',
          'dir41' => [
            '.' => 'dir4/dir41/',
          ],
        ],
      ],
    ],
    // Mixed dirs, files, order.
    [
      [
        'dir1/',
        'dir1/dir11/dir111/',
        'dir1/dir11/',
        'dir1/dir11/dir111/file111.txt',
        'dir1/dir11/dir111/file112.txt',
        'file1.txt',
        'file2.txt',
        'dir2/file21.txt',
        'dir2/dir21/file211.txt',
        'dir2/file22.txt',
        'dir2/dir21/file212.txt',
        'dir2/file23.txt',
      ],
      [
        'file1.txt' => 'file1.txt',
        'file2.txt' => 'file2.txt',
        'dir1' => [
          '.' => 'dir1/',
          'dir11' => [
            '.' => 'dir1/dir11/',
            'dir111' => [
              '.' => 'dir1/dir11/dir111/',
              'file111.txt' => 'dir1/dir11/dir111/file111.txt',
              'file112.txt' => 'dir1/dir11/dir111/file112.txt',
            ],
          ],
        ],
        'dir2' => [
          '.' => 'dir2/',
          'dir21' => [
            '.' => 'dir2/dir21/',
            'file211.txt' => 'dir2/dir21/file211.txt',
            'file212.txt' => 'dir2/dir21/file212.txt',
          ],
          'file21.txt' => 'dir2/file21.txt',
          'file22.txt' => 'dir2/file22.txt',
          'file23.txt' => 'dir2/file23.txt',
        ],
      ],
    ],
    // Edge case - dirs provided as files and then as dirs.
    [
      [
        'dir1',
        'dir1/file1.txt',
      ],
      [],
      TRUE,
    ],
    [
      [
        'dir1/file1.txt',
        'dir1',
      ],
      [],
      TRUE,
    ],
    [
      [
        'dir1/dir11/dir111/file111.txt',
        'dir1/dir11/dir111',
      ],
      [],
      TRUE,
    ],
    // Repeating files.
    [
      [
        'file1.txt',
        'file1.txt',
      ],
      [
        'file1.txt' => 'file1.txt',
      ],
    ],
    [
      [
        'dir1/file1.txt',
        'dir1/file1.txt',
      ],
      [
        'dir1' => [
          '.' => 'dir1/',
          'file1.txt' => 'dir1/file1.txt',
        ],
      ],
    ],
  ];
}