mirror of
				https://github.com/brmlab/brmsklad.git
				synced 2025-10-31 16:23:59 +01:00 
			
		
		
		
	Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
		
							parent
							
								
									5a580df460
								
							
						
					
					
						commit
						235a541597
					
				
					 793 changed files with 60746 additions and 23753 deletions
				
			
		
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -2,19 +2,17 @@ | |||
| /** | ||||
|  * DboPostgresTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * | ||||
|  * Licensed under The MIT License | ||||
|  * Redistributions of files must retain the above copyright notice. | ||||
|  * | ||||
|  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP(tm) Project | ||||
|  * @package       Cake.Test.Case.Model.Datasource.Database | ||||
|  * @since         CakePHP(tm) v 1.2.0 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('Model', 'Model'); | ||||
|  | @ -66,17 +64,10 @@ class DboPostgresTestDb extends Postgres { | |||
|  */ | ||||
| class PostgresTestModel extends Model { | ||||
| 
 | ||||
| /** | ||||
|  * name property | ||||
|  * | ||||
|  * @var string 'PostgresTestModel' | ||||
|  */ | ||||
| 	public $name = 'PostgresTestModel'; | ||||
| 
 | ||||
| /** | ||||
|  * useTable property | ||||
|  * | ||||
|  * @var bool false | ||||
|  * @var bool | ||||
|  */ | ||||
| 	public $useTable = false; | ||||
| 
 | ||||
|  | @ -141,7 +132,8 @@ class PostgresTestModel extends Model { | |||
| 			'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''), | ||||
| 			'last_login' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''), | ||||
| 			'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), | ||||
| 			'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) | ||||
| 			'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null), | ||||
| 			'some_uuid' => array('type' => 'uuid', 'null' => '1', 'default' => null), | ||||
| 		); | ||||
| 	} | ||||
| 
 | ||||
|  | @ -154,17 +146,10 @@ class PostgresTestModel extends Model { | |||
|  */ | ||||
| class PostgresClientTestModel extends Model { | ||||
| 
 | ||||
| /** | ||||
|  * name property | ||||
|  * | ||||
|  * @var string 'PostgresClientTestModel' | ||||
|  */ | ||||
| 	public $name = 'PostgresClientTestModel'; | ||||
| 
 | ||||
| /** | ||||
|  * useTable property | ||||
|  * | ||||
|  * @var bool false | ||||
|  * @var bool | ||||
|  */ | ||||
| 	public $useTable = false; | ||||
| 
 | ||||
|  | @ -178,8 +163,8 @@ class PostgresClientTestModel extends Model { | |||
| 			'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'), | ||||
| 			'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), | ||||
| 			'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), | ||||
| 			'created' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''), | ||||
| 			'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) | ||||
| 			'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'length' => ''), | ||||
| 			'updated' => array('type' => 'datetime', 'null' => true, 'default' => null, 'length' => null) | ||||
| 		); | ||||
| 	} | ||||
| 
 | ||||
|  | @ -196,7 +181,7 @@ class PostgresTest extends CakeTestCase { | |||
|  * Do not automatically load fixtures for each test, they will be loaded manually | ||||
|  * using CakeTestCase::loadFixtures | ||||
|  * | ||||
|  * @var boolean | ||||
|  * @var bool | ||||
|  */ | ||||
| 	public $autoFixtures = false; | ||||
| 
 | ||||
|  | @ -227,8 +212,10 @@ class PostgresTest extends CakeTestCase { | |||
| /** | ||||
|  * Sets up a Dbo class instance for testing | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function setUp() { | ||||
| 		parent::setUp(); | ||||
| 		Configure::write('Cache.disable', true); | ||||
| 		$this->Dbo = ConnectionManager::getDataSource('test'); | ||||
| 		$this->skipIf(!($this->Dbo instanceof Postgres)); | ||||
|  | @ -239,8 +226,10 @@ class PostgresTest extends CakeTestCase { | |||
| /** | ||||
|  * Sets up a Dbo class instance for testing | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function tearDown() { | ||||
| 		parent::tearDown(); | ||||
| 		Configure::write('Cache.disable', false); | ||||
| 		unset($this->Dbo2); | ||||
| 	} | ||||
|  | @ -248,6 +237,7 @@ class PostgresTest extends CakeTestCase { | |||
| /** | ||||
|  * Test field quoting method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testFieldQuoting() { | ||||
| 		$fields = array( | ||||
|  | @ -268,7 +258,8 @@ class PostgresTest extends CakeTestCase { | |||
| 			'"PostgresTestModel"."comments" AS "PostgresTestModel__comments"', | ||||
| 			'"PostgresTestModel"."last_login" AS "PostgresTestModel__last_login"', | ||||
| 			'"PostgresTestModel"."created" AS "PostgresTestModel__created"', | ||||
| 			'"PostgresTestModel"."updated" AS "PostgresTestModel__updated"' | ||||
| 			'"PostgresTestModel"."updated" AS "PostgresTestModel__updated"', | ||||
| 			'"PostgresTestModel"."some_uuid" AS "PostgresTestModel__some_uuid"' | ||||
| 		); | ||||
| 
 | ||||
| 		$result = $this->Dbo->fields($this->model); | ||||
|  | @ -307,6 +298,15 @@ class PostgresTest extends CakeTestCase { | |||
| 		$this->assertEquals('string', $this->Dbo2->column('character varying')); | ||||
| 		$this->assertEquals('time', $this->Dbo2->column('time without time zone')); | ||||
| 		$this->assertEquals('datetime', $this->Dbo2->column('timestamp without time zone')); | ||||
| 		$this->assertEquals('decimal', $this->Dbo2->column('decimal')); | ||||
| 		$this->assertEquals('decimal', $this->Dbo2->column('numeric')); | ||||
| 		$this->assertEquals('float', $this->Dbo2->column('float')); | ||||
| 		$this->assertEquals('float', $this->Dbo2->column('double precision')); | ||||
| 		$this->assertEquals('uuid', $this->Dbo2->column('uuid')); | ||||
| 
 | ||||
| 		$result = $this->Dbo2->column('bigint'); | ||||
| 		$expected = 'biginteger'; | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -321,8 +321,8 @@ class PostgresTest extends CakeTestCase { | |||
| 		$this->assertEquals("0", $this->Dbo->value('0', 'integer')); | ||||
| 		$this->assertEquals('NULL', $this->Dbo->value('', 'integer')); | ||||
| 		$this->assertEquals('NULL', $this->Dbo->value('', 'float')); | ||||
| 		$this->assertEquals("NULL", $this->Dbo->value('', 'integer', false)); | ||||
| 		$this->assertEquals("NULL", $this->Dbo->value('', 'float', false)); | ||||
| 		$this->assertEquals('""', $this->Dbo->value('', 'integer', false)); | ||||
| 		$this->assertEquals('""', $this->Dbo->value('', 'float', false)); | ||||
| 		$this->assertEquals("'0.0'", $this->Dbo->value('0.0', 'float')); | ||||
| 
 | ||||
| 		$this->assertEquals("'TRUE'", $this->Dbo->value('t', 'boolean')); | ||||
|  | @ -339,6 +339,8 @@ class PostgresTest extends CakeTestCase { | |||
| 		$this->assertEquals("'TRUE'", $this->Dbo->value('1', 'boolean')); | ||||
| 		$this->assertEquals("NULL", $this->Dbo->value(null, 'boolean')); | ||||
| 		$this->assertEquals("NULL", $this->Dbo->value(array())); | ||||
| 		$this->assertEquals("'550e8400-e29b-41d4-a716-446655440000'", $this->Dbo->value('550e8400-e29b-41d4-a716-446655440000', 'uuid')); | ||||
| 		$this->assertEquals("NULL", $this->Dbo->value(null, 'uuid')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -348,7 +350,8 @@ class PostgresTest extends CakeTestCase { | |||
|  */ | ||||
| 	public function testLocalizedFloats() { | ||||
| 		$restore = setlocale(LC_NUMERIC, 0); | ||||
| 		setlocale(LC_NUMERIC, 'de_DE'); | ||||
| 
 | ||||
| 		$this->skipIf(setlocale(LC_NUMERIC, 'de_DE') === false, "The German locale isn't available."); | ||||
| 
 | ||||
| 		$result = $this->db->value(3.141593, 'float'); | ||||
| 		$this->assertEquals("3.141593", $result); | ||||
|  | @ -482,6 +485,22 @@ class PostgresTest extends CakeTestCase { | |||
| 		$this->assertEquals($data, $result['BinaryTest']['data']); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Tests passing PostgreSQL regular expression operators when building queries | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testRegexpOperatorConditionsParsing() { | ||||
| 		$this->assertSame(' WHERE "name" ~ \'[a-z_]+\'', $this->Dbo->conditions(array('name ~' => '[a-z_]+'))); | ||||
| 		$this->assertSame(' WHERE "name" ~* \'[a-z_]+\'', $this->Dbo->conditions(array('name ~*' => '[a-z_]+'))); | ||||
| 		$this->assertSame(' WHERE "name" !~ \'[a-z_]+\'', $this->Dbo->conditions(array('name !~' => '[a-z_]+'))); | ||||
| 		$this->assertSame(' WHERE "name" !~* \'[a-z_]+\'', $this->Dbo->conditions(array('name !~*' => '[a-z_]+'))); | ||||
| 		$this->assertSame( | ||||
| 			' WHERE EXTRACT( \'YEAR\' FROM "User"."birthday" ) = 2015', | ||||
| 			$this->Dbo->conditions(array('EXTRACT( \'YEAR\' FROM User.birthday )' => 2015)) | ||||
| 		); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Tests the syntax of generated schema indexes | ||||
|  * | ||||
|  | @ -530,23 +549,27 @@ class PostgresTest extends CakeTestCase { | |||
| 			id serial NOT NULL, | ||||
| 			"varchar" character varying(40) NOT NULL, | ||||
| 			"full_length" character varying NOT NULL, | ||||
| 			"huge_int" bigint NOT NULL, | ||||
| 			"timestamp" timestamp without time zone, | ||||
| 			"date" date, | ||||
| 			CONSTRAINT test_data_types_pkey PRIMARY KEY (id) | ||||
| 		)'); | ||||
| 
 | ||||
| 		$model = new Model(array('name' => 'DatatypeTest', 'ds' => 'test')); | ||||
| 		$schema = new CakeSchema(array('connection' => 'test')); | ||||
| 		$result = $schema->read(array( | ||||
| 			'connection' => 'test', | ||||
| 			'models' => array('DatatypeTest') | ||||
| 		)); | ||||
| 		$schema->tables = array('datatype_tests' => $result['tables']['missing']['datatype_tests']); | ||||
| 
 | ||||
| 		$schema->tables = array( | ||||
| 			'datatype_tests' => $result['tables']['missing']['datatype_tests'] | ||||
| 		); | ||||
| 		$result = $db1->createSchema($schema, 'datatype_tests'); | ||||
| 
 | ||||
| 		$this->assertNotRegExp('/timestamp DEFAULT/', $result); | ||||
| 		$this->assertRegExp('/\"full_length\"\s*text\s.*,/', $result); | ||||
| 		$this->assertRegExp('/timestamp\s*,/', $result); | ||||
| 		$this->assertContains('timestamp ,', $result); | ||||
| 		$this->assertContains('"huge_int" bigint NOT NULL,', $result); | ||||
| 
 | ||||
| 		$db1->query('DROP TABLE ' . $db1->fullTableName('datatype_tests')); | ||||
| 
 | ||||
|  | @ -562,6 +585,38 @@ class PostgresTest extends CakeTestCase { | |||
| 		$db1->query('DROP TABLE ' . $db1->fullTableName('datatype_tests')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testCakeSchemaBegserial method | ||||
|  * | ||||
|  * Test that schema generated postgresql queries are valid. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCakeSchemaBigserial() { | ||||
| 		$db1 = ConnectionManager::getDataSource('test'); | ||||
| 		$db1->cacheSources = false; | ||||
| 
 | ||||
| 		$db1->rawQuery('CREATE TABLE ' . $db1->fullTableName('bigserial_tests') . ' ( | ||||
| 			"id" bigserial NOT NULL, | ||||
| 			"varchar" character varying(40) NOT NULL, | ||||
| 			PRIMARY KEY ("id") | ||||
| 		)'); | ||||
| 
 | ||||
| 		$schema = new CakeSchema(array('connection' => 'test')); | ||||
| 		$result = $schema->read(array( | ||||
| 			'connection' => 'test', | ||||
| 			'models' => array('BigserialTest') | ||||
| 		)); | ||||
| 		$schema->tables = array( | ||||
| 			'bigserial_tests' => $result['tables']['missing']['bigserial_tests'] | ||||
| 		); | ||||
| 		$result = $db1->createSchema($schema, 'bigserial_tests'); | ||||
| 
 | ||||
| 		$this->assertContains('"id" bigserial NOT NULL,', $result); | ||||
| 
 | ||||
| 		$db1->query('DROP TABLE ' . $db1->fullTableName('bigserial_tests')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test index generation from table info. | ||||
|  * | ||||
|  | @ -657,6 +712,70 @@ class PostgresTest extends CakeTestCase { | |||
| 		$this->assertNotRegExp('/varchar\(36\) NOT NULL/i', $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test the alterSchema changing boolean to integer | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAlterSchemaBooleanToIntegerField() { | ||||
| 		$default = array( | ||||
| 			'connection' => 'test', | ||||
| 			'name' => 'BoolField', | ||||
| 			'bool_fields' => array( | ||||
| 				'id' => array('type' => 'integer', 'key' => 'primary'), | ||||
| 				'name' => array('type' => 'string', 'length' => 50), | ||||
| 				'active' => array('type' => 'boolean', 'null' => false), | ||||
| 			) | ||||
| 		); | ||||
| 		$Old = new CakeSchema($default); | ||||
| 		$result = $this->Dbo->query($this->Dbo->createSchema($Old)); | ||||
| 		$this->assertTrue($result); | ||||
| 
 | ||||
| 		$modified = $default; | ||||
| 		$modified['bool_fields']['active'] = array('type' => 'integer', 'null' => true); | ||||
| 
 | ||||
| 		$New = new CakeSchema($modified); | ||||
| 		$query = $this->Dbo->alterSchema($New->compare($Old)); | ||||
| 		$result = $this->Dbo->query($query); | ||||
| 		$this->Dbo->query($this->Dbo->dropSchema($Old)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test the alterSchema changing text to integer | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAlterSchemaTextToIntegerField() { | ||||
| 		$default = array( | ||||
| 			'connection' => 'test', | ||||
| 			'name' => 'TextField', | ||||
| 			'text_fields' => array( | ||||
| 				'id' => array('type' => 'integer', 'key' => 'primary'), | ||||
| 				'name' => array('type' => 'string', 'length' => 50), | ||||
| 				'active' => array('type' => 'text', 'null' => false), | ||||
| 			) | ||||
| 		); | ||||
| 		$Old = new CakeSchema($default); | ||||
| 		$result = $this->Dbo->query($this->Dbo->createSchema($Old)); | ||||
| 		$this->assertTrue($result); | ||||
| 
 | ||||
| 		$modified = $default; | ||||
| 		$modified['text_fields']['active'] = array('type' => 'integer', 'null' => true); | ||||
| 
 | ||||
| 		$New = new CakeSchema($modified); | ||||
| 		$this->Dbo->query($this->Dbo->alterSchema($New->compare($Old))); | ||||
| 		$result = $this->Dbo->describe('text_fields'); | ||||
| 
 | ||||
| 		$this->Dbo->query($this->Dbo->dropSchema($Old)); | ||||
| 		$expected = array( | ||||
| 			'type' => 'integer', | ||||
| 			'null' => true, | ||||
| 			'default' => null, | ||||
| 			'length' => null, | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result['active']); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test the alter index capabilities of postgres | ||||
|  * | ||||
|  | @ -732,6 +851,25 @@ class PostgresTest extends CakeTestCase { | |||
| 		$this->Dbo->query($this->Dbo->dropSchema($schema1)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test the alterSchema RENAME statements | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAlterSchemaRenameTo() { | ||||
| 		$query = $this->Dbo->alterSchema(array( | ||||
| 			'posts' => array( | ||||
| 				'change' => array( | ||||
| 					'title' => array('name' => 'subject', 'type' => 'string', 'null' => false) | ||||
| 				) | ||||
| 			) | ||||
| 		)); | ||||
| 		$this->assertContains('RENAME "title" TO "subject";', $query); | ||||
| 		$this->assertContains('ALTER COLUMN "subject" TYPE', $query); | ||||
| 		$this->assertNotContains(";\n\tALTER COLUMN \"subject\" TYPE", $query); | ||||
| 		$this->assertNotContains('ALTER COLUMN "title" TYPE "subject"', $query); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test it is possible to use virtual field with postgresql | ||||
|  * | ||||
|  | @ -915,6 +1053,7 @@ class PostgresTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testNestedTransaction() { | ||||
| 		$this->Dbo->useNestedTransactions = true; | ||||
| 		$this->skipIf($this->Dbo->nestedTransactionSupported() === false, 'The Postgres server do not support nested transaction'); | ||||
| 
 | ||||
| 		$this->loadFixtures('Article'); | ||||
|  | @ -942,4 +1081,141 @@ class PostgresTest extends CakeTestCase { | |||
| 		$this->assertNotEmpty($model->read(null, 1)); | ||||
| 	} | ||||
| 
 | ||||
| 	public function testResetSequence() { | ||||
| 		$model = new Article(); | ||||
| 
 | ||||
| 		$table = $this->Dbo->fullTableName($model, false); | ||||
| 		$fields = array( | ||||
| 			'id', 'user_id', 'title', 'body', 'published', | ||||
| 		); | ||||
| 		$values = array( | ||||
| 			array(1, 1, 'test', 'first post', false), | ||||
| 			array(2, 1, 'test 2', 'second post post', false), | ||||
| 		); | ||||
| 		$this->Dbo->insertMulti($table, $fields, $values); | ||||
| 		$sequence = $this->Dbo->getSequence($table); | ||||
| 		$result = $this->Dbo->rawQuery("SELECT nextval('$sequence')"); | ||||
| 		$original = $result->fetch(PDO::FETCH_ASSOC); | ||||
| 
 | ||||
| 		$this->assertTrue($this->Dbo->resetSequence($table, 'id')); | ||||
| 		$result = $this->Dbo->rawQuery("SELECT currval('$sequence')"); | ||||
| 		$new = $result->fetch(PDO::FETCH_ASSOC); | ||||
| 		$this->assertTrue($new['currval'] > $original['nextval'], 'Sequence did not update'); | ||||
| 	} | ||||
| 
 | ||||
| 	public function testSettings() { | ||||
| 		Configure::write('Cache.disable', true); | ||||
| 		$this->Dbo = ConnectionManager::getDataSource('test'); | ||||
| 		$this->skipIf(!($this->Dbo instanceof Postgres)); | ||||
| 
 | ||||
| 		$config2 = $this->Dbo->config; | ||||
| 		$config2['settings']['datestyle'] = 'sql, dmy'; | ||||
| 		ConnectionManager::create('test2', $config2); | ||||
| 		$dbo2 = new Postgres($config2, true); | ||||
| 		$expected = array(array('r' => date('d/m/Y'))); | ||||
| 		$r = $dbo2->fetchRow('SELECT now()::date AS "r"'); | ||||
| 		$this->assertEquals($expected, $r); | ||||
| 		$dbo2->execute('SET DATESTYLE TO ISO'); | ||||
| 		$dbo2->disconnect(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test the limit function. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testLimit() { | ||||
| 		$db = $this->Dbo; | ||||
| 
 | ||||
| 		$result = $db->limit('0'); | ||||
| 		$this->assertNull($result); | ||||
| 
 | ||||
| 		$result = $db->limit('10'); | ||||
| 		$this->assertEquals(' LIMIT 10', $result); | ||||
| 
 | ||||
| 		$result = $db->limit('FARTS', 'BOOGERS'); | ||||
| 		$this->assertEquals(' LIMIT 0 OFFSET 0', $result); | ||||
| 
 | ||||
| 		$result = $db->limit(20, 10); | ||||
| 		$this->assertEquals(' LIMIT 20 OFFSET 10', $result); | ||||
| 
 | ||||
| 		$result = $db->limit(10, 300000000000000000000000000000); | ||||
| 		$scientificNotation = sprintf('%.1E', 300000000000000000000000000000); | ||||
| 		$this->assertNotContains($scientificNotation, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that postgres describes UUID columns correctly. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testDescribeUuid() { | ||||
| 		$db = $this->Dbo; | ||||
| 		$db->execute('CREATE TABLE test_uuid_describe (id UUID PRIMARY KEY, name VARCHAR(255))'); | ||||
| 		$data = $db->describe('test_uuid_describe'); | ||||
| 
 | ||||
| 		$expected = array( | ||||
| 			'type' => 'uuid', | ||||
| 			'null' => false, | ||||
| 			'default' => null, | ||||
| 			'length' => 36, | ||||
| 		); | ||||
| 		$this->assertSame($expected, $data['id']); | ||||
| 		$db->execute('DROP TABLE test_uuid_describe'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test describe() behavior for timestamp columns. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testDescribeTimestamp() { | ||||
| 		$this->loadFixtures('User'); | ||||
| 		$model = ClassRegistry::init('User'); | ||||
| 		$result = $this->Dbo->describe($model); | ||||
| 		$expected = array( | ||||
| 			'id' => array( | ||||
| 				'type' => 'integer', | ||||
| 				'null' => false, | ||||
| 				'default' => null, | ||||
| 				'length' => 11, | ||||
| 				'key' => 'primary' | ||||
| 			), | ||||
| 			'user' => array( | ||||
| 				'type' => 'string', | ||||
| 				'null' => true, | ||||
| 				'default' => null, | ||||
| 				'length' => 255 | ||||
| 			), | ||||
| 			'password' => array( | ||||
| 				'type' => 'string', | ||||
| 				'null' => true, | ||||
| 				'default' => null, | ||||
| 				'length' => 255 | ||||
| 			), | ||||
| 			'created' => array( | ||||
| 				'type' => 'datetime', | ||||
| 				'null' => true, | ||||
| 				'default' => null, | ||||
| 				'length' => null | ||||
| 			), | ||||
| 			'updated' => array( | ||||
| 				'type' => 'datetime', | ||||
| 				'null' => true, | ||||
| 				'default' => null, | ||||
| 				'length' => null | ||||
| 			) | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test build column working for new uuid types | ||||
|  */ | ||||
| 	public function testBuildColumnUuid() { | ||||
| 		$column = array('name' => 'col1', 'type' => 'uuid'); | ||||
| 		$result = $this->Dbo2->buildColumn($column); | ||||
| 
 | ||||
| 		$this->assertEquals('"col1" uuid', $result); | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -2,20 +2,20 @@ | |||
| /** | ||||
|  * DboSqliteTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.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 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP(tm) Project | ||||
|  * @package       Cake.Test.Case.Model.Datasource.Database | ||||
|  * @since         CakePHP(tm) v 1.2.0 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('Model', 'Model'); | ||||
| App::uses('AppModel', 'Model'); | ||||
| App::uses('Sqlite', 'Model/Datasource/Database'); | ||||
|  | @ -68,7 +68,7 @@ class SqliteTest extends CakeTestCase { | |||
| /** | ||||
|  * Do not automatically load fixtures for each test, they will be loaded manually using CakeTestCase::loadFixtures | ||||
|  * | ||||
|  * @var boolean | ||||
|  * @var bool | ||||
|  */ | ||||
| 	public $autoFixtures = false; | ||||
| 
 | ||||
|  | @ -77,7 +77,7 @@ class SqliteTest extends CakeTestCase { | |||
|  * | ||||
|  * @var object | ||||
|  */ | ||||
| 	public $fixtures = array('core.user', 'core.uuid'); | ||||
| 	public $fixtures = array('core.user', 'core.uuid', 'core.datatype'); | ||||
| 
 | ||||
| /** | ||||
|  * Actual DB connection used in testing | ||||
|  | @ -89,6 +89,7 @@ class SqliteTest extends CakeTestCase { | |||
| /** | ||||
|  * Sets up a Dbo class instance for testing | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function setUp() { | ||||
| 		parent::setUp(); | ||||
|  | @ -102,6 +103,7 @@ class SqliteTest extends CakeTestCase { | |||
| /** | ||||
|  * Sets up a Dbo class instance for testing | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function tearDown() { | ||||
| 		parent::tearDown(); | ||||
|  | @ -111,6 +113,7 @@ class SqliteTest extends CakeTestCase { | |||
| /** | ||||
|  * Tests that SELECT queries from DboSqlite::listSources() are not cached | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testTableListCacheDisabling() { | ||||
| 		$this->assertFalse(in_array('foo_test', $this->Dbo->listSources())); | ||||
|  | @ -157,6 +160,7 @@ class SqliteTest extends CakeTestCase { | |||
| /** | ||||
|  * Tests that cached table descriptions are saved under the sanitized key name | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCacheKeyName() { | ||||
| 		Configure::write('Cache.disable', false); | ||||
|  | @ -164,8 +168,13 @@ class SqliteTest extends CakeTestCase { | |||
| 		$dbName = 'db' . rand() . '$(*%&).db'; | ||||
| 		$this->assertFalse(file_exists(TMP . $dbName)); | ||||
| 
 | ||||
| 		$config = $this->Dbo->config; | ||||
| 		$db = new Sqlite(array_merge($this->Dbo->config, array('database' => TMP . $dbName))); | ||||
| 		try { | ||||
| 			$db = new Sqlite(array_merge($this->Dbo->config, array('database' => TMP . $dbName))); | ||||
| 		} catch (MissingConnectionException $e) { | ||||
| 			// This might be caused by NTFS file systems, where '*' is a forbidden character. Repeat without this character.
 | ||||
| 			$dbName = str_replace('*', '', $dbName); | ||||
| 			$db = new Sqlite(array_merge($this->Dbo->config, array('database' => TMP . $dbName))); | ||||
| 		} | ||||
| 		$this->assertTrue(file_exists(TMP . $dbName)); | ||||
| 
 | ||||
| 		$db->execute("CREATE TABLE test_list (id VARCHAR(255));"); | ||||
|  | @ -253,6 +262,27 @@ class SqliteTest extends CakeTestCase { | |||
| 		$result = $this->Dbo->buildColumn($data); | ||||
| 		$expected = '"testName" integer(10) DEFAULT 10 NOT NULL'; | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$data = array( | ||||
| 			'name' => 'huge', | ||||
| 			'type' => 'biginteger', | ||||
| 			'length' => 20, | ||||
| 			'null' => false, | ||||
| 		); | ||||
| 		$result = $this->Dbo->buildColumn($data); | ||||
| 		$expected = '"huge" bigint(20) NOT NULL'; | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$data = array( | ||||
| 			'name' => 'id', | ||||
| 			'type' => 'biginteger', | ||||
| 			'length' => 20, | ||||
| 			'null' => false, | ||||
| 			'key' => 'primary', | ||||
| 		); | ||||
| 		$result = $this->Dbo->buildColumn($data); | ||||
| 		$expected = '"id" bigint(20) NOT NULL PRIMARY KEY'; | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -262,7 +292,11 @@ class SqliteTest extends CakeTestCase { | |||
|  */ | ||||
| 	public function testDescribe() { | ||||
| 		$this->loadFixtures('User'); | ||||
| 		$Model = new Model(array('name' => 'User', 'ds' => 'test', 'table' => 'users')); | ||||
| 		$Model = new Model(array( | ||||
| 			'name' => 'User', | ||||
| 			'ds' => 'test', | ||||
| 			'table' => 'users' | ||||
| 		)); | ||||
| 
 | ||||
| 		$this->Dbo->cacheSources = true; | ||||
| 		Configure::write('Cache.disable', false); | ||||
|  | @ -310,6 +344,55 @@ class SqliteTest extends CakeTestCase { | |||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that datatypes are reflected | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testDatatypes() { | ||||
| 		$this->loadFixtures('Datatype'); | ||||
| 		$Model = new Model(array( | ||||
| 			'name' => 'Datatype', | ||||
| 			'ds' => 'test', | ||||
| 			'table' => 'datatypes' | ||||
| 		)); | ||||
| 		$result = $this->Dbo->describe($Model); | ||||
| 		$expected = array( | ||||
| 			'id' => array( | ||||
| 				'type' => 'integer', | ||||
| 				'null' => false, | ||||
| 				'default' => '', | ||||
| 				'length' => 11, | ||||
| 				'key' => 'primary', | ||||
| 			), | ||||
| 			'float_field' => array( | ||||
| 				'type' => 'float', | ||||
| 				'null' => false, | ||||
| 				'default' => '', | ||||
| 				'length' => '5,2', | ||||
| 			), | ||||
| 			'decimal_field' => array( | ||||
| 				'type' => 'decimal', | ||||
| 				'null' => true, | ||||
| 				'default' => '0.000', | ||||
| 				'length' => '6,3', | ||||
| 			), | ||||
| 			'huge_int' => array( | ||||
| 				'type' => 'biginteger', | ||||
| 				'null' => true, | ||||
| 				'default' => null, | ||||
| 				'length' => 20, | ||||
| 			), | ||||
| 			'bool' => array( | ||||
| 				'type' => 'boolean', | ||||
| 				'null' => false, | ||||
| 				'default' => '0', | ||||
| 				'length' => null | ||||
| 			), | ||||
| 		); | ||||
| 		$this->assertSame($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that describe does not corrupt UUID primary keys | ||||
|  * | ||||
|  | @ -345,6 +428,40 @@ class SqliteTest extends CakeTestCase { | |||
| 		$this->Dbo->query('DROP TABLE ' . $tableName); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that describe ignores `default current_timestamp` in timestamp columns. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testDescribeHandleCurrentTimestamp() { | ||||
| 		$name = $this->Dbo->fullTableName('timestamp_default_values'); | ||||
| 		$sql = <<<SQL | ||||
| CREATE TABLE $name ( | ||||
| 	id INT NOT NULL, | ||||
| 	phone VARCHAR(10), | ||||
| 	limit_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||||
| 	PRIMARY KEY (id) | ||||
| ); | ||||
| SQL; | ||||
| 		$this->Dbo->execute($sql); | ||||
| 		$model = new Model(array( | ||||
| 			'table' => 'timestamp_default_values', | ||||
| 			'ds' => 'test', | ||||
| 			'alias' => 'TimestampDefaultValue' | ||||
| 		)); | ||||
| 		$result = $this->Dbo->describe($model); | ||||
| 		$this->Dbo->execute('DROP TABLE ' . $name); | ||||
| 
 | ||||
| 		$this->assertNull($result['limit_date']['default']); | ||||
| 
 | ||||
| 		$schema = new CakeSchema(array( | ||||
| 			'connection' => 'test', | ||||
| 			'testdescribes' => $result | ||||
| 		)); | ||||
| 		$result = $this->Dbo->createSchema($schema); | ||||
| 		$this->assertContains('"limit_date" timestamp NOT NULL', $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test virtualFields with functions. | ||||
|  * | ||||
|  | @ -362,7 +479,7 @@ class SqliteTest extends CakeTestCase { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that records can be inserted with uuid primary keys, and | ||||
|  * Test that records can be inserted with UUID primary keys, and | ||||
|  * that the primary key is not blank | ||||
|  * | ||||
|  * @return void | ||||
|  | @ -372,7 +489,7 @@ class SqliteTest extends CakeTestCase { | |||
| 		$Model = ClassRegistry::init('Uuid'); | ||||
| 
 | ||||
| 		$data = array( | ||||
| 			'title' => 'A uuid should work', | ||||
| 			'title' => 'A UUID should work', | ||||
| 			'count' => 10 | ||||
| 		); | ||||
| 		$Model->create($data); | ||||
|  | @ -380,7 +497,7 @@ class SqliteTest extends CakeTestCase { | |||
| 		$result = $Model->read(); | ||||
| 
 | ||||
| 		$this->assertEquals($data['title'], $result['Uuid']['title']); | ||||
| 		$this->assertTrue(Validation::uuid($result['Uuid']['id']), 'Not a uuid'); | ||||
| 		$this->assertTrue(Validation::uuid($result['Uuid']['id']), 'Not a UUID'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -389,6 +506,7 @@ class SqliteTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testNestedTransaction() { | ||||
| 		$this->Dbo->useNestedTransactions = true; | ||||
| 		$this->skipIf($this->Dbo->nestedTransactionSupported() === false, 'The Sqlite version do not support nested transaction'); | ||||
| 
 | ||||
| 		$this->loadFixtures('User'); | ||||
|  | @ -416,4 +534,96 @@ class SqliteTest extends CakeTestCase { | |||
| 		$this->assertNotEmpty($model->read(null, 1)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test the limit function. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testLimit() { | ||||
| 		$db = $this->Dbo; | ||||
| 
 | ||||
| 		$result = $db->limit('0'); | ||||
| 		$this->assertNull($result); | ||||
| 
 | ||||
| 		$result = $db->limit('10'); | ||||
| 		$this->assertEquals(' LIMIT 10', $result); | ||||
| 
 | ||||
| 		$result = $db->limit('FARTS', 'BOOGERS'); | ||||
| 		$this->assertEquals(' LIMIT 0 OFFSET 0', $result); | ||||
| 
 | ||||
| 		$result = $db->limit(20, 10); | ||||
| 		$this->assertEquals(' LIMIT 20 OFFSET 10', $result); | ||||
| 
 | ||||
| 		$result = $db->limit(10, 300000000000000000000000000000); | ||||
| 		$scientificNotation = sprintf('%.1E', 300000000000000000000000000000); | ||||
| 		$this->assertNotContains($scientificNotation, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that fields are parsed out in a reasonable fashion. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testFetchRowColumnParsing() { | ||||
| 		$this->loadFixtures('User'); | ||||
| 		$sql = 'SELECT "User"."id", "User"."user", "User"."password", "User"."created", (1 + 1) AS "two" ' . | ||||
| 			'FROM "users" AS "User" WHERE ' . | ||||
| 			'"User"."id" IN (SELECT MAX("id") FROM "users") ' . | ||||
| 			'OR "User.id" IN (5, 6, 7, 8)'; | ||||
| 		$result = $this->Dbo->fetchRow($sql); | ||||
| 
 | ||||
| 		$expected = array( | ||||
| 			'User' => array( | ||||
| 				'id' => 4, | ||||
| 				'user' => 'garrett', | ||||
| 				'password' => '5f4dcc3b5aa765d61d8327deb882cf99', | ||||
| 				'created' => '2007-03-17 01:22:23' | ||||
| 			), | ||||
| 			0 => array( | ||||
| 				'two' => 2 | ||||
| 			) | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$sql = 'SELECT "User"."id", "User"."user" ' . | ||||
| 			'FROM "users" AS "User" WHERE "User"."id" = 4 ' . | ||||
| 			'UNION ' . | ||||
| 			'SELECT "User"."id", "User"."user" ' . | ||||
| 			'FROM "users" AS "User" WHERE "User"."id" = 3'; | ||||
| 		$result = $this->Dbo->fetchRow($sql); | ||||
| 
 | ||||
| 		$expected = array( | ||||
| 			'User' => array( | ||||
| 				'id' => 3, | ||||
| 				'user' => 'larry', | ||||
| 			), | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test parsing more complex field names. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testFetchColumnRowParsingMoreComplex() { | ||||
| 		$this->loadFixtures('User'); | ||||
| 		$sql = 'SELECT | ||||
| 			COUNT(*) AS User__count, | ||||
| 			COUNT(CASE id WHEN 2 THEN 1 ELSE NULL END) as User__case, | ||||
| 			AVG(CAST("User"."id" AS BIGINT)) AS User__bigint | ||||
| 			FROM "users" AS "User" | ||||
| 			WHERE "User"."id" > 0'; | ||||
| 		$result = $this->Dbo->fetchRow($sql); | ||||
| 
 | ||||
| 		$expected = array( | ||||
| 			'0' => array( | ||||
| 				'User__count' => '4', | ||||
| 				'User__case' => '1', | ||||
| 				'User__bigint' => '2.5', | ||||
| 			), | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -2,19 +2,18 @@ | |||
| /** | ||||
|  * SqlserverTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.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 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP(tm) Project | ||||
|  * @package       Cake.Test.Case.Model.Datasource.Database | ||||
|  * @since         CakePHP(tm) v 1.2.0 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('Model', 'Model'); | ||||
|  | @ -98,7 +97,7 @@ class SqlserverTestDb extends Sqlserver { | |||
| /** | ||||
|  * describe method | ||||
|  * | ||||
|  * @param object $model | ||||
|  * @param Model $model | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function describe($model) { | ||||
|  | @ -114,17 +113,10 @@ class SqlserverTestDb extends Sqlserver { | |||
|  */ | ||||
| class SqlserverTestModel extends CakeTestModel { | ||||
| 
 | ||||
| /** | ||||
|  * name property | ||||
|  * | ||||
|  * @var string 'SqlserverTestModel' | ||||
|  */ | ||||
| 	public $name = 'SqlserverTestModel'; | ||||
| 
 | ||||
| /** | ||||
|  * useTable property | ||||
|  * | ||||
|  * @var bool false | ||||
|  * @var bool | ||||
|  */ | ||||
| 	public $useTable = false; | ||||
| 
 | ||||
|  | @ -187,17 +179,10 @@ class SqlserverTestModel extends CakeTestModel { | |||
|  */ | ||||
| class SqlserverClientTestModel extends CakeTestModel { | ||||
| 
 | ||||
| /** | ||||
|  * name property | ||||
|  * | ||||
|  * @var string 'SqlserverAssociatedTestModel' | ||||
|  */ | ||||
| 	public $name = 'SqlserverClientTestModel'; | ||||
| 
 | ||||
| /** | ||||
|  * useTable property | ||||
|  * | ||||
|  * @var bool false | ||||
|  * @var bool | ||||
|  */ | ||||
| 	public $useTable = false; | ||||
| 
 | ||||
|  | @ -263,7 +248,7 @@ class SqlserverTest extends CakeTestCase { | |||
| /** | ||||
|  * autoFixtures property | ||||
|  * | ||||
|  * @var bool false | ||||
|  * @var bool | ||||
|  */ | ||||
| 	public $autoFixtures = false; | ||||
| 
 | ||||
|  | @ -277,8 +262,10 @@ class SqlserverTest extends CakeTestCase { | |||
| /** | ||||
|  * Sets up a Dbo class instance for testing | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function setUp() { | ||||
| 		parent::setUp(); | ||||
| 		$this->Dbo = ConnectionManager::getDataSource('test'); | ||||
| 		if (!($this->Dbo instanceof Sqlserver)) { | ||||
| 			$this->markTestSkipped('Please configure the test datasource to use SQL Server.'); | ||||
|  | @ -293,6 +280,7 @@ class SqlserverTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function tearDown() { | ||||
| 		parent::tearDown(); | ||||
| 		unset($this->Dbo); | ||||
| 		unset($this->model); | ||||
| 	} | ||||
|  | @ -322,6 +310,10 @@ class SqlserverTest extends CakeTestCase { | |||
| 		$expected = "''"; | ||||
| 		$result = $this->db->value('', 'binary'); | ||||
| 		$this->assertSame($expected, $result); | ||||
| 
 | ||||
| 		$expected = 'NULL'; | ||||
| 		$result = $this->db->value(null, 'string'); | ||||
| 		$this->assertSame($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -447,7 +439,25 @@ class SqlserverTest extends CakeTestCase { | |||
| 				'Length' => 72, | ||||
| 				'Null' => 'NO', | ||||
| 				'Size' => '' | ||||
| 			) | ||||
| 			), | ||||
| 			(object)array( | ||||
| 				'Default' => null, | ||||
| 				'Field' => 'parent_id', | ||||
| 				'Key' => '0', | ||||
| 				'Type' => 'bigint', | ||||
| 				'Length' => 8, | ||||
| 				'Null' => 'YES', | ||||
| 				'Size' => '0', | ||||
| 			), | ||||
| 			(object)array( | ||||
| 				'Default' => null, | ||||
| 				'Field' => 'description', | ||||
| 				'Key' => '0', | ||||
| 				'Type' => 'text', | ||||
| 				'Length' => 16, | ||||
| 				'Null' => 'YES', | ||||
| 				'Size' => '0', | ||||
| 			), | ||||
| 		)); | ||||
| 		$this->db->executeResultsStack = array($SqlserverTableDescription); | ||||
| 		$dummyModel = $this->model; | ||||
|  | @ -477,9 +487,22 @@ class SqlserverTest extends CakeTestCase { | |||
| 				'default' => '', | ||||
| 				'length' => 36, | ||||
| 				'key' => 'primary' | ||||
| 			), | ||||
| 			'parent_id' => array( | ||||
| 				'type' => 'biginteger', | ||||
| 				'null' => true, | ||||
| 				'default' => null, | ||||
| 				'length' => 8, | ||||
| 			), | ||||
| 			'description' => array( | ||||
| 				'type' => 'text', | ||||
| 				'null' => true, | ||||
| 				'default' => null, | ||||
| 				'length' => null, | ||||
| 			) | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 		$this->assertSame($expected['parent_id'], $result['parent_id']); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -553,6 +576,14 @@ class SqlserverTest extends CakeTestCase { | |||
| 		$result = $this->db->buildColumn($column); | ||||
| 		$expected = "[checked] bit DEFAULT '1'"; | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$column = array( | ||||
| 			'name' => 'huge', | ||||
| 			'type' => 'biginteger', | ||||
| 		); | ||||
| 		$result = $this->db->buildColumn($column); | ||||
| 		$expected = "[huge] bigint"; | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko