function CssCollectionRendererUnitTest::setUp

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php \Drupal\Tests\Core\Asset\CssCollectionRendererUnitTest::setUp()
  2. 8.9.x core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php \Drupal\Tests\Core\Asset\CssCollectionRendererUnitTest::setUp()
  3. 11.x core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php \Drupal\Tests\Core\Asset\CssCollectionRendererUnitTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php, line 37

Class

CssCollectionRendererUnitTest
Tests the CSS asset collection renderer.

Namespace

Drupal\Tests\Core\Asset

Code

protected function setUp() : void {
  parent::setUp();
  $state = $this->prophesize(StateInterface::class);
  $assetQueryString = $this->prophesize(AssetQueryStringInterface::class);
  $file_url_generator = $this->createMock(FileUrlGeneratorInterface::class);
  $file_url_generator->expects($this->any())
    ->method('generateString')
    ->with($this->isType('string'))
    ->willReturnCallback(function ($uri) {
    return 'generated-relative-url:' . $uri;
  });
  $assetQueryString->get()
    ->shouldBeCalledOnce()
    ->willReturn('');
  $this->renderer = new CssCollectionRenderer($assetQueryString->reveal(), $file_url_generator);
  $this->fileCssGroup = [
    'group' => -100,
    'type' => 'file',
    'media' => 'all',
    'preprocess' => TRUE,
    'items' => [
      0 => [
        'group' => -100,
        'type' => 'file',
        'weight' => 0.012,
        'media' => 'all',
        'preprocess' => TRUE,
        'data' => 'tests/Drupal/Tests/Core/Asset/foo.css',
        'basename' => 'foo.css',
      ],
      1 => [
        'group' => -100,
        'type' => 'file',
        'weight' => 0.013,
        'media' => 'all',
        'preprocess' => TRUE,
        'data' => 'tests/Drupal/Tests/Core/Asset/bar.css',
        'basename' => 'bar.css',
      ],
    ],
  ];
}

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