<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       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
namespace Cake\Test\TestCase\Database\Schema;

use Cake\Core\Configure;
use Cake\Datasource\ConnectionManager;
use Cake\Database\Schema\Collection as SchemaCollection;
use Cake\Database\Schema\SqlserverSchema;
use Cake\Database\Schema\Table;
use Cake\TestSuite\TestCase;

/**
 * SQL Server schema test case.
 */
class SqlserverSchemaTest extends TestCase {

/**
 * Set up
 *
 * @return void
 */
	public function setUp() {
		parent::setUp();
		$this->skipUnless(defined('PDO::SQLSRV_ENCODING_UTF8'), 'SQL Server extension not present');
	}

/**
 * Helper method for skipping tests that need a real connection.
 *
 * @return void
 */
	protected function _needsConnection() {
		$config = ConnectionManager::config('test');
		$this->skipIf(strpos($config['className'], 'Sqlserver') === false, 'Not using Sqlserver for test config');
	}

/**
 * Helper method for testing methods.
 *
 * @return void
 */
	protected function _createTables($connection) {
		$this->_needsConnection();

		$connection->execute("IF OBJECT_ID('schema_articles', 'U') IS NOT NULL DROP TABLE schema_articles");
		$connection->execute("IF OBJECT_ID('schema_authors', 'U') IS NOT NULL DROP TABLE schema_authors");

		$table = <<<SQL
CREATE TABLE schema_authors (
id int IDENTITY(1,1) PRIMARY KEY,
name VARCHAR(50),
bio DATE,
created DATETIME
)
SQL;
		$connection->execute($table);

		$table = <<<SQL
CREATE TABLE schema_articles (
id BIGINT PRIMARY KEY,
title VARCHAR(20),
body VARCHAR(1000),
author_id INTEGER NOT NULL,
published BIT DEFAULT 0,
views SMALLINT DEFAULT 0,
created DATETIME,
CONSTRAINT [content_idx] UNIQUE ([title], [body]),
CONSTRAINT [author_idx] FOREIGN KEY ([author_id]) REFERENCES [schema_authors] ([id]) ON DELETE CASCADE ON UPDATE CASCADE
)
SQL;
		$connection->execute($table);
		$connection->execute('CREATE INDEX [author_idx] ON [schema_articles] ([author_id])');
	}

/**
 * Data provider for convert column testing
 *
 * @return array
 */
	public static function convertColumnProvider() {
		return [
			[
				'DATETIME',
				null,
				null,
				null,
				['type' => 'timestamp', 'length' => null]
			],
			[
				'DATE',
				null,
				null,
				null,
				['type' => 'date', 'length' => null]
			],
			[
				'TIME',
				null,
				null,
				null,
				['type' => 'time', 'length' => null]
			],
			[
				'SMALLINT',
				null,
				4,
				null,
				['type' => 'integer', 'length' => 4]
			],
			[
				'INTEGER',
				null,
				null,
				null,
				['type' => 'integer', 'length' => 10]
			],
			[
				'INTEGER',
				null,
				8,
				null,
				['type' => 'integer', 'length' => 8]
			],
			[
				'BIGINT',
				null,
				null,
				null,
				['type' => 'biginteger', 'length' => 20]
			],
			[
				'NUMERIC',
				null,
				15,
				5,
				['type' => 'decimal', 'length' => 15, 'precision' => 5]
			],
			[
				'DECIMAL',
				null,
				11,
				3,
				['type' => 'decimal', 'length' => 11, 'precision' => 3]
			],
			[
				'MONEY',
				null,
				null,
				null,
				['type' => 'decimal', 'length' => null, 'precision' => null]
			],
			[
				'VARCHAR',
				null,
				null,
				null,
				['type' => 'string', 'length' => 255]
			],
			[
				'VARCHAR',
				10,
				null,
				null,
				['type' => 'string', 'length' => 10]
			],
			[
				'CHAR',
				10,
				null,
				null,
				['type' => 'string', 'fixed' => true, 'length' => 10]<commit_msg>Added tests for NVARCHAR and NCHAR<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       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
namespace Cake\Test\TestCase\Database\Schema;

use Cake\Core\Configure;
use Cake\Database\Schema\Collection as SchemaCollection;
use Cake\Database\Schema\SqlserverSchema;
use Cake\Database\Schema\Table;
use Cake\Datasource\ConnectionManager;
use Cake\TestSuite\TestCase;

/**
 * SQL Server schema test case.
 */
class SqlserverSchemaTest extends TestCase {

/**
 * Set up
 *
 * @return void
 */
	public function setUp() {
		parent::setUp();
		$this->skipUnless(defined('PDO::SQLSRV_ENCODING_UTF8'), 'SQL Server extension not present');
	}

/**
 * Helper method for skipping tests that need a real connection.
 *
 * @return void
 */
	protected function _needsConnection() {
		$config = ConnectionManager::config('test');
		$this->skipIf(strpos($config['className'], 'Sqlserver') === false, 'Not using Sqlserver for test config');
	}

/**
 * Helper method for testing methods.
 *
 * @return void
 */
	protected function _createTables($connection) {
		$this->_needsConnection();

		$connection->execute("IF OBJECT_ID('schema_articles', 'U') IS NOT NULL DROP TABLE schema_articles");
		$connection->execute("IF OBJECT_ID('schema_authors', 'U') IS NOT NULL DROP TABLE schema_authors");

		$table = <<<SQL
CREATE TABLE schema_authors (
id int IDENTITY(1,1) PRIMARY KEY,
name VARCHAR(50),
bio DATE,
created DATETIME
)
SQL;
		$connection->execute($table);

		$table = <<<SQL
CREATE TABLE schema_articles (
id BIGINT PRIMARY KEY,
title VARCHAR(20),
body VARCHAR(1000),
author_id INTEGER NOT NULL,
published BIT DEFAULT 0,
views SMALLINT DEFAULT 0,
created DATETIME,
CONSTRAINT [content_idx] UNIQUE ([title], [body]),
CONSTRAINT [author_idx] FOREIGN KEY ([author_id]) REFERENCES [schema_authors] ([id]) ON DELETE CASCADE ON UPDATE CASCADE
)
SQL;
		$connection->execute($table);
		$connection->execute('CREATE INDEX [author_idx] ON [schema_articles] ([author_id])');
	}

/**
 * Data provider for convert column testing
 *
 * @return array
 */
	public static function convertColumnProvider() {
		return [
			[
				'DATETIME',
				null,
				null,
				null,
				['type' => 'timestamp', 'length' => null]
			],
			[
				'DATE',
				null,
				null,
				null,
				['type' => 'date', 'length' => null]
			],
			[
				'TIME',
				null,
				null,
				null,
				['type' => 'time', 'length' => null]
			],
			[
				'SMALLINT',
				null,
				4,
				null,
				['type' => 'integer', 'length' => 4]
			],
			[
				'INTEGER',
				null,
				null,
				null,
				['type' => 'integer', 'length' => 10]
			],
			[
				'INTEGER',
				null,
				8,
				null,
				['type' => 'integer', 'length' => 8]
			],
			[
				'BIGINT',
				null,
				null,
				null,
				['type' => 'biginteger', 'length' => 20]
			],
			[
				'NUMERIC',
				null,
				15,
				5,
				['type' => 'decimal', 'length' => 15, 'precision' => 5]
			],
			[
				'DECIMAL',
				null,
				11,
				3,
				['type' => 'decimal', 'length' => 11, 'precision' => 3]
			],
			[
				'MONEY',
				null,
				null,
				null,
				['type' => 'decimal', 'length' => null, 'precision' => null]
			],
			[
				'VARCHAR',
				null,
				null,
				null,
				['type' => 'string', 'length' => 255]
			],
			[
				'VARCHAR',
				10,
				null,
				null,
				['type' => 'string', 'length' => 10]
			],
			[
				'NVARCHAR',
				50,
				null,
				null,
				['type' => 'string', 'length' => 50]
			],
			[
				'CHAR',
				10,
				null,
				null,
				['type' => 'string', 'fixed' => true, 'length' => 10]
			],
			[
				'NCHAR',
				10,
				null,
				null,
				['type' => 'string', 'fixed' => true, 'length' => 10]
{'fraction_non_alphanumeric': 0.16520232644474694, 'fraction_numerical': 0.01262220022274471, 'mean_word_length': 3.0470706059088633, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 84, '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': '5136371', 'n_tokens_mistral': 3443, 'n_tokens_neox': 2704, 'n_words': 714}