From c3c7c78e465a23dbb3776a22ff6be9adc46eb152 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Wed, 27 Jan 2016 09:25:07 +0100 Subject: [PATCH] :white_check_mark: Test Assets::getCss() and Assets::getJs() --- tests/unit/Grav/Common/AssetsTest.php | 77 ++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/tests/unit/Grav/Common/AssetsTest.php b/tests/unit/Grav/Common/AssetsTest.php index ec6508a15..a3272610b 100644 --- a/tests/unit/Grav/Common/AssetsTest.php +++ b/tests/unit/Grav/Common/AssetsTest.php @@ -38,22 +38,59 @@ class AssetsTest extends \Codeception\TestCase\Test $css = $assets->css(); $this->assertSame($css, '' . 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, '' . 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, '' . 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, '' . 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, '' . 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, '' . 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, '' . 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, '' . 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()