CubridQueryBuilderTest.php 4.83 KB
Newer Older
Carsten Brandt committed
1 2 3 4 5 6 7
<?php

namespace yiiunit\framework\db\cubrid;

use yii\db\sqlite\Schema;
use yiiunit\framework\db\QueryBuilderTest;

8 9 10 11
/**
 * @group db
 * @group cubrid
 */
Carsten Brandt committed
12 13
class CubridQueryBuilderTest extends QueryBuilderTest
{
14
    public $driverName = 'cubrid';
Carsten Brandt committed
15

16 17 18 19 20 21 22 23
    /**
     * this is not used as a dataprovider for testGetColumnType to speed up the test
     * when used as dataprovider every single line will cause a reconnect with the database which is not needed here
     */
    public function columnTypes()
    {
        return [
            [Schema::TYPE_PK, 'int NOT NULL AUTO_INCREMENT PRIMARY KEY'],
Qiang Xue committed
24
            [Schema::TYPE_PK . '(8)', 'int NOT NULL AUTO_INCREMENT PRIMARY KEY'],
25
            [Schema::TYPE_PK . ' CHECK (value > 5)', 'int NOT NULL AUTO_INCREMENT PRIMARY KEY CHECK (value > 5)'],
Qiang Xue committed
26
            [Schema::TYPE_PK . '(8) CHECK (value > 5)', 'int NOT NULL AUTO_INCREMENT PRIMARY KEY CHECK (value > 5)'],
27 28 29 30 31 32
            [Schema::TYPE_STRING, 'varchar(255)'],
            [Schema::TYPE_STRING . '(32)', 'varchar(32)'],
            [Schema::TYPE_STRING . ' CHECK (value LIKE "test%")', 'varchar(255) CHECK (value LIKE "test%")'],
            [Schema::TYPE_STRING . '(32) CHECK (value LIKE "test%")', 'varchar(32) CHECK (value LIKE "test%")'],
            [Schema::TYPE_STRING . ' NOT NULL', 'varchar(255) NOT NULL'],
            [Schema::TYPE_TEXT, 'varchar'],
Qiang Xue committed
33
            [Schema::TYPE_TEXT . '(255)', 'varchar'],
34
            [Schema::TYPE_TEXT . ' CHECK (value LIKE "test%")', 'varchar CHECK (value LIKE "test%")'],
Qiang Xue committed
35
            [Schema::TYPE_TEXT . '(255) CHECK (value LIKE "test%")', 'varchar CHECK (value LIKE "test%")'],
36
            [Schema::TYPE_TEXT . ' NOT NULL', 'varchar NOT NULL'],
Qiang Xue committed
37
            [Schema::TYPE_TEXT . '(255) NOT NULL', 'varchar NOT NULL'],
38
            [Schema::TYPE_SMALLINT, 'smallint'],
Qiang Xue committed
39
            [Schema::TYPE_SMALLINT . '(8)', 'smallint'],
40
            [Schema::TYPE_INTEGER, 'int'],
Qiang Xue committed
41
            [Schema::TYPE_INTEGER . '(8)', 'int'],
42
            [Schema::TYPE_INTEGER . ' CHECK (value > 5)', 'int CHECK (value > 5)'],
Qiang Xue committed
43
            [Schema::TYPE_INTEGER . '(8) CHECK (value > 5)', 'int CHECK (value > 5)'],
44 45
            [Schema::TYPE_INTEGER . ' NOT NULL', 'int NOT NULL'],
            [Schema::TYPE_BIGINT, 'bigint'],
Qiang Xue committed
46
            [Schema::TYPE_BIGINT . '(8)', 'bigint'],
47
            [Schema::TYPE_BIGINT . ' CHECK (value > 5)', 'bigint CHECK (value > 5)'],
Qiang Xue committed
48
            [Schema::TYPE_BIGINT . '(8) CHECK (value > 5)', 'bigint CHECK (value > 5)'],
49 50 51 52 53 54 55 56 57 58 59 60
            [Schema::TYPE_BIGINT . ' NOT NULL', 'bigint NOT NULL'],
            [Schema::TYPE_FLOAT, 'float(7)'],
            [Schema::TYPE_FLOAT . '(16)', 'float(16)'],
            [Schema::TYPE_FLOAT . ' CHECK (value > 5.6)', 'float(7) CHECK (value > 5.6)'],
            [Schema::TYPE_FLOAT . '(16) CHECK (value > 5.6)', 'float(16) CHECK (value > 5.6)'],
            [Schema::TYPE_FLOAT . ' NOT NULL', 'float(7) NOT NULL'],
            [Schema::TYPE_DECIMAL, 'decimal(10,0)'],
            [Schema::TYPE_DECIMAL . '(12,4)', 'decimal(12,4)'],
            [Schema::TYPE_DECIMAL . ' CHECK (value > 5.6)', 'decimal(10,0) CHECK (value > 5.6)'],
            [Schema::TYPE_DECIMAL . '(12,4) CHECK (value > 5.6)', 'decimal(12,4) CHECK (value > 5.6)'],
            [Schema::TYPE_DECIMAL . ' NOT NULL', 'decimal(10,0) NOT NULL'],
            [Schema::TYPE_DATETIME, 'datetime'],
Carsten Brandt committed
61
            [Schema::TYPE_DATETIME . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", "datetime CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"],
62 63
            [Schema::TYPE_DATETIME . ' NOT NULL', 'datetime NOT NULL'],
            [Schema::TYPE_TIMESTAMP, 'timestamp'],
Carsten Brandt committed
64
            [Schema::TYPE_TIMESTAMP . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", "timestamp CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"],
65 66
            [Schema::TYPE_TIMESTAMP . ' NOT NULL', 'timestamp NOT NULL'],
            [Schema::TYPE_TIME, 'time'],
Carsten Brandt committed
67
            [Schema::TYPE_TIME . " CHECK (value BETWEEN '12:00:00' AND '13:01:01')", "time CHECK (value BETWEEN '12:00:00' AND '13:01:01')"],
68 69
            [Schema::TYPE_TIME . ' NOT NULL', 'time NOT NULL'],
            [Schema::TYPE_DATE, 'date'],
Carsten Brandt committed
70
            [Schema::TYPE_DATE . " CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')", "date CHECK (value BETWEEN '2011-01-01' AND '2013-01-01')"],
71 72 73 74 75 76 77 78 79 80 81
            [Schema::TYPE_DATE . ' NOT NULL', 'date NOT NULL'],
            [Schema::TYPE_BINARY, 'blob'],
            [Schema::TYPE_BOOLEAN, 'smallint'],
            [Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT 1', 'smallint NOT NULL DEFAULT 1'],
            [Schema::TYPE_MONEY, 'decimal(19,4)'],
            [Schema::TYPE_MONEY . '(16,2)', 'decimal(16,2)'],
            [Schema::TYPE_MONEY . ' CHECK (value > 0.0)', 'decimal(19,4) CHECK (value > 0.0)'],
            [Schema::TYPE_MONEY . '(16,2) CHECK (value > 0.0)', 'decimal(16,2) CHECK (value > 0.0)'],
            [Schema::TYPE_MONEY . ' NOT NULL', 'decimal(19,4) NOT NULL'],
        ];
    }
Carsten Brandt committed
82
}