You are here

PrintableCssIncludeTest.php in Printer and PDF versions for Drupal 8+ 8

Same filename and directory in other branches
  1. 2.x tests/src/Unit/PrintableCssIncludeTest.php

File

tests/src/Unit/PrintableCssIncludeTest.php
View source
<?php

namespace Drupal\Tests\printable\Unit;

use Drupal\Tests\UnitTestCase;
use Drupal\printable\PrintableCssInclude;

/**
 * Tests the print format plugin.
 *
 * @group Printable
 */
class PrintableCssIncludeTest extends UnitTestCase {

  /**
   * {@inheritdoc}
   */
  public static function getInfo() {
    return [
      'name' => 'Printable CSS Include',
      'descriptions' => 'Tests the printable CSS include class.',
      'group' => 'Printable',
    ];
  }

  /**
   * Tests getting the plugin label from the plugin.
   *
   * @covers PrintableCssInclude::getCssIncludePath
   *
   * @dataProvider providerTestGetCssIncludePath
   */
  public function testGetCssIncludePath($include, $expected) {
    $config = $this
      ->getConfigFactoryStub([
      'printable.settings' => [
        'css_include' => $include,
      ],
    ]);
    $theme_info = [
      'bartik' => new \stdClass(),
    ];
    $theme_info['bartik']->uri = 'core/themes/bartik/bartik.info.yml';
    $theme_handler = $this
      ->getMockBuilder('Drupal\\Core\\Extension\\ThemeHandlerInterface')
      ->disableOriginalConstructor()
      ->getMock();
    $theme_handler
      ->expects($this
      ->any())
      ->method('listInfo')
      ->will($this
      ->returnValue($theme_info));
    $css_include = new PrintableCssInclude($config, $theme_handler);
    $this
      ->assertEquals($expected, $css_include
      ->getCssIncludePath());
  }

  /**
   * Data provider for testGetCssIncludePath().
   */
  public function providerTestGetCssIncludePath() {
    return [
      [
        '[theme:bartik]/css/test.css',
        'core/themes/bartik/css/test.css',
      ],
      [
        '[theme:foobar]/css/test.css',
        '/css/test.css',
      ],
      [
        'foo/bar/css/test.css',
        'foo/bar/css/test.css',
      ],
    ];
  }

}

Classes

Namesort descending Description
PrintableCssIncludeTest Tests the print format plugin.