mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adjust enum related unit tests
This commit is contained in:
parent
cf6c8d511f
commit
7788c60f58
3 changed files with 44 additions and 10 deletions
|
@ -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(),
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue