Skip to content

Commit 94de4bd

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.3
Conflicts: rector.php user_guide_src/source/installation/upgrading.rst
2 parents 6344fc7 + b0da9eb commit 94de4bd

File tree

11 files changed

+100
-9
lines changed

11 files changed

+100
-9
lines changed

.github/workflows/test-rector.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
- 'utils/**.php'
1515
- '.github/workflows/test-rector.yml'
1616
- composer.json
17+
- rector.php
1718

1819
push:
1920
branches:
@@ -26,6 +27,7 @@ on:
2627
- 'utils/**.php'
2728
- '.github/workflows/test-rector.yml'
2829
- composer.json
30+
- rector.php
2931

3032
jobs:
3133
build:

.php-cs-fixer.dist.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
__DIR__ . '/tests',
2626
__DIR__ . '/utils',
2727
])
28-
->exclude(['ThirdParty'])
28+
->exclude([
29+
'Pager/Views',
30+
'ThirdParty',
31+
'Validation/Views',
32+
])
2933
->notName('#Foobar.php$#')
3034
->append([
3135
__FILE__,

.php-cs-fixer.no-header.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
__DIR__ . '/app',
2626
__DIR__ . '/public',
2727
])
28+
->exclude(['Views/errors/html'])
2829
->notName('#Logger\.php$#')
2930
->append([
3031
__DIR__ . '/admin/starter/builds',

env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
# database.default.port = 3306
4949

5050
# database.tests.hostname = localhost
51-
# database.tests.database = ci4
51+
# database.tests.database = ci4_test
5252
# database.tests.username = root
5353
# database.tests.password = root
5454
# database.tests.DBDriver = MySQLi

rector.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595

9696
// check on constant compare
9797
UnwrapFutureCompatibleIfPhpVersionRector::class => [
98-
__DIR__ . '/system/CodeIgniter.php',
9998
__DIR__ . '/system/Autoloader/Autoloader.php',
10099
],
101100

system/Database/SQLite3/Table.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@ protected function createTable()
247247

248248
$this->forge->addField($fields);
249249

250+
$fieldNames = array_keys($fields);
251+
252+
$this->keys = array_filter(
253+
$this->keys,
254+
static fn ($index) => count(array_intersect($index['fields'], $fieldNames)) === count($index['fields'])
255+
);
256+
250257
// Unique/Index keys
251258
if (is_array($this->keys)) {
252259
foreach ($this->keys as $key) {

tests/README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,24 @@ for code coverage to be calculated successfully. After installing `XDebug`, you
3434
## Setting Up
3535

3636
A number of the tests use a running database.
37-
In order to set up the database edit the details for the `tests` group in
38-
**app/Config/Database.php** or **phpunit.xml**.
37+
The default configuration uses SQLite3 transient in-memory database, so it works if you can use SQLite3.
38+
39+
In order to change the database for testing, edit the details for the `tests` group in
40+
**app/Config/Database.php** or **phpunit.xml** or use **.env** file.
41+
42+
E.g.:
43+
```
44+
database.tests.hostname = localhost
45+
database.tests.database = ci4_test
46+
database.tests.username = root
47+
database.tests.password = root
48+
database.tests.DBDriver = MySQLi
49+
database.tests.DBPrefix = db_
50+
database.default.port = 3306
51+
```
52+
3953
Make sure that you provide a database engine that is currently running on your machine.
54+
4055
More details on a test database setup are in the
4156
[Testing Your Database](https://codeigniter4.github.io/CodeIgniter4/testing/database.html) section of the documentation.
4257

tests/system/Database/Live/SQLite/AlterTableTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,46 @@ public function testDropColumnMaintainsKeys()
156156
$this->assertTrue($result);
157157
}
158158

159+
public function testDropColumnDropCompositeKey()
160+
{
161+
$this->forge->dropTable('actions', true);
162+
163+
$fields = [
164+
'category' => ['type' => 'varchar', 'constraint' => 63],
165+
'name' => ['type' => 'varchar', 'constraint' => 63],
166+
'created_at' => ['type' => 'datetime', 'null' => true],
167+
];
168+
169+
$this->forge->addField('id');
170+
$this->forge->addField($fields);
171+
172+
$this->forge->addKey('name');
173+
$this->forge->addKey(['category', 'name']);
174+
$this->forge->addKey('created_at');
175+
176+
$this->forge->createTable('actions');
177+
178+
$indexes = $this->db->getIndexData('actions');
179+
180+
// the composite index was created
181+
$this->assertSame(['category', 'name'], $indexes['actions_category_name']->fields);
182+
183+
// drop one of the columns in the composite index
184+
$this->forge->dropColumn('actions', 'category');
185+
186+
// get indexes again
187+
$indexes = $this->db->getIndexData('actions');
188+
189+
// check that composite index was dropped.
190+
$this->assertArrayNotHasKey('actions_category_name', $indexes);
191+
192+
// check that that other keys are present
193+
$this->assertArrayHasKey('actions_name', $indexes);
194+
$this->assertArrayHasKey('actions_created_at', $indexes);
195+
196+
$this->forge->dropTable('actions');
197+
}
198+
159199
public function testModifyColumnSuccess()
160200
{
161201
$this->createTable('janky');
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
############################
2+
Backward Compatibility Notes
3+
############################
4+
5+
We try to develop our products to be as backward compatible (BC) as possible.
6+
7+
Only major releases (such as 4.0, 5.0 etc.) are allowed to break backward compatibility.
8+
Minor releases (such as 4.2, 4.3 etc.) may introduce new features, but must do so without breaking the existing API.
9+
10+
However, the code is not mature and bug fixes may break compatibility in minor releases, or even in patch releases (such as 4.2.5). In that case, all the breaking changes are described in the :doc:`../changelogs/index`.
11+
12+
*****************************
13+
What are not Breaking Changes
14+
*****************************
15+
16+
- System messages defined in **system/Language/en/** are strictly for internal framework use and are not covered by backwards compatibility (BC) promise. If developers are relying on language string output they should be checking it against the function call (``lang('...')``), not the content.

user_guide_src/source/installation/upgrading.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ Upgrading From a Previous Version
55
Please read the upgrade notes corresponding to the version you are
66
upgrading from.
77

8+
See also :doc:`./backward_compatibility_notes`.
9+
810
.. note:: If you don't know what version of CodeIgniter you are currently running,
911
you can get it from :ref:`the Debug Toolbar <the-debug-toolbar>`,
1012
or simply echo the constant ``\CodeIgniter\CodeIgniter::CI_VERSION``.
1113

1214
.. toctree::
1315
:titlesonly:
1416

17+
backward_compatibility_notes
18+
1519
upgrade_430
1620
upgrade_423
1721
upgrade_422

user_guide_src/source/testing/database.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ If you have multiple developers on your team, you will likely want to keep your
3232
the **.env** file. To do so, edit the file to ensure the following lines are present and have the
3333
correct information::
3434

35-
database.tests.dbdriver = 'MySQLi';
36-
database.tests.username = 'root';
37-
database.tests.password = '';
38-
database.tests.database = '';
35+
database.tests.hostname = localhost
36+
database.tests.database = ci4_test
37+
database.tests.username = root
38+
database.tests.password = root
39+
database.tests.DBDriver = MySQLi
40+
database.tests.DBPrefix =
41+
database.tests.port = 3306
3942

4043
Migrations and Seeds
4144
====================

0 commit comments

Comments
 (0)