<commit_before><?php

use Codeception\Util\Fixtures;

class AssetsTest extends \Codeception\TestCase\Test
{
    /**
     * @var \UnitTester
     */
    protected $tester;

    protected function _before()
    {
    }

    protected function _after()
    {
    }

    public function grav()
    {
        $grav = Fixtures::get('grav');
        return $grav;
    }

    public function assets()
    {
        return $this->grav()['assets'];
    }

    public function testAddingAssets()
    {
        $assets = $this->assets();

        //test add()
        $assets->add('test.css');

        $css = $assets->css();
        $this->assertSame($css, '<link href="/test.css" type="text/css" rel="stylesheet" />' . PHP_EOL);

        $assets->add('test.js');
        $js = $assets->js();
        $this->assertSame($js, '<script src="/test.js" type="text/javascript" ></script>' . PHP_EOL);

        //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);

        //test addJs()
        $assets->reset();
        $assets->addJs('test.js');
        $js = $assets->js();
        $this->assertSame($js, '<script src="/test.js" type="text/javascript" ></script>' . PHP_EOL);

        //Test CSS Groups
        $assets->reset();
        $assets->addCSS('test.css', null, true, 'footer');
        $css = $assets->css();
        $this->assertEmpty($css);
        $css = $assets->css('footer');
        $this->assertSame($css, '<link href="/test.css" type="text/css" rel="stylesheet" />' . PHP_EOL);

        //Test JS Groups
        $assets->reset();
        $assets->addJs('test.js', null, true, null, 'footer');
        $js = $assets->js();
        $this->assertEmpty($js);
        $js = $assets->js('footer');
        $this->assertSame($js, '<script src="/test.js" type="text/javascript" ></script>' . PHP_EOL);

        //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);
        $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);


    }

    public function testAddingAssetPropertiesWithArray()
    {
        $assets = $this->assets();

        //Test adding assets with object to define properties
        $assets->reset();
        $assets->addJs('test.js', ['loading' => 'async']);
        $js = $assets->js();
        $this->assertSame($js, '<script src="/test.js" type="text/javascript" async></script>' . PHP_EOL);
        $assets->reset();

    }
<commit_msg>:white_check_mark: Test Assets::getCss() and Assets::getJs()<commit_after><?php

use Codeception\Util\Fixtures;

class AssetsTest extends \Codeception\TestCase\Test
{
    /**
     * @var \UnitTester
     */
    protected $tester;

    protected function _before()
    {
    }

    protected function _after()
    {
    }

    public function grav()
    {
        $grav = Fixtures::get('grav');
        return $grav;
    }

    public function assets()
    {
        return $this->grav()['assets'];
    }

    public function testAddingAssets()
    {
        $assets = $this->assets();

        //test add()
        $assets->add('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'
        ]);

        $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');
        $css = $assets->css();
        $this->assertEmpty($css);
        $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');
        $js = $assets->js();
        $this->assertEmpty($js);
        $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()
    {
        $assets = $this->assets();

        //Test adding assets with object to define properties
        $assets->reset();
        $assets->addJs('test.js', ['loading' => 'async']);
        $js = $assets->js();
        $this->assertSame($js, '<script src="/test.js" type="text/javascript" async></script>' . PHP_EOL);
        $assets->reset();

    }

{'fraction_non_alphanumeric': 0.20567553992968357, 'fraction_numerical': 0.0030135610246107484, 'mean_word_length': 1.9831460674157304, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 179, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1771506', 'n_tokens_mistral': 2493, 'n_tokens_neox': 2428, 'n_words': 476}