<commit_before><?php
App::uses('AssetCache', 'AssetCompress.Lib');
App::uses('AssetConfig', 'AssetCompress.Lib');

class AssetCacheTest extends CakeTestCase {

	public function setUp() {
		parent::setUp();
		AssetConfig::clearBuildTimestamp();
		$this->_testFiles = App::pluginPath('AssetCompress') . 'Test' . DS . 'test_files' . DS;
		$this->testConfig = $this->_testFiles . 'Config' . DS . 'integration.ini';
		$this->_themeConfig = $this->_testFiles . 'Config' . DS . 'themed.ini';

		$this->config = AssetConfig::buildFromIniFile($this->testConfig);
		$this->config->cachePath('js', TMP);
		$this->config->set('js.timestamp', true);
		$this->cache = new AssetCache($this->config);
	}

	public function testWrite() {
		$this->config->set('js.timestamp', false);
		$result = $this->cache->write('test.js', 'Some content');
		$this->assertNotEqual($result, false);
		$contents = file_get_contents(TMP . 'test.js');
		$this->assertEquals('Some content', $contents);
		unlink(TMP . 'test.js');
	}

	public function testWriteTimestamp() {
		$this->assertTrue($this->config->get('js.timestamp'));

		$now = time();
		$this->cache->setTimestamp('test.js', $now);
		$this->cache->write('test.js', 'Some content');

		$contents = file_get_contents(TMP . 'test.v' . $now . '.js');
		$this->assertEquals('Some content', $contents);
		unlink(TMP . 'test.v' . $now . '.js');
	}

	public function testIsFreshNoBuild() {
		$this->assertFalse($this->cache->isFresh('libs.js'));<commit_msg>Fix failing test.<commit_after><?php
App::uses('AssetCache', 'AssetCompress.Lib');
App::uses('AssetConfig', 'AssetCompress.Lib');

class AssetCacheTest extends CakeTestCase {

	public function setUp() {
		parent::setUp();
		AssetConfig::clearBuildTimestamp();
		$this->_testFiles = App::pluginPath('AssetCompress') . 'Test' . DS . 'test_files' . DS;
		$this->testConfig = $this->_testFiles . 'Config' . DS . 'integration.ini';
		$this->_themeConfig = $this->_testFiles . 'Config' . DS . 'themed.ini';

		$this->config = AssetConfig::buildFromIniFile($this->testConfig, array(
			'TEST_FILES' => $this->_testFiles
		));
		$this->config->cachePath('js', TMP);
		$this->config->set('js.timestamp', true);
		$this->cache = new AssetCache($this->config);
	}

	public function testWrite() {
		$this->config->set('js.timestamp', false);
		$result = $this->cache->write('test.js', 'Some content');
		$this->assertNotEqual($result, false);
		$contents = file_get_contents(TMP . 'test.js');
		$this->assertEquals('Some content', $contents);
		unlink(TMP . 'test.js');
	}

	public function testWriteTimestamp() {
		$this->assertTrue($this->config->get('js.timestamp'));

		$now = time();
		$this->cache->setTimestamp('test.js', $now);
		$this->cache->write('test.js', 'Some content');

		$contents = file_get_contents(TMP . 'test.v' . $now . '.js');
		$this->assertEquals('Some content', $contents);
		unlink(TMP . 'test.v' . $now . '.js');
	}

	public function testIsFreshNoBuild() {
		$this->assertFalse($this->cache->isFresh('libs.js'));
{'fraction_non_alphanumeric': 0.2119800332778702, 'fraction_numerical': 0.0, 'mean_word_length': 4.952475247524752, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 65, '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': '2740485', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1000, 'n_words': 174}