Skip to content

Commit

Permalink
php 5.3 arrays for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcal committed May 4, 2021
1 parent 48417d2 commit a767323
Showing 1 changed file with 92 additions and 92 deletions.
184 changes: 92 additions & 92 deletions tests/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,61 +29,61 @@ function testSimpleFields(){
# JSON

$tbl = $this->get_first_table("CREATE TABLE foo (bar DATE)");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "DATE",
]
]);
)
));
}

function testInts(){

$tbl = $this->get_first_table("CREATE TABLE foo (bar TINYINT)");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "TINYINT",
]
]);
)
));

$tbl = $this->get_first_table("CREATE TABLE foo (bar smallint (4))");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "SMALLINT",
'length' => "4",
]
]);
)
));

$tbl = $this->get_first_table("CREATE TABLE foo (bar MEDIUMINT UNSIGNED)");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "MEDIUMINT",
'unsigned' => true,
]
]);
)
));

$tbl = $this->get_first_table("CREATE TABLE foo (bar INT ZEROFILL)");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "INT",
'zerofill' => true,
]
]);
)
));

$tbl = $this->get_first_table("CREATE TABLE foo (bar BIGINT(20) UNSIGNED ZEROFILL)");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "BIGINT",
'length' => "20",
'unsigned' => true,
'zerofill' => true,
]
]);
)
));


}
Expand All @@ -95,34 +95,34 @@ function testFloats(){
# FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]

$tbl = $this->get_first_table("CREATE TABLE foo (bar REAL)");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "REAL",
]
]);
)
));

$tbl = $this->get_first_table("CREATE TABLE foo (bar double (1,2))");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "DOUBLE",
'length' => 1,
'decimals' => 2,
]
]);
)
));

$tbl = $this->get_first_table("CREATE TABLE foo (bar Float(3,4) UNSIGNED ZEROFILL)");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "FLOAT",
'length' => 3,
'decimals' => 4,
'unsigned' => true,
'zerofill' => true,
]
]);
)
));
}

function testNumerics(){
Expand All @@ -131,33 +131,33 @@ function testNumerics(){
# NUMERIC[(length[,decimals])] [UNSIGNED] [ZEROFILL]

$tbl = $this->get_first_table("CREATE TABLE foo (bar Decimal)");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "DECIMAL",
]
]);
)
));

$tbl = $this->get_first_table("CREATE TABLE foo (bar DECIMAL(1) UNSIGNED)");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "DECIMAL",
'length' => 1,
'unsigned' => true,
]
]);
)
));

$tbl = $this->get_first_table("CREATE TABLE foo (bar NUMERIC(1,2) ZEROFILL)");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "NUMERIC",
'length' => 1,
'decimals' => 2,
'zerofill' => true,
]
]);
)
));
}

function testTimes(){
Expand All @@ -167,43 +167,43 @@ function testTimes(){
# DATETIME[(fsp)]

$tbl = $this->get_first_table("CREATE TABLE foo (bar TIME)");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "TIME",
]
]);
)
));

$tbl = $this->get_first_table("CREATE TABLE foo (bar TIMESTAMP(6))");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "TIMESTAMP",
'fsp' => 6,
]
]);
)
));
}

function testBits(){

# BIT[(length)]

$tbl = $this->get_first_table("CREATE TABLE foo (bar bit)");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "BIT",
]
]);
)
));

$tbl = $this->get_first_table("CREATE TABLE foo (bar BIT (999))");
$this->assertEquals($tbl['fields'], [
[
$this->assertEquals($tbl['fields'], array(
array(
'name' => "bar",
'type' => "BIT",
'length' => 999,
]
]);
)
));
}

function testChars(){
Expand All @@ -214,61 +214,61 @@ function testChars(){
# VARBINARY(length)

$fields = $this->get_fields("bar CHAR BINARY CHARACTER SET `utf19`");
$this->assertEquals([
[
$this->assertEquals(array(
array(
'name' => "bar",
'type' => "CHAR",
'binary' => true,
'character_set' => "utf19",

]
], $fields);
)
), $fields);

$fields = $this->get_fields("bar CHAR(15) CHARACTER SET `utf19` COLLATE `utf19_awesome`");
$this->assertEquals([
[
$this->assertEquals(array(
array(
'name' => "bar",
'type' => "CHAR",
'length' => 15,
'character_set' => "utf19",
'collation' => "utf19_awesome",
]
], $fields);
)
), $fields);

$fields = $this->get_fields("bar VARCHAR(255)`");
$this->assertEquals([
[
$this->assertEquals(array(
array(
'name' => "bar",
'type' => "VARCHAR",
'length' => 255,
]
], $fields);
)
), $fields);

$fields = $this->get_fields("bar BINARY");
$this->assertEquals([
[
$this->assertEquals(array(
array(
'name' => "bar",
'type' => "BINARY",
]
], $fields);
)
), $fields);

$fields = $this->get_fields("bar BINARY(66)");
$this->assertEquals([
[
$this->assertEquals(array(
array(
'name' => "bar",
'type' => "BINARY",
'length' => 66,
]
], $fields);
)
), $fields);

$fields = $this->get_fields("bar VARBINARY(1024)");
$this->assertEquals([
[
$this->assertEquals(array(
array(
'name' => "bar",
'type' => "VARBINARY",
'length' => 1024,
]
], $fields);
)
), $fields);
}

function testTexts(){
Expand Down Expand Up @@ -319,15 +319,15 @@ function testFieldOptions(){
# [reference_definition]

$fields = $this->get_fields("bar VARCHAR(255) DEFAULT NULL");
$this->assertEquals([
[
$this->assertEquals(array(
array(
'name' => "bar",
'type' => "VARCHAR",
'length' => 255,
'default' => 'NULL',
'null' => true,
]
], $fields);
)
), $fields);
}

function testVirtualOptions(){
Expand Down

0 comments on commit a767323

Please sign in to comment.