<commit_before><?php
App::import('Model', 'Config.Config');

class ConfigTestCase extends CakeTestCase {

/**
 * Fixture
 *
 * @var array
 * @access public
 */
	public $fixtures = array('plugin.config.config');

/**
 * startTest
 *
 * @return void
 * @access public
 */
	public function startTest() {
		$this->Config = ClassRegistry::init('Config.Config');
	}

/**
 * startTest
 *
 * @return void
 * @access public
 */
	public function endTest() {
		unset($this->Config);
		ClassRegistry::flush();
	}

/**
 * startTest
 *
 * @return void
 * @access public
 */
	public function testConfigInstance() {
		$this->assertTrue(is_a($this->Config, 'Config'));
	}

/**
 * testConfigSavingAndReading
 *
 * @return void
 * @access public
 */
	public function testConfigSavingAndReading() {
		Config::$configFile = 'tmp_config.php';
		$config = array(
			'Config' => array(
				'tester' => 'burzum',
				'foo' => 'bar',
				'cakephp' => '1.2',
				'nested' => array(
					'one' => 1,
					'two' => 2)));

		$this->assertTrue($this->Config->write($config));

		$this->assertNull(Configure::read('tester'));
		$result = $this->Config->readFile();
		$expected = array(
			'Media.imageSizes.large.width' => 500,
			'Media.imageSizes.large.height' => 500,
			'tester' => 'burzum',
			'foo' => 'bar',
			'cakephp' => '1.2',
			'nested.one' => 1,
			'nested.two' => 2);
		$this->assertEqual($result, $expected);

		$this->assertNull(Configure::read('tester'));
		$result = $this->Config->readFileAsArray();
		$expected = Set::merge(
			array(
				'Media' => array(
					'imageSizes' => array(
						'large' => array(
							'width' => 500,
							'height' => 500)))),
			$config['Config']);
		$this->assertEqual($result, $expected);

		$this->Config->loadFile();
		$this->assertEqual('burzum', Configure::read('tester'));
		$this->assertEqual(array('one' => 1, 'two' => 2), Configure::read('nested'));

		if (is_file(TMP . 'tmp_config.php')) {
			unlink(TMP . 'tmp_config.php');
		}
	}

/**
 * testBuildFields
 *
 * @return void
 * @access public
 */
	public function testBuildFields() {
		$result = $this->Config->buildFields();
		$this->assertTrue(empty($result));
	}

/**
 * Test write method
 *
 * @return void
 * @access public
 */
	public function testWrite() {
		$testFile = 'tmp_config.php';
		Config::$configFile = $testFile;

		$f = new Exception('f');
		$data = array('Config' => array(
			'a' => array(
				'b' => 'c',
				'd'),
			'e' => $f,
			'g' => array(
				'h' => array(
					'i'))));
		$this->assertTrue($this->Config->write($data));
		$this->assertTrue(is_file(TMP . $testFile));

		$result = $this->Config->find('all');
		$expected = array(
			'Media.imageSizes.large.width' => 500,
			'Media.imageSizes.large.height' => 500,<commit_msg>Optimizing the test to make sure the order of the results is always the same<commit_after><?php
App::import('Model', 'Config.Config');

class ConfigTestCase extends CakeTestCase {

/**
 * Fixture
 *
 * @var array
 * @access public
 */
	public $fixtures = array('plugin.config.config');

/**
 * startTest
 *
 * @return void
 * @access public
 */
	public function startTest() {
		$this->Config = ClassRegistry::init('Config.Config');
	}

/**
 * startTest
 *
 * @return void
 * @access public
 */
	public function endTest() {
		unset($this->Config);
		ClassRegistry::flush();
	}

/**
 * startTest
 *
 * @return void
 * @access public
 */
	public function testConfigInstance() {
		$this->assertTrue(is_a($this->Config, 'Config'));
	}

/**
 * testConfigSavingAndReading
 *
 * @return void
 * @access public
 */
	public function testConfigSavingAndReading() {
		Config::$configFile = 'tmp_config.php';
		$config = array(
			'Config' => array(
				'tester' => 'burzum',
				'foo' => 'bar',
				'cakephp' => '1.2',
				'nested' => array(
					'one' => 1,
					'two' => 2)));

		$this->assertTrue($this->Config->write($config));

		$this->assertNull(Configure::read('tester'));
		$result = $this->Config->readFile();
		$expected = array(
			'Media.imageSizes.large.width' => 500,
			'Media.imageSizes.large.height' => 500,
			'tester' => 'burzum',
			'foo' => 'bar',
			'cakephp' => '1.2',
			'nested.one' => 1,
			'nested.two' => 2);
		$this->assertEqual($result, $expected);

		$this->assertNull(Configure::read('tester'));
		$result = $this->Config->readFileAsArray();
		$expected = Set::merge(
			array(
				'Media' => array(
					'imageSizes' => array(
						'large' => array(
							'width' => 500,
							'height' => 500)))),
			$config['Config']);
		$this->assertEqual($result, $expected);

		$this->Config->loadFile();
		$this->assertEqual('burzum', Configure::read('tester'));
		$this->assertEqual(array('one' => 1, 'two' => 2), Configure::read('nested'));

		if (is_file(TMP . 'tmp_config.php')) {
			unlink(TMP . 'tmp_config.php');
		}
	}

/**
 * testBuildFields
 *
 * @return void
 * @access public
 */
	public function testBuildFields() {
		$result = $this->Config->buildFields();
		$this->assertTrue(empty($result));
	}

/**
 * Test write method
 *
 * @return void
 * @access public
 */
	public function testWrite() {
		$testFile = 'tmp_config.php';
		Config::$configFile = $testFile;

		$f = new Exception('f');
		$data = array('Config' => array(
			'a' => array(
				'b' => 'c',
				'd'),
			'e' => $f,
			'g' => array(
				'h' => array(
					'i'))));
		$this->assertTrue($this->Config->write($data));
		$this->assertTrue(is_file(TMP . $testFile));

		$result = $this->Config->find('all', array('order' => 'namespace ASC'));
		$expected = array(
			'Media.imageSizes.large.width' => 500,
			'Media.imageSizes.large.height' => 500,
{'fraction_non_alphanumeric': 0.21495159555396198, 'fraction_numerical': 0.010039440659734672, 'mean_word_length': 3.6375727348295928, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 118, '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': '910548', 'n_tokens_mistral': 2239, 'n_tokens_neox': 1953, 'n_words': 374}