You are here

class AssetsDataCollectorTest in Devel 4.x

Same name and namespace in other branches
  1. 8.3 webprofiler/tests/src/Unit/DataCollector/AssetsDataCollectorTest.php \Drupal\Tests\webprofiler\Unit\DataCollector\AssetsDataCollectorTest
  2. 8 webprofiler/tests/src/Unit/DataCollector/AssetsDataCollectorTest.php \Drupal\Tests\webprofiler\Unit\DataCollector\AssetsDataCollectorTest
  3. 8.2 webprofiler/tests/src/Unit/DataCollector/AssetsDataCollectorTest.php \Drupal\Tests\webprofiler\Unit\DataCollector\AssetsDataCollectorTest

@coversDefaultClass \Drupal\webprofiler\DataCollector\AssetsDataCollector

@group webprofiler

Hierarchy

Expanded class hierarchy of AssetsDataCollectorTest

File

webprofiler/tests/src/Unit/DataCollector/AssetsDataCollectorTest.php, line 13

Namespace

Drupal\Tests\webprofiler\Unit\DataCollector
View source
class AssetsDataCollectorTest extends DataCollectorBaseTest {

  /**
   * @var \Drupal\webprofiler\DataCollector\AssetsDataCollector
   */
  private $assetDataCollector;

  /**
   * @var \PHPUnit_Framework_MockObject_MockObject
   */
  private $assetCollectionRendererInterface;
  const ROOT = 'test_root';

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();
    $this->assetDataCollector = new AssetsDataCollector(AssetsDataCollectorTest::ROOT);
    $this->assetCollectionRendererInterface = $this
      ->createMock('Drupal\\Core\\Asset\\AssetCollectionRendererInterface');
  }

  /**
   * Tests the Assets data collector.
   */
  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']);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AssetsDataCollectorTest::$assetCollectionRendererInterface private property
AssetsDataCollectorTest::$assetDataCollector private property
AssetsDataCollectorTest::ROOT constant
AssetsDataCollectorTest::setUp public function Overrides DataCollectorBaseTest::setUp
AssetsDataCollectorTest::testCSS public function Tests the Assets data collector.
DataCollectorBaseTest::$exception protected property @var
DataCollectorBaseTest::$request protected property @var
DataCollectorBaseTest::$response protected property @var
PhpUnitWarnings::$deprecationWarnings private static property Deprecation warnings from PHPUnit to raise with @trigger_error().
PhpUnitWarnings::addWarning public function Converts PHPUnit deprecation warnings to E_USER_DEPRECATED.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals Deprecated protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUpBeforeClass public static function