From 7788c60f581457e57699be63ad50f75f98e483a1 Mon Sep 17 00:00:00 2001 From: bancer Date: Wed, 12 Dec 2018 14:31:55 +0100 Subject: [PATCH] Adjust enum related unit tests --- lib/Cake/Test/Case/Model/CakeSchemaTest.php | 15 ++++++++++ .../Model/Datasource/Database/MysqlTest.php | 28 +++++++++++++------ .../Case/Model/Datasource/DboSourceTest.php | 11 ++++++-- 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/lib/Cake/Test/Case/Model/CakeSchemaTest.php b/lib/Cake/Test/Case/Model/CakeSchemaTest.php index c7c8deab1..bdcaf2440 100644 --- a/lib/Cake/Test/Case/Model/CakeSchemaTest.php +++ b/lib/Cake/Test/Case/Model/CakeSchemaTest.php @@ -64,6 +64,13 @@ class MyAppSchema extends CakeSchema { 'published' => array('type' => 'string', 'null' => true, 'default' => 'Y', 'length' => 1), 'created' => array('type' => 'datetime', 'null' => true, 'default' => null), 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null), + 'status' => array( + 'type' => 'enum(\'active\',\'deleted\')', + 'null' => false, + 'default' => 'active', + 'collate' => 'utf8_unicode_ci', + 'charset' => 'utf8', + ), 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), ); @@ -809,6 +816,14 @@ class CakeSchemaTest extends CakeTestCase { 'posts' => array( 'add' => array( 'summary' => array('type' => 'text', 'null' => true, 'after' => 'body'), + 'status' => array( + 'type' => 'enum(\'active\',\'deleted\')', + 'null' => false, + 'default' => 'active', + 'collate' => 'utf8_unicode_ci', + 'charset' => 'utf8', + 'after' => 'updated', + ), ), 'drop' => array( 'tableParameters' => array(), diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index fe7f3e0db..cc2cce668 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -3080,14 +3080,6 @@ SQL; $expected = '5,2'; $this->assertSame($expected, $result); - $result = $this->Dbo->length("enum('test','me','now')"); - $expected = 4; - $this->assertSame($expected, $result); - - $result = $this->Dbo->length("set('a','b','cd')"); - $expected = 2; - $this->assertSame($expected, $result); - $result = $this->Dbo->length(false); $this->assertNull($result); @@ -3100,6 +3092,26 @@ SQL; $this->assertSame($expected, $result); } +/** + * Tests the length of enum column. + * + * @return void + */ + public function testLengthEnum() { + $result = $this->Dbo->length("enum('test','me','now')"); + $this->assertNull($result); + } + +/** + * Tests the length of set column. + * + * @return void + */ + public function testLengthSet() { + $result = $this->Dbo->length("set('a','b','cd')"); + $this->assertNull($result); + } + /** * testBuildIndex method * diff --git a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php index 2d206d5bf..c8df92dc3 100644 --- a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php @@ -2177,12 +2177,19 @@ class DboSourceTest extends CakeTestCase { $result = $this->db->length('decimal(20,3)'); $this->assertEquals('20,3', $result); + } +/** + * Test length parsing of enum column. + * + * @return void + */ + public function testLengthEnum() { $result = $this->db->length('enum("one", "longer")'); - $this->assertEquals(6, $result); + $this->assertNull($result); $result = $this->db->length("enum('One Value','ANOTHER ... VALUE ...')"); - $this->assertEquals(21, $result); + $this->assertNull($result); } /**