function IconFinderTest::providerGetFilesFromSourcesUrl

Data provider for ::testGetFilesFromSourcesUrl().

Return value

\Generator The test cases, with expected result as icon_id.

File

core/tests/Drupal/Tests/Core/Theme/Icon/IconFinderTest.php, line 68

Class

IconFinderTest
@coversDefaultClass \Drupal\Core\Theme\Icon\IconFinder[[api-linebreak]]

Namespace

Drupal\Tests\Core\Theme\Icon

Code

public static function providerGetFilesFromSourcesUrl() : iterable {
  (yield 'empty sources' => [
    [],
  ]);
  (yield 'url valid' => [
    [
      'http://example.com/foo.png',
      'https://example.com/bar.png',
      'https://example.com/fOO%20folder%20%C3%B9/FoO%21%20BaR%3D%281%29%20iCo-n.png%3Ftest%3DfOO%23bAz',
    ],
    [
      'foo' => 'http://example.com/foo.png',
      'bar' => 'https://example.com/bar.png',
      'FoO! BaR=(1) iCo-n' => 'https://example.com/fOO%20folder%20%C3%B9/FoO%21%20BaR%3D%281%29%20iCo-n.png%3Ftest%3DfOO%23bAz',
    ],
  ]);
  (yield 'url encoded' => [
    [
      'https://example.com/fOO%20folder%20%C3%B9/FoO%21%20BaR%3D%281%29%20iCo-n.png%3Ftest%3DfOO%23bAz',
    ],
    [
      'FoO! BaR=(1) iCo-n' => 'https://example.com/fOO%20folder%20%C3%B9/FoO%21%20BaR%3D%281%29%20iCo-n.png%3Ftest%3DfOO%23bAz',
    ],
  ]);
  (yield 'url not encoded' => [
    [
      'https://example.com/fOO folder ù/FoO_Ba,R=(1) iCo-n.png?test=fOO#bAz',
    ],
    [
      'FoO_Ba,R=(1) iCo-n' => 'https://example.com/fOO folder ù/FoO_Ba,R=(1) iCo-n.png?test=fOO#bAz',
    ],
  ]);
  (yield 'url valid with duplicate' => [
    [
      'http://example.com/foo.png',
      'https://example.com/bar.png',
      'http://example.com/foo.svg',
      'https://example.com/bar.svg',
    ],
    [
      'foo' => 'http://example.com/foo.svg',
      'bar' => 'https://example.com/bar.svg',
    ],
  ]);
  (yield 'url no extension' => [
    [
      'http://example.com/foo',
      'https://example.com/fOO folder ù/FoO BaR=(1) iCo-n?test=fOO#bAz',
    ],
    [
      'foo' => 'http://example.com/foo',
      'FoO BaR=(1) iCo-n' => 'https://example.com/fOO folder ù/FoO BaR=(1) iCo-n?test=fOO#bAz',
    ],
  ]);
  (yield 'url valid with special filename' => [
    [
      'http://example.com/foo (è$ù5 6*$^ _ ù48 \'Bar\']=-n!.png',
    ],
    [
      'foo (è$ù5 6*$^ _ ù48 \'Bar\']=-n!' => 'http://example.com/foo (è$ù5 6*$^ _ ù48 \'Bar\']=-n!.png',
    ],
  ]);
  // Test invalid scheme and empty path.
  (yield 'url not supported scheme or path is invalid' => [
    [
      'ftp://foo/bar.png',
      'ssh://foo/bar.png',
      'sftp://foo/bar.png',
      'htp://foo/bar.png',
      'a://foo/bar.png',
      'http://',
      'https://',
    ],
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.