PrintableCssIncludeTest.php in Printer and PDF versions for Drupal 8+ 8
File
tests/src/Unit/PrintableCssIncludeTest.php
View source
<?php
namespace Drupal\Tests\printable\Unit;
use Drupal\Tests\UnitTestCase;
use Drupal\printable\PrintableCssInclude;
class PrintableCssIncludeTest extends UnitTestCase {
public static function getInfo() {
return [
'name' => 'Printable CSS Include',
'descriptions' => 'Tests the printable CSS include class.',
'group' => 'Printable',
];
}
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());
}
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',
],
];
}
}