<commit_before><?php
/**
 * @group Assets
 */
class Vps_Assets_Dynamic_Test extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        Vps_Assets_Dynamic_Asset::$file = tempnam('/tmp', 'asset');
        file_put_contents(Vps_Assets_Dynamic_Asset::$file, 'a { color: red; }');
    }

    public function tearDown()
    {
        unlink(Vps_Assets_Dynamic_Asset::$file);
    }

    public function testDynamic()
    {
        $config = clone Zend_Registry::get('config');
        $config->debug->menu = false;
        $config->debug->assets->js = true;
        $config->debug->assets->css = true;
        $config->debug->assets->printcss = true;
        $loader = new Vps_Assets_Loader($config);
        $dep = $loader->getDependencies();

        $type = 'Vps_Assets_Dynamic:Test';
        $files = $dep->getAssetUrls($type, 'css', 'web', false);
        $this->assertEquals(1, count($files));
        $this->assertContains('/assets/dynamic/Vps_Assets_Dynamic:Test/Vps_Assets_Dynamic_Asset', $files[0]);

        $c = $loader->getFileContents('dynamic/Vps_Assets_Dynamic:Test/Vps_Assets_Dynamic_Asset');
        $this->assertEquals('a { color: red; }', $c['contents']);
    }

    public function testMTimeFiles()
    {
        Vps_Assets_Cache::getInstance()->clean();
        Vps_Benchmark::enable();
        Vps_Benchmark::reset();

        $config = clone Zend_Registry::get('config');
        $config->debug->menu = false;
        $config->debug->assets->js = false;
        $config->debug->assets->css = false;
        $config->debug->assets->printcss = false;
        $loader = new Vps_Assets_Loader($config);
        $dep = $loader->getDependencies();

        $type = 'Vps_Assets_Dynamic:Test';
        $files = $dep->getAssetUrls($type, 'css', 'web', false);
        $this->assertEquals(1, count($files));
        $f = 'all/web/de/Vps_Assets_Dynamic:Test.css';
        $this->assertContains('/assets/'.$f, $files[0]);

        //erstes mal laden
        $c = $loader->getFileContents($f);
        $this->assertEquals('a { color: red; }', trim($c['contents']));
        $this->assertEquals(1, Vps_Benchmark::getCounterValue('processing dependencies miss'));
        $this->assertEquals(1, Vps_Benchmark::getCounterValue('load asset all'));

        //nochmal laden, wird gecached
        $c = $loader->getFileContents($f);
        $this->assertEquals('a { color: red; }', trim($c['contents']));
        $this->assertEquals(1, Vps_Benchmark::getCounterValue('processing dependencies miss'));
        $this->assertEquals(1, Vps_Benchmark::getCounterValue('load asset all'));

        //datei ändern, muss neu geladen werden (wegen mtimeFiles in Vps_Assets_Dynamic_Asset)
        $t = time();
        sleep(1); //damit mtime sicher größer
        file_put_contents(Vps_Assets_Dynamic_Asset::$file, 'a { color: blue; }');<commit_msg>fix test für englisch sprachige webs<commit_after><?php
/**
 * @group Assets
 */
class Vps_Assets_Dynamic_Test extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        Vps_Assets_Dynamic_Asset::$file = tempnam('/tmp', 'asset');
        file_put_contents(Vps_Assets_Dynamic_Asset::$file, 'a { color: red; }');
    }

    public function tearDown()
    {
        unlink(Vps_Assets_Dynamic_Asset::$file);
    }

    public function testDynamic()
    {
        $config = clone Zend_Registry::get('config');
        $config->debug->menu = false;
        $config->debug->assets->js = true;
        $config->debug->assets->css = true;
        $config->debug->assets->printcss = true;
        $loader = new Vps_Assets_Loader($config);
        $dep = $loader->getDependencies();

        $type = 'Vps_Assets_Dynamic:Test';
        $files = $dep->getAssetUrls($type, 'css', 'web', false);
        $this->assertEquals(1, count($files));
        $this->assertContains('/assets/dynamic/Vps_Assets_Dynamic:Test/Vps_Assets_Dynamic_Asset', $files[0]);

        $c = $loader->getFileContents('dynamic/Vps_Assets_Dynamic:Test/Vps_Assets_Dynamic_Asset');
        $this->assertEquals('a { color: red; }', $c['contents']);
    }

    public function testMTimeFiles()
    {
        Vps_Assets_Cache::getInstance()->clean();
        Vps_Benchmark::enable();
        Vps_Benchmark::reset();

        $config = clone Zend_Registry::get('config');
        $config->debug->menu = false;
        $config->debug->assets->js = false;
        $config->debug->assets->css = false;
        $config->debug->assets->printcss = false;
        $loader = new Vps_Assets_Loader($config);
        $dep = $loader->getDependencies();

        $type = 'Vps_Assets_Dynamic:Test';
        $files = $dep->getAssetUrls($type, 'css', 'web', false);
        $this->assertEquals(1, count($files));
        $f = 'all/web/'.Vps_Registry::get('trl')->getTargetLanguage().'/Vps_Assets_Dynamic:Test.css';
        $this->assertContains('/assets/'.$f, $files[0]);

        //erstes mal laden
        $c = $loader->getFileContents($f);
        $this->assertEquals('a { color: red; }', trim($c['contents']));
        $this->assertEquals(1, Vps_Benchmark::getCounterValue('processing dependencies miss'));
        $this->assertEquals(1, Vps_Benchmark::getCounterValue('load asset all'));

        //nochmal laden, wird gecached
        $c = $loader->getFileContents($f);
        $this->assertEquals('a { color: red; }', trim($c['contents']));
        $this->assertEquals(1, Vps_Benchmark::getCounterValue('processing dependencies miss'));
        $this->assertEquals(1, Vps_Benchmark::getCounterValue('load asset all'));

        //datei ändern, muss neu geladen werden (wegen mtimeFiles in Vps_Assets_Dynamic_Asset)
        $t = time();
        sleep(1); //damit mtime sicher größer
        file_put_contents(Vps_Assets_Dynamic_Asset::$file, 'a { color: blue; }');
{'fraction_non_alphanumeric': 0.16632088520055324, 'fraction_numerical': 0.0031120331950207467, 'mean_word_length': 3.2693726937269374, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 86, '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': '952873', 'n_tokens_mistral': 1825, 'n_tokens_neox': 1810, 'n_words': 301}