<commit_before><?php
/**
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @since         3.0.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
namespace Cake\Test\TestCase\ORM;

use Cake\ORM\Association;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;

/**
 * A Test double used to assert that default tables are created
 *
 */
class TestTable extends Table {

}

/**
 * Tests Association class
 *
 */
class AssociationTest extends \Cake\TestSuite\TestCase {

/**
 * Set up
 *
 * @return void
 */
	public function setUp() {
		parent::setUp();
		$this->source = new TestTable;
		$config = [
			'className' => '\Cake\Test\TestCase\ORM\TestTable',
			'foreignKey' => 'a_key',
			'conditions' => ['field' => 'value'],
			'dependent' => true,
			'sourceTable' => $this->source,
			'joinType' => 'INNER'
		];
		$this->association = $this->getMock(
			'\Cake\ORM\Association',
			[
				'_options', 'attachTo', '_joinCondition', 'cascadeDelete', 'isOwningSide',
				'saveAssociated', 'eagerLoader', 'type'
			],
			['Foo', $config]
		);
	}

/**
 * Tear down
 *
 * @return void
 */
	public function tearDown() {
		parent::tearDown();
		TableRegistry::clear();
	}

/**
 * Tests that _options acts as a callback where subclasses can add their own
 * initialization code based on the passed configuration array
 *
 * @return void
 */
	public function testOptionsIsCalled() {
		$options = ['foo' => 'bar'];
		$this->association->expects($this->once())->method('_options')->with($options);
		$this->association->__construct('Name', $options);
	}

/**
 * Tests that name() returns the correct configure association name
 *
 * @return void
 */
	public function testName() {
		$this->assertEquals('Foo', $this->association->name());
		$this->association->name('Bar');
		$this->assertEquals('Bar', $this->association->name());
	}

/**
 * Tests that name() returns the correct configured value
 *
 * @return void
 */
	public function testForeignKey() {
		$this->assertEquals('a_key', $this->association->foreignKey());
		$this->association->foreignKey('another_key');
		$this->assertEquals('another_key', $this->association->foreignKey());
	}

/**
 * Tests that conditions() returns the correct configured value
 *
 * @return void
 */
	public function testConditions() {<commit_msg>Added cascadeCallbacks accessor/mutator test<commit_after><?php
/**
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @since         3.0.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
namespace Cake\Test\TestCase\ORM;

use Cake\ORM\Association;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;

/**
 * A Test double used to assert that default tables are created
 *
 */
class TestTable extends Table {

}

/**
 * Tests Association class
 *
 */
class AssociationTest extends \Cake\TestSuite\TestCase {

/**
 * Set up
 *
 * @return void
 */
	public function setUp() {
		parent::setUp();
		$this->source = new TestTable;
		$config = [
			'className' => '\Cake\Test\TestCase\ORM\TestTable',
			'foreignKey' => 'a_key',
			'conditions' => ['field' => 'value'],
			'dependent' => true,
			'sourceTable' => $this->source,
			'joinType' => 'INNER'
		];
		$this->association = $this->getMock(
			'\Cake\ORM\Association',
			[
				'_options', 'attachTo', '_joinCondition', 'cascadeDelete', 'isOwningSide',
				'saveAssociated', 'eagerLoader', 'type'
			],
			['Foo', $config]
		);
	}

/**
 * Tear down
 *
 * @return void
 */
	public function tearDown() {
		parent::tearDown();
		TableRegistry::clear();
	}

/**
 * Tests that _options acts as a callback where subclasses can add their own
 * initialization code based on the passed configuration array
 *
 * @return void
 */
	public function testOptionsIsCalled() {
		$options = ['foo' => 'bar'];
		$this->association->expects($this->once())->method('_options')->with($options);
		$this->association->__construct('Name', $options);
	}

/**
 * Tests that name() returns the correct configure association name
 *
 * @return void
 */
	public function testName() {
		$this->assertEquals('Foo', $this->association->name());
		$this->association->name('Bar');
		$this->assertEquals('Bar', $this->association->name());
	}

/**
 * Tests that cascadeCallbacks() returns the correct configured value
 *
 * @return void
 */
	public function testCascadeCallbacks() {
		$this->assertSame(false, $this->association->cascadeCallbacks());
		$this->association->cascadeCallbacks(true);
		$this->assertSame(true, $this->association->cascadeCallbacks());
	}

/**
 * Tests that name() returns the correct configured value
 *
 * @return void
 */
	public function testForeignKey() {
		$this->assertEquals('a_key', $this->association->foreignKey());
		$this->association->foreignKey('another_key');
		$this->assertEquals('another_key', $this->association->foreignKey());
	}

/**
 * Tests that conditions() returns the correct configured value
 *
 * @return void
 */
	public function testConditions() {
{'fraction_non_alphanumeric': 0.16256242465989323, 'fraction_numerical': 0.0010332357499569485, 'mean_word_length': 4.0285714285714285, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '960983', 'n_tokens_mistral': 1883, 'n_tokens_neox': 1743, 'n_words': 449}