AssetsDataCollectorTest.php in Devel 4.x
File
webprofiler/tests/src/Unit/DataCollector/AssetsDataCollectorTest.php
View source
<?php
namespace Drupal\Tests\webprofiler\Unit\DataCollector;
use Drupal\webprofiler\Asset\CssCollectionRendererWrapper;
use Drupal\webprofiler\DataCollector\AssetsDataCollector;
class AssetsDataCollectorTest extends DataCollectorBaseTest {
private $assetDataCollector;
private $assetCollectionRendererInterface;
const ROOT = 'test_root';
public function setUp() {
parent::setUp();
$this->assetDataCollector = new AssetsDataCollector(AssetsDataCollectorTest::ROOT);
$this->assetCollectionRendererInterface = $this
->createMock('Drupal\\Core\\Asset\\AssetCollectionRendererInterface');
}
public function testCSS() {
$css = [
'core/assets/vendor/normalize-css/normalize.css' => [
'weight' => -219.944,
'group' => 0,
'type' => 'file',
'data' => 'core\\/assets\\/vendor\\/normalize-css\\/normalize.css',
'version' => '3.0.3',
'media' => 'all',
'preprocess' => TRUE,
'browsers' => [
'IE' => TRUE,
'!IE' => TRUE,
],
],
];
$cssCollectionRendererWrapper = new CssCollectionRendererWrapper($this->assetCollectionRendererInterface, $this->assetDataCollector);
$cssCollectionRendererWrapper
->render($css);
$this
->assertEquals(1, $this->assetDataCollector
->getCssCount());
$this->assetDataCollector
->collect($this->request, $this->response, $this->exception);
$data = $this->assetDataCollector
->getData();
$this
->assertEquals(AssetsDataCollectorTest::ROOT . '/', $data['assets']['installation_path']);
}
}