mirror of
https://github.com/getgrav/grav.git
synced 2025-12-05 23:39:58 +01:00
✅ Test Assets::getCss() and Assets::getJs()
This commit is contained in:
@@ -38,22 +38,59 @@ class AssetsTest extends \Codeception\TestCase\Test
|
||||
$css = $assets->css();
|
||||
$this->assertSame($css, '<link href="/test.css" type="text/css" rel="stylesheet" />' . PHP_EOL);
|
||||
|
||||
$array = $assets->getCss();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.css',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'group' => 'head'
|
||||
]);
|
||||
|
||||
$assets->add('test.js');
|
||||
$js = $assets->js();
|
||||
$this->assertSame($js, '<script src="/test.js" type="text/javascript" ></script>' . PHP_EOL);
|
||||
|
||||
$array = $assets->getCss();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.css',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'group' => 'head'
|
||||
]);
|
||||
|
||||
//test addCss(). Test adding asset to a separate group
|
||||
$assets->reset();
|
||||
$assets->addCSS('test.css');
|
||||
$css = $assets->css();
|
||||
$this->assertSame($css, '<link href="/test.css" type="text/css" rel="stylesheet" />' . PHP_EOL);
|
||||
|
||||
$array = $assets->getCss();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.css',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'group' => 'head'
|
||||
]);
|
||||
|
||||
//test addJs()
|
||||
$assets->reset();
|
||||
$assets->addJs('test.js');
|
||||
$js = $assets->js();
|
||||
$this->assertSame($js, '<script src="/test.js" type="text/javascript" ></script>' . PHP_EOL);
|
||||
|
||||
$array = $assets->getJs();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.js',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'loading' => '',
|
||||
'group' => 'head'
|
||||
]);
|
||||
|
||||
//Test CSS Groups
|
||||
$assets->reset();
|
||||
$assets->addCSS('test.css', null, true, 'footer');
|
||||
@@ -62,6 +99,15 @@ class AssetsTest extends \Codeception\TestCase\Test
|
||||
$css = $assets->css('footer');
|
||||
$this->assertSame($css, '<link href="/test.css" type="text/css" rel="stylesheet" />' . PHP_EOL);
|
||||
|
||||
$array = $assets->getCss();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.css',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'group' => 'footer'
|
||||
]);
|
||||
|
||||
//Test JS Groups
|
||||
$assets->reset();
|
||||
$assets->addJs('test.js', null, true, null, 'footer');
|
||||
@@ -70,17 +116,46 @@ class AssetsTest extends \Codeception\TestCase\Test
|
||||
$js = $assets->js('footer');
|
||||
$this->assertSame($js, '<script src="/test.js" type="text/javascript" ></script>' . PHP_EOL);
|
||||
|
||||
$array = $assets->getJs();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.js',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'loading' => '',
|
||||
'group' => 'footer'
|
||||
]);
|
||||
|
||||
//Test async / defer
|
||||
$assets->reset();
|
||||
$assets->addJs('test.js', null, true, 'async', null);
|
||||
$js = $assets->js();
|
||||
$this->assertSame($js, '<script src="/test.js" type="text/javascript" async></script>' . PHP_EOL);
|
||||
|
||||
$array = $assets->getJs();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.js',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'loading' => 'async',
|
||||
'group' => 'head'
|
||||
]);
|
||||
|
||||
$assets->reset();
|
||||
$assets->addJs('test.js', null, true, 'defer', null);
|
||||
$js = $assets->js();
|
||||
$this->assertSame($js, '<script src="/test.js" type="text/javascript" defer></script>' . PHP_EOL);
|
||||
|
||||
|
||||
$array = $assets->getJs();
|
||||
$this->assertSame(reset($array), [
|
||||
'asset' => '/test.js',
|
||||
'priority' => 10,
|
||||
'order' => 0,
|
||||
'pipeline' => true,
|
||||
'loading' => 'defer',
|
||||
'group' => 'head'
|
||||
]);
|
||||
}
|
||||
|
||||
public function testAddingAssetPropertiesWithArray()
|
||||
|
||||
Reference in New Issue
Block a user