Skip to content

Commit e27a92f

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.5
Conflicts: user_guide_src/source/incoming/routing/069.php Added user_guide_src/source/incoming/routing/070.php Modified user_guide_src/source/intro/requirements.rst
2 parents f673bb0 + 02942c4 commit e27a92f

File tree

13 files changed

+340
-331
lines changed

13 files changed

+340
-331
lines changed

app/Config/Routing.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,12 @@ class Routing extends BaseRouting
6868

6969
/**
7070
* Sets the class/method that should be called if routing doesn't
71-
* find a match. It can be either a closure or the controller/method
72-
* name exactly like a route is defined: Users::index
71+
* find a match. It can be the controller/method name like: Users::index
7372
*
7473
* This setting is passed to the Router class and handled there.
7574
*
7675
* If you want to use a closure, you will have to set it in the
77-
* class constructor or the routes file by calling:
76+
* routes file by calling:
7877
*
7978
* $routes->set404Override(function() {
8079
* // Do something here

system/Config/Routing.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,12 @@ class Routing extends BaseConfig
6868

6969
/**
7070
* Sets the class/method that should be called if routing doesn't
71-
* find a match. It can be either a closure or the controller/method
72-
* name exactly like a route is defined: Users::index
71+
* find a match. It can be the controller/method name like: Users::index
7372
*
7473
* This setting is passed to the Router class and handled there.
7574
*
7675
* If you want to use a closure, you will have to set it in the
77-
* class constructor or the routes file by calling:
76+
* routes file by calling:
7877
*
7978
* $routes->set404Override(function() {
8079
* // Do something here

tests/system/Database/Live/AbstractGetFieldDataTest.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ abstract class AbstractGetFieldDataTest extends CIUnitTestCase
2626
protected $db;
2727

2828
protected Forge $forge;
29+
protected string $table = 'test1';
2930

3031
protected function setUp(): void
3132
{
@@ -34,7 +35,6 @@ protected function setUp(): void
3435
$this->db = Database::connect($this->DBGroup);
3536

3637
$this->createForge();
37-
$this->createTable();
3838
}
3939

4040
/**
@@ -46,12 +46,12 @@ protected function tearDown(): void
4646
{
4747
parent::tearDown();
4848

49-
$this->forge->dropTable('test1', true);
49+
$this->forge->dropTable($this->table, true);
5050
}
5151

52-
protected function createTable()
52+
protected function createTableForDefault()
5353
{
54-
$this->forge->dropTable('test1', true);
54+
$this->forge->dropTable($this->table, true);
5555

5656
$this->forge->addField([
5757
'id' => [
@@ -88,8 +88,21 @@ protected function createTable()
8888
],
8989
]);
9090
$this->forge->addKey('id', true);
91-
$this->forge->createTable('test1');
91+
$this->forge->createTable($this->table);
9292
}
9393

94-
abstract public function testGetFieldData(): void;
94+
abstract public function testGetFieldDataDefault(): void;
95+
96+
protected function assertSameFieldData(array $expected, array $actual)
97+
{
98+
$expected = json_decode(json_encode($expected), true);
99+
$names = array_column($expected, 'name');
100+
array_multisort($names, SORT_ASC, $expected);
101+
102+
$fields = json_decode(json_encode($actual), true);
103+
$names = array_column($fields, 'name');
104+
array_multisort($names, SORT_ASC, $fields);
105+
106+
$this->assertSame($expected, $fields);
107+
}
95108
}

tests/system/Database/Live/MySQLi/GetFieldDataTest.php

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -46,70 +46,70 @@ private function isOldMySQL(): bool
4646
);
4747
}
4848

49-
public function testGetFieldData(): void
49+
public function testGetFieldDataDefault(): void
5050
{
51-
$fields = $this->db->getFieldData('test1');
51+
$this->createTableForDefault();
5252

53-
$this->assertJsonStringEqualsJsonString(
54-
json_encode([
55-
(object) [
56-
'name' => 'id',
57-
'type' => 'int',
58-
'max_length' => $this->isOldMySQL() ? 11 : null,
59-
'default' => null, // The default value is not defined.
60-
'primary_key' => 1,
61-
'nullable' => false,
62-
],
63-
(object) [
64-
'name' => 'text_not_null',
65-
'type' => 'varchar',
66-
'max_length' => 64,
67-
'default' => null, // The default value is not defined.
68-
'primary_key' => 0,
69-
'nullable' => false,
70-
],
71-
(object) [
72-
'name' => 'text_null',
73-
'type' => 'varchar',
74-
'max_length' => 64,
75-
'default' => null, // The default value is not defined.
76-
'primary_key' => 0,
77-
'nullable' => true,
78-
],
79-
(object) [
80-
'name' => 'int_default_0',
81-
'type' => 'int',
82-
'max_length' => $this->isOldMySQL() ? 11 : null,
83-
'default' => '0', // int 0
84-
'primary_key' => 0,
85-
'nullable' => false,
86-
],
87-
(object) [
88-
'name' => 'text_default_null',
89-
'type' => 'varchar',
90-
'max_length' => 64,
91-
'default' => null, // NULL value
92-
'primary_key' => 0,
93-
'nullable' => true,
94-
],
95-
(object) [
96-
'name' => 'text_default_text_null',
97-
'type' => 'varchar',
98-
'max_length' => 64,
99-
'default' => 'null', // string "null"
100-
'primary_key' => 0,
101-
'nullable' => false,
102-
],
103-
(object) [
104-
'name' => 'text_default_abc',
105-
'type' => 'varchar',
106-
'max_length' => 64,
107-
'default' => 'abc', // string "abc"
108-
'primary_key' => 0,
109-
'nullable' => false,
110-
],
111-
]),
112-
json_encode($fields)
113-
);
53+
$fields = $this->db->getFieldData($this->table);
54+
55+
$expected = [
56+
(object) [
57+
'name' => 'id',
58+
'type' => 'int',
59+
'max_length' => $this->isOldMySQL() ? 11 : null,
60+
'nullable' => false,
61+
'default' => null, // The default value is not defined.
62+
'primary_key' => 1,
63+
],
64+
(object) [
65+
'name' => 'text_not_null',
66+
'type' => 'varchar',
67+
'max_length' => 64,
68+
'nullable' => false,
69+
'default' => null, // The default value is not defined.
70+
'primary_key' => 0,
71+
],
72+
(object) [
73+
'name' => 'text_null',
74+
'type' => 'varchar',
75+
'max_length' => 64,
76+
'nullable' => true,
77+
'default' => null, // The default value is not defined.
78+
'primary_key' => 0,
79+
],
80+
(object) [
81+
'name' => 'int_default_0',
82+
'type' => 'int',
83+
'max_length' => $this->isOldMySQL() ? 11 : null,
84+
'nullable' => false,
85+
'default' => '0', // int 0
86+
'primary_key' => 0,
87+
],
88+
(object) [
89+
'name' => 'text_default_null',
90+
'type' => 'varchar',
91+
'max_length' => 64,
92+
'nullable' => true,
93+
'default' => null, // NULL value
94+
'primary_key' => 0,
95+
],
96+
(object) [
97+
'name' => 'text_default_text_null',
98+
'type' => 'varchar',
99+
'max_length' => 64,
100+
'nullable' => false,
101+
'default' => 'null', // string "null"
102+
'primary_key' => 0,
103+
],
104+
(object) [
105+
'name' => 'text_default_abc',
106+
'type' => 'varchar',
107+
'max_length' => 64,
108+
'nullable' => false,
109+
'default' => 'abc', // string "abc"
110+
'primary_key' => 0,
111+
],
112+
];
113+
$this->assertSameFieldData($expected, $fields);
114114
}
115115
}

tests/system/Database/Live/OCI8/GetFieldDataTest.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ protected function createForge(): void
3232
$this->forge = Database::forge($this->db);
3333
}
3434

35-
public function testGetFieldData(): void
35+
public function testGetFieldDataDefault(): void
3636
{
37-
$fields = $this->db->getFieldData('test1');
37+
$this->createTableForDefault();
38+
39+
$fields = $this->db->getFieldData($this->table);
3840

3941
$data = [];
4042

@@ -45,7 +47,7 @@ public function testGetFieldData(): void
4547
$idDefault = $data['id']->default;
4648
$this->assertMatchesRegularExpression('/"ORACLE"."ISEQ\$\$_[0-9]+".nextval/', $idDefault);
4749

48-
$expected = json_decode(json_encode([
50+
$expected = [
4951
(object) [
5052
'name' => 'id',
5153
'type' => 'NUMBER',
@@ -102,14 +104,7 @@ public function testGetFieldData(): void
102104
'default' => "'abc' ", // string "abc"
103105
// 'primary_key' => 0,
104106
],
105-
]), true);
106-
$names = array_column($expected, 'name');
107-
array_multisort($names, SORT_ASC, $expected);
108-
109-
$fields = json_decode(json_encode($fields), true);
110-
$names = array_column($fields, 'name');
111-
array_multisort($names, SORT_ASC, $fields);
112-
113-
$this->assertSame($expected, $fields);
107+
];
108+
$this->assertSameFieldData($expected, $fields);
114109
}
115110
}

tests/system/Database/Live/Postgre/GetFieldDataTest.php

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -32,70 +32,70 @@ protected function createForge(): void
3232
$this->forge = Database::forge($this->db);
3333
}
3434

35-
public function testGetFieldData(): void
35+
public function testGetFieldDataDefault(): void
3636
{
37+
$this->createTableForDefault();
38+
3739
$fields = $this->db->getFieldData('test1');
3840

39-
$this->assertJsonStringEqualsJsonString(
40-
json_encode([
41-
(object) [
42-
'name' => 'id',
43-
'type' => 'integer',
44-
'max_length' => '32',
45-
'default' => "nextval('db_test1_id_seq'::regclass)", // The default value is not defined.
46-
// 'primary_key' => 1,
47-
'nullable' => false,
48-
],
49-
(object) [
50-
'name' => 'text_not_null',
51-
'type' => 'character varying',
52-
'max_length' => '64',
53-
'default' => null, // The default value is not defined.
54-
// 'primary_key' => 0,
55-
'nullable' => false,
56-
],
57-
(object) [
58-
'name' => 'text_null',
59-
'type' => 'character varying',
60-
'max_length' => '64',
61-
'default' => null, // The default value is not defined.
62-
// 'primary_key' => 0,
63-
'nullable' => true,
64-
],
65-
(object) [
66-
'name' => 'int_default_0',
67-
'type' => 'integer',
68-
'max_length' => '32',
69-
'default' => '0', // int 0
70-
// 'primary_key' => 0,
71-
'nullable' => false,
72-
],
73-
(object) [
74-
'name' => 'text_default_null',
75-
'type' => 'character varying',
76-
'max_length' => '64',
77-
'default' => 'NULL::character varying', // NULL value
78-
// 'primary_key' => 0,
79-
'nullable' => true,
80-
],
81-
(object) [
82-
'name' => 'text_default_text_null',
83-
'type' => 'character varying',
84-
'max_length' => '64',
85-
'default' => "'null'::character varying", // string "null"
86-
// 'primary_key' => 0,
87-
'nullable' => false,
88-
],
89-
(object) [
90-
'name' => 'text_default_abc',
91-
'type' => 'character varying',
92-
'max_length' => '64',
93-
'default' => "'abc'::character varying", // string "abc"
94-
// 'primary_key' => 0,
95-
'nullable' => false,
96-
],
97-
]),
98-
json_encode($fields)
99-
);
41+
$expected = [
42+
(object) [
43+
'name' => 'id',
44+
'type' => 'integer',
45+
'max_length' => '32',
46+
'nullable' => false,
47+
// 'primary_key' => 1,
48+
'default' => "nextval('db_test1_id_seq'::regclass)", // The default value is not defined.
49+
],
50+
(object) [
51+
'name' => 'text_not_null',
52+
'type' => 'character varying',
53+
'max_length' => '64',
54+
'nullable' => false,
55+
// 'primary_key' => 0,
56+
'default' => null, // The default value is not defined.
57+
],
58+
(object) [
59+
'name' => 'text_null',
60+
'type' => 'character varying',
61+
'max_length' => '64',
62+
'nullable' => true,
63+
// 'primary_key' => 0,
64+
'default' => null, // The default value is not defined.
65+
],
66+
(object) [
67+
'name' => 'int_default_0',
68+
'type' => 'integer',
69+
'max_length' => '32',
70+
'nullable' => false,
71+
// 'primary_key' => 0,
72+
'default' => '0', // int 0
73+
],
74+
(object) [
75+
'name' => 'text_default_null',
76+
'type' => 'character varying',
77+
'max_length' => '64',
78+
'nullable' => true,
79+
// 'primary_key' => 0,
80+
'default' => 'NULL::character varying', // NULL value
81+
],
82+
(object) [
83+
'name' => 'text_default_text_null',
84+
'type' => 'character varying',
85+
'max_length' => '64',
86+
'nullable' => false,
87+
// 'primary_key' => 0,
88+
'default' => "'null'::character varying", // string "null"
89+
],
90+
(object) [
91+
'name' => 'text_default_abc',
92+
'type' => 'character varying',
93+
'max_length' => '64',
94+
'nullable' => false,
95+
// 'primary_key' => 0,
96+
'default' => "'abc'::character varying", // string "abc"
97+
],
98+
];
99+
$this->assertSameFieldData($expected, $fields);
100100
}
101101
}

0 commit comments

Comments
 (0)