Skip to content

Commit bf0a59c

Browse files
committed
Merge branch 'develop' of https://github.com/codeigniter4/CodeIgniter4 into develop
2 parents 87697b3 + a70e9e4 commit bf0a59c

10 files changed

Lines changed: 467 additions & 48 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
CodeIgniter is a PHP full-stack web framework that is light, fast, flexible, and secure.
1010
More information can be found at the [official site](http://codeigniter.com).
1111

12-
This repository holds the alpha code for CodeIgniter 4 only.
12+
This repository holds the source code for CodeIgniter 4 only.
1313
Version 4 is a complete rewrite to bring the quality and the code into a more modern version,
1414
while still keeping as many of the things intact that has made people love the framework over the years.
1515

@@ -19,9 +19,12 @@ More information about the plans for version 4 can be found in [the announcement
1919

2020
### Documentation
2121

22-
The current in-progress documentation can be found [here](https://codeigniter4.github.io/CodeIgniter4/).
23-
As with the rest of the framework, it is currently a work in progress, and will see changes over time to structure, explanations, etc.
22+
The [User Guide](https://codeigniter4.github.io/userguide/) is the primary documentation for CodeIgniter 4.
2423

24+
The current **in-progress** User Guide can be found [here](https://codeigniter4.github.io/CodeIgniter4/).
25+
As with the rest of the framework, it is a work in progress, and will see changes over time to structure, explanations, etc.
26+
27+
You might also be interested in the [API documentation](https://codeigniter4.github.io/api/) for the framework components.
2528

2629
## Important Change with index.php
2730

admin/framework/README.md

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,12 @@ The user guide updating and deployment is a bit awkward at the moment, but we ar
3131

3232
## Repository Management
3333

34-
We use Github issues to track **BUGS** and to track approved **DEVELOPMENT** work packages.
34+
We use Github issues, in our main repository, to track **BUGS** and to track approved **DEVELOPMENT** work packages.
3535
We use our [forum](http://forum.codeigniter.com) to provide SUPPORT and to discuss
3636
FEATURE REQUESTS.
3737

38-
If you raise an issue here that pertains to support or a feature request, it will
39-
be closed! If you are not sure if you have found a bug, raise a thread on the forum first -
40-
someone else may have encountered the same thing.
41-
42-
Before raising a new Github issue, please check that your bug hasn't already
43-
been reported or fixed.
44-
45-
We use pull requests (PRs) for CONTRIBUTIONS to the repository.
46-
We are looking for contributions that address one of the reported bugs or
47-
approved work packages.
48-
49-
Do not use a PR as a form of feature request.
50-
Unsolicited contributions will only be considered if they fit nicely
51-
into the framework roadmap.
52-
Remember that some components that were part of CodeIgniter 3 are being moved
53-
to optional packages, with their own repository.
38+
This repository is a "distribution" one, built by our release preparation script.
39+
Problems with it can be raised on our forum, or as issues in the main repository.
5440

5541
## Contributing
5642

admin/framework/phpunit.xml.dist

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@
1212
<testsuites>
1313
<testsuite name="app">
1414
<directory>./tests</directory>
15-
<exclude>./tests/system</exclude>
1615
</testsuite>
1716
</testsuites>
18-
19-
<filter>
20-
<whitelist processUncoveredFilesFromWhitelist="true">
21-
<directory suffix=".php">./system</directory>
22-
<exclude>
23-
<directory>./system</directory>
24-
</exclude>
25-
</whitelist>
26-
</filter>
17+
18+
<php>
19+
<env name="app.baseURL" value="http://example.com"/>
20+
</php>
2721

2822
</phpunit>

admin/starter/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,4 @@ nb-configuration.xml
123123
.vscode/
124124

125125
/results/
126-
/phpunit*.xml
126+
/phpunit*.xml

admin/starter/README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ It has been built from the
1111

1212
**This is pre-release code and should not be used in production sites.**
1313

14-
---
15-
16-
**CAUTION: This app starter is EXPERIMENTAL, and likely to change before
17-
the framework release. We are looking for feedback and suggestions!**
18-
19-
---
20-
2114
More information about the plans for version 4 can be found in [the announcement](http://forum.codeigniter.com/thread-62615.html) on the forums.
2215

2316
The user guide corresponding to this version of the framework can be found
@@ -28,6 +21,10 @@ The user guide corresponding to this version of the framework can be found
2821
`composer create-project codeigniter4/appstarter` then `composer update` whenever
2922
there is a new release of the framework.
3023

24+
When updating, check the release notes to see if there are any changes you might need to apply
25+
to your `app` folder. The affected files can be copied or merged from
26+
`vendor/codeigniter4/framework/app`.
27+
3128
## Setup
3229

3330
Copy `env` to `.env` and tailor for your app, specifically the baseURL
@@ -45,6 +42,15 @@ framework are exposed.
4542
**Please** read the user guide for a better explanation of how CI4 works!
4643
The user guide updating and deployment is a bit awkward at the moment, but we are working on it!
4744

45+
## Repository Management
46+
47+
We use Github issues, in our main repository, to track **BUGS** and to track approved **DEVELOPMENT** work packages.
48+
We use our [forum](http://forum.codeigniter.com) to provide SUPPORT and to discuss
49+
FEATURE REQUESTS.
50+
51+
This repository is a "distribution" one, built by our release preparation script.
52+
Problems with it can be raised on our forum, or as issues in the main repository.
53+
4854
## Server Requirements
4955

5056
PHP version 7.2 or higher is required, with the following extensions installed:

admin/starter/phpunit.xml.dist

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@
1212
<testsuites>
1313
<testsuite name="app">
1414
<directory>./tests</directory>
15-
<exclude>./tests/system</exclude>
1615
</testsuite>
1716
</testsuites>
1817

19-
<filter>
20-
<whitelist processUncoveredFilesFromWhitelist="true">
21-
<directory suffix=".php">./system</directory>
22-
<exclude>
23-
<directory>./system</directory>
24-
</exclude>
25-
</whitelist>
26-
</filter>
18+
<php>
19+
<env name="app.baseURL" value="http://example.com"/>
20+
</php>
2721

2822
</phpunit>

admin/starter/tests/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Running System Tests
2+
3+
This is the quick-start to CodeIgniter testing. Its intent is to describe what
4+
it takes to get your system setup and ready to run the system tests.
5+
It is not intended to be a full description of the test features that you can
6+
use to test your application, since that can be found in the documentation.
7+
8+
## Requirements
9+
10+
It is recommended to use the latest version of PHPUnit. At the time of this
11+
writing we are running version 7.5.1. Support for this has been built into the
12+
**composer.json** file that ships with CodeIgniter, and can easily be installed
13+
via [Composer](https://getcomposer.org/) if you don't already have it installed globally.
14+
15+
> composer install
16+
17+
If running under OS X or Linux, you can create a symbolic link to make running tests a touch nicer.
18+
19+
> ln -s ./vendor/bin/phpunit ./phpunit
20+
21+
You also need to install [XDebug](https://xdebug.org/index.php) in order
22+
for the unit tests to successfully complete.
23+
24+
## Setup
25+
26+
A number of the tests that are ran during the test suite are ran against a running database.
27+
In order to setup the database used here, edit the details for the `tests` database
28+
group in **app/Config/Database.php**. Make sure that you provide a database engine
29+
that is currently running, and have already created a table that you can use only
30+
for these tests, as it will be wiped and refreshed often while running the test suite.
31+
32+
A simplified PHPunit configuration file, **phpunit.dist.xml**, is provided.
33+
You can use it as is, or copy it to **phpunit.xml**, and tailor it to suit your
34+
application.
35+
36+
## Running the tests
37+
38+
The entire test suite can be ran by simply typing one command from the command line within the main directory.
39+
40+
> ./phpunit
41+
42+
You can limit tests to those within a single test directory by specifying the
43+
directory name after phpunit.
44+
45+
> ./phpunit app/Models
46+
47+
## Generating Code Coverage
48+
49+
To generate coverage information, including HTML reports you can view in your browser,
50+
you can use the following command:
51+
52+
> ./phpunit --colors --coverage-text=tests/coverage.txt --coverage-html=tests/coverage/ -d memory_limit=1024m
53+
54+
This runs all of the tests again, collecting information about how many lines,
55+
functions, and files are tested, and the percent of the code that is covered by the tests.
56+
It is collected in two formats: a simple text file that provides an overview,
57+
as well as comprehensive collection of HTML files that show the status of every line of code in the project.
58+
59+
Code coverage details will be left in the **tests/coverage** folder.

tests/system/Router/RouteCollectionTest.php

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,4 +1208,109 @@ public function testRouteToWithoutSubdomainNot()
12081208
$this->assertEquals('/i/sth', $routes->reverseRoute('doc_item', 'sth'));
12091209
}
12101210

1211+
//--------------------------------------------------------------------
1212+
// Tests for router overwritting issue
1213+
// @see https://github.com/codeigniter4/CodeIgniter4/issues/1692
1214+
1215+
public function testRouteOverwritingDifferentSubdomains()
1216+
{
1217+
$_SERVER['REQUEST_METHOD'] = 'GET';
1218+
$_SERVER['HTTP_HOST'] = 'doc.domain.com';
1219+
1220+
$routes = $this->getCollector();
1221+
$router = new Router($routes);
1222+
1223+
$routes->setDefaultNamespace('App\Controllers');
1224+
$routes->setDefaultController('Home');
1225+
$routes->setDefaultMethod('index');
1226+
1227+
$routes->get('/', 'App\Controllers\Site\CDoc::index', ['subdomain' => 'doc', 'as' => 'doc_index']);
1228+
$routes->get('/', 'Home::index', ['subdomain' => 'dev']);
1229+
1230+
$expects = '\App\Controllers\Site\CDoc';
1231+
1232+
$this->assertEquals($expects, $router->handle('/'));
1233+
}
1234+
1235+
public function testRouteOverwritingTwoRules()
1236+
{
1237+
$_SERVER['REQUEST_METHOD'] = 'GET';
1238+
$_SERVER['HTTP_HOST'] = 'doc.domain.com';
1239+
1240+
$routes = $this->getCollector();
1241+
$router = new Router($routes);
1242+
1243+
$routes->setDefaultNamespace('App\Controllers');
1244+
$routes->setDefaultController('Home');
1245+
$routes->setDefaultMethod('index');
1246+
1247+
$routes->get('/', 'App\Controllers\Site\CDoc::index', ['subdomain' => 'doc', 'as' => 'doc_index']);
1248+
$routes->get('/', 'Home::index');
1249+
1250+
// the second rule applies, so overwrites the first
1251+
$expects = '\App\Controllers\Home';
1252+
1253+
$this->assertEquals($expects, $router->handle('/'));
1254+
}
1255+
1256+
public function testRouteOverwritingTwoRulesLastApplies()
1257+
{
1258+
$_SERVER['REQUEST_METHOD'] = 'GET';
1259+
$_SERVER['HTTP_HOST'] = 'doc.domain.com';
1260+
1261+
$routes = $this->getCollector();
1262+
$router = new Router($routes);
1263+
1264+
$routes->setDefaultNamespace('App\Controllers');
1265+
$routes->setDefaultController('Home');
1266+
$routes->setDefaultMethod('index');
1267+
1268+
$routes->get('/', 'Home::index');
1269+
$routes->get('/', 'App\Controllers\Site\CDoc::index', ['subdomain' => 'doc', 'as' => 'doc_index']);
1270+
1271+
$expects = '\App\Controllers\Site\CDoc';
1272+
1273+
$this->assertEquals($expects, $router->handle('/'));
1274+
}
1275+
1276+
public function testRouteOverwritingMatchingSubdomain()
1277+
{
1278+
$_SERVER['REQUEST_METHOD'] = 'GET';
1279+
$_SERVER['HTTP_HOST'] = 'doc.domain.com';
1280+
1281+
$routes = $this->getCollector();
1282+
$router = new Router($routes);
1283+
1284+
$routes->setDefaultNamespace('App\Controllers');
1285+
$routes->setDefaultController('Home');
1286+
$routes->setDefaultMethod('index');
1287+
1288+
$routes->get('/', 'Home::index', ['as' => 'ddd']);
1289+
$routes->get('/', 'App\Controllers\Site\CDoc::index', ['subdomain' => 'doc', 'as' => 'doc_index']);
1290+
1291+
$expects = '\App\Controllers\Site\CDoc';
1292+
1293+
$this->assertEquals($expects, $router->handle('/'));
1294+
}
1295+
1296+
public function testRouteOverwritingMatchingHost()
1297+
{
1298+
$_SERVER['REQUEST_METHOD'] = 'GET';
1299+
$_SERVER['HTTP_HOST'] = 'doc.domain.com';
1300+
1301+
$routes = $this->getCollector();
1302+
$router = new Router($routes);
1303+
1304+
$routes->setDefaultNamespace('App\Controllers');
1305+
$routes->setDefaultController('Home');
1306+
$routes->setDefaultMethod('index');
1307+
1308+
$routes->get('/', 'Home::index', ['as' => 'ddd']);
1309+
$routes->get('/', 'App\Controllers\Site\CDoc::index', ['hostname' => 'doc.domain.com', 'as' => 'doc_index']);
1310+
1311+
$expects = '\App\Controllers\Site\CDoc';
1312+
1313+
$this->assertEquals($expects, $router->handle('/'));
1314+
}
1315+
12111316
}

user_guide_src/source/changelogs/index.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@ Release Date: Not Released
99

1010
**Next release of CodeIgniter4**
1111

12+
Highlights:
13+
14+
- A number of fixes & improvements, importantly for the Model and testing classes
15+
- Models now require a primary key
16+
- Generated API docs accessible at https://codeigniter4.github.io/api/
17+
- Validation rules have been enhanced
18+
- .htaccess beefed up
19+
20+
New messages:
21+
22+
- Database.noPrimaryKey, forFindColumnHaveMultipleColumns, Database.forEmptyInputGiven
23+
24+
App changes:
25+
26+
- updated app/Config/Events
27+
- added app/Controllers/BaseController
28+
- added tests/ folder for unit testing
29+
- added phpunit.xml.dist for unit testing configuration
1230

1331
:doc:`See all the changes. </changelogs/next>`
1432

0 commit comments

Comments
 (0)