<commit_before><?php

namespace Kibo\Phast\Filters\JavaScript\Minification;

use Kibo\Phast\PhastTestCase;
use Kibo\Phast\ValueObjects\Resource;
use Kibo\Phast\ValueObjects\URL;

class JSMinifierFilterTest extends PhastTestCase {
    public function testGetCacheSalt() {
        $filter1 = new JSMinifierFilter(false);
        $filter2 = new JSMinifierFilter(true);
        $resource = Resource::makeWithContent(URL::fromString(self::BASE_URL), 'the-content');
        $this->assertNotEquals($filter1->getCacheSalt($resource, []), $filter2->getCacheSalt($resource, []));
    }
}<commit_msg>Add test for control chars in minified JS<commit_after><?php

namespace Kibo\Phast\Filters\JavaScript\Minification;

use Kibo\Phast\PhastTestCase;
use Kibo\Phast\ValueObjects\Resource;
use Kibo\Phast\ValueObjects\URL;

class JSMinifierFilterTest extends PhastTestCase {
    public function testGetCacheSalt() {
        $filter1 = new JSMinifierFilter(false);
        $filter2 = new JSMinifierFilter(true);
        $resource = Resource::makeWithContent(URL::fromString(self::BASE_URL), 'the-content');
        $this->assertNotEquals($filter1->getCacheSalt($resource, []), $filter2->getCacheSalt($resource, []));
    }

    public function testControlCharacters() {
        $filter = new JSMinifierFilter(true);
        $resource = Resource::makeWithContent(URL::fromString(self::BASE_URL), " alert( '\x13' ); ");
        $result = $filter->apply($resource, []);
        $this->assertEquals("alert('\x13');", $result->getContent());
    }
}
{'fraction_non_alphanumeric': 0.14463350785340315, 'fraction_numerical': 0.007853403141361256, 'mean_word_length': 4.769811320754717, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '5936218', 'n_tokens_mistral': 477, 'n_tokens_neox': 467, 'n_words': 75}