<commit_before><?php
/* SVN FILE: $Id$ */
/**
 * Short description for file.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
 * Copyright 2005-2008, Cake Software Foundation, Inc.
 *								1785 E. Sahara Avenue, Suite 490-204
 *								Las Vegas, Nevada 89104
 *
 *  Licensed under The Open Group Test Suite License
 *  Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright		Copyright 2005-2008, Cake Software Foundation, Inc.
 * @link				https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
 * @package			cake.tests
 * @subpackage		cake.tests.cases.libs.controller.components
 * @since			CakePHP(tm) v 1.2.0.5436
 * @version			$Revision$
 * @modifiedby		$LastChangedBy$
 * @lastmodified	$Date$
 * @license			http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
 */
App::import('Core', array('Controller', 'Object'));
App::import('Component', 'Session');
/**
 * SessionTestController class
 *
 * @package		cake.tests
 * @subpackage	cake.tests.cases.libs.controller.components
 */
class SessionTestController extends Controller {
	var $uses = array();

	function session_id() {
		return $this->Session->id();
	}
}
/**
 * OrangeSessionTestController class
 *
 * @package		cake.tests
 * @subpackage	cake.tests.cases.libs.controller.components
 */
class OrangeSessionTestController extends Controller {
	var $uses = array();

	function session_id() {
		return $this->Session->id();
	}
}
/**
 * Short description for class.
 *
 * @package		cake.tests
 * @subpackage	cake.tests.cases.libs.controller.components
 */
class SessionComponentTest extends CakeTestCase {
/**
 * testSessionAutoStart method
 *
 * @access public
 * @return void
 */
	function testSessionAutoStart() {
		Configure::write('Session.start', false);
		$Session =& new SessionComponent();
		$this->assertFalse($Session->__active);
		$this->assertFalse($Session->__started);
		$Session->startup(new SessionTestController());

		Configure::write('Session.start', true);
		$Session =& new SessionComponent();
		$this->assertTrue($Session->__active);
		$this->assertFalse($Session->__started);
		$Session->startup(new SessionTestController());
		$this->assertTrue(isset($_SESSION));

		$Object = new Object();
		$Session =& new SessionComponent();
		$Session->start();
		$expected = $Session->id();

		$result = $Object->requestAction('/session_test/session_id');
		$this->assertEqual($result, $expected);

		$result = $Object->requestAction('/orange_session_test/session_id');
		$this->assertEqual($result, $expected);
	}
/**
 * testSessionInitialize method
 *
 * @access public
 * @return void
 */
	function testSessionInitialize() {
		$Session =& new SessionComponent();

		$this->assertEqual($Session->__bare, 0);

		$Session->initialize(new SessionTestController());
		$this->assertEqual($Session->__bare, 0);

		$sessionController =& new SessionTestController();
		$sessionController->params['bare'] = 1;
		$Session->initialize($sessionController);
		$this->assertEqual($Session->__bare, 1);
	}
/**
 * testSessionActivate method
 *
 * @access public
 * @return void
 */
	function testSessionActivate() {
		$Session =& new SessionComponent();

		$this->assertTrue($Session->__active);
		$this->assertNull($Session->activate());
		$this->assertTrue($Session->__active);

		Configure::write('Session.start', false);
		$Session =& new SessionComponent();
		$this->assertFalse($Session->__active);
		$this->assertNull($Session->activate());
		$this->assertTrue($Session->__active);
		Configure::write('Session.start', true);
		$Session->destroy();
	}
/**
 * testSessionValid method
 *
 * @access public
 * @return void
 */
	function testSessionValid() {
		$Session =& new SessionComponent();

		$this->assertTrue($Session->valid());

		$Session->_userAgent = 'rweerw';
		$this->assertFalse($Session->valid());

		Configure::write('Session.start', false);
		$Session =& new SessionComponent();
		$this->assertFalse($Session->__active);
		$this->assertFalse($Session->valid());
		Configure::write('Session.start', true);
	}
/**
 * testSessionError method
 *
 * @access public
 * @return void
 */
	function testSessionError() {
		$Session =& new SessionComponent();

		$this->assertFalse($Session->error());

		Configure::write('Session.start', false);
		$Session =& new SessionComponent();
		$this->assertFalse($Session->__active);
		$this->assertFalse($Session->error());
		Configure::write('Session.start', true);<commit_msg>Proving bad condition structure when Session.checkAgent equal to false. Refs #5450<commit_after><?php
/* SVN FILE: $Id$ */
/**
 * Short description for file.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
 * Copyright 2005-2008, Cake Software Foundation, Inc.
 *								1785 E. Sahara Avenue, Suite 490-204
 *								Las Vegas, Nevada 89104
 *
 *  Licensed under The Open Group Test Suite License
 *  Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright		Copyright 2005-2008, Cake Software Foundation, Inc.
 * @link				https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
 * @package			cake.tests
 * @subpackage		cake.tests.cases.libs.controller.components
 * @since			CakePHP(tm) v 1.2.0.5436
 * @version			$Revision$
 * @modifiedby		$LastChangedBy$
 * @lastmodified	$Date$
 * @license			http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
 */
App::import('Core', array('Controller', 'Object'));
App::import('Component', 'Session');
/**
 * SessionTestController class
 *
 * @package		cake.tests
 * @subpackage	cake.tests.cases.libs.controller.components
 */
class SessionTestController extends Controller {
	var $uses = array();

	function session_id() {
		return $this->Session->id();
	}
}
/**
 * OrangeSessionTestController class
 *
 * @package		cake.tests
 * @subpackage	cake.tests.cases.libs.controller.components
 */
class OrangeSessionTestController extends Controller {
	var $uses = array();

	function session_id() {
		return $this->Session->id();
	}
}
/**
 * Short description for class.
 *
 * @package		cake.tests
 * @subpackage	cake.tests.cases.libs.controller.components
 */
class SessionComponentTest extends CakeTestCase {
/**
 * testSessionAutoStart method
 *
 * @access public
 * @return void
 */
	function testSessionAutoStart() {
		Configure::write('Session.start', false);
		$Session =& new SessionComponent();
		$this->assertFalse($Session->__active);
		$this->assertFalse($Session->__started);
		$Session->startup(new SessionTestController());

		Configure::write('Session.start', true);
		$Session =& new SessionComponent();
		$this->assertTrue($Session->__active);
		$this->assertFalse($Session->__started);
		$Session->startup(new SessionTestController());
		$this->assertTrue(isset($_SESSION));

		$Object = new Object();
		$Session =& new SessionComponent();
		$Session->start();
		$expected = $Session->id();

		$result = $Object->requestAction('/session_test/session_id');
		$this->assertEqual($result, $expected);

		$result = $Object->requestAction('/orange_session_test/session_id');
		$this->assertEqual($result, $expected);
	}
/**
 * testSessionInitialize method
 *
 * @access public
 * @return void
 */
	function testSessionInitialize() {
		$Session =& new SessionComponent();

		$this->assertEqual($Session->__bare, 0);

		$Session->initialize(new SessionTestController());
		$this->assertEqual($Session->__bare, 0);

		$sessionController =& new SessionTestController();
		$sessionController->params['bare'] = 1;
		$Session->initialize($sessionController);
		$this->assertEqual($Session->__bare, 1);
	}
/**
 * testSessionActivate method
 *
 * @access public
 * @return void
 */
	function testSessionActivate() {
		$Session =& new SessionComponent();

		$this->assertTrue($Session->__active);
		$this->assertNull($Session->activate());
		$this->assertTrue($Session->__active);

		Configure::write('Session.start', false);
		$Session =& new SessionComponent();
		$this->assertFalse($Session->__active);
		$this->assertNull($Session->activate());
		$this->assertTrue($Session->__active);
		Configure::write('Session.start', true);
		$Session->destroy();
	}
/**
 * testSessionValid method
 *
 * @access public
 * @return void
 */
	function testSessionValid() {
		$Session =& new SessionComponent();

		$this->assertTrue($Session->valid());

		$Session->_userAgent = 'rweerw';
		$this->assertFalse($Session->valid());

		Configure::write('Session.start', false);
		$Session =& new SessionComponent();
		$this->assertFalse($Session->__active);
		$this->assertFalse($Session->valid());
		Configure::write('Session.start', true);

		$Session =& new SessionComponent();
		$Session->time = $Session->read('Config.time') + 1;
		$this->assertFalse($Session->valid());

		Configure::write('Session.checkAgent', false);
		$Session =& new SessionComponent();
		$Session->time = $Session->read('Config.time') + 1;
		$this->assertFalse($Session->valid());
		Configure::write('Session.checkAgent', true);
	}
/**
 * testSessionError method
 *
 * @access public
 * @return void
 */
	function testSessionError() {
		$Session =& new SessionComponent();

		$this->assertFalse($Session->error());

		Configure::write('Session.start', false);
		$Session =& new SessionComponent();
		$this->assertFalse($Session->__active);
		$this->assertFalse($Session->error());
		Configure::write('Session.start', true);
{'fraction_non_alphanumeric': 0.1675376254180602, 'fraction_numerical': 0.009824414715719064, 'mean_word_length': 4.903146206045651, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 129, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2492444', 'n_tokens_mistral': 3145, 'n_tokens_neox': 2815, 'n_words': 581}