You are here

public function FileUrlGeneratorTest::testGenerate in CDN 8.3

@covers ::generate @dataProvider urlProvider

File

tests/src/Unit/File/FileUrlGeneratorTest.php, line 49

Class

FileUrlGeneratorTest
@coversDefaultClass \Drupal\cdn\File\FileUrlGenerator @group cdn

Namespace

Drupal\Tests\cdn\Unit\File

Code

public function testGenerate($scheme, $base_path, $uri, $expected_result) {
  $gen = $this
    ->createFileUrlGenerator($base_path, [
    'status' => TRUE,
    'mapping' => [
      'type' => 'complex',
      'fallback_domain' => 'cdn.example.com',
      'domains' => [
        0 => [
          'type' => 'simple',
          'domain' => 'static.example.com',
          'conditions' => [
            'extensions' => [
              'css',
              'js',
            ],
          ],
        ],
        1 => [
          'type' => 'auto-balanced',
          'domains' => [
            'img1.example.com',
            'img2.example.com',
          ],
          'conditions' => [
            'extensions' => [
              'jpg',
              'jpeg',
              'png',
            ],
          ],
        ],
      ],
    ],
    'scheme' => $scheme,
    'farfuture' => [
      'status' => FALSE,
    ],
    'stream_wrappers' => [
      'public',
    ],
  ]);
  $this
    ->assertSame($expected_result, $gen
    ->generate($uri));
}