Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.

Commit e42b8d8

Browse files
authored
Merge pull request #46 from modulusphp/feature/unit-testing-bug-fix
Feature/unit testing bug fix
2 parents 0376a71 + 59da4fe commit e42b8d8

3 files changed

Lines changed: 22 additions & 5 deletions

File tree

Upstart.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function boot(?bool $isConsole = false) : Upstart
5757
/**
5858
* Add cors to the request
5959
*/
60-
$this->addCors();
60+
$this->addCors($isConsole);
6161

6262
/**
6363
* Don't load framework components, if
@@ -113,6 +113,9 @@ class_alias($class, $alias);
113113
*/
114114
private function startApp(bool $isConsole)
115115
{
116+
/**
117+
* Start the App Service Resolver
118+
*/
116119
(new AppServiceResolver)->start(Application::prototype($isConsole));
117120

118121
/**

Upstart/HandleCors.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,38 @@
55
trait HandleCors
66
{
77
/**
8-
* add Cors
8+
* Add cors to request
99
*
10+
* @param bool $isConsole
1011
* @return void
1112
*/
12-
public function addCors()
13+
public function addCors(bool $isConsole = false)
1314
{
15+
/**
16+
* Don't add Cors if this is a console application.
17+
* Application might fail if this is a PHPUnit test
18+
*/
19+
if ($isConsole) return;
20+
21+
/**
22+
* This is not a console application, let's add
23+
* Cors!
24+
*/
1425
header('Access-Control-Allow-Credentials: 0');
1526
header('Access-Control-Allow-Origin: *');
1627
header('Access-Control-Allow-Headers: *');
1728
header('Access-Control-Allow-Methods: *');
1829

30+
/**
31+
* Let's exit if the request type is "options"
32+
*/
1933
if (isset($_SERVER["REQUEST_METHOD"]) && $_SERVER["REQUEST_METHOD"] === "OPTIONS") {
2034
exit;
2135
}
2236
}
2337

2438
/**
25-
* remove Cors
39+
* Remove cors to request
2640
*
2741
* @return void
2842
*/

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "modulusphp/framework",
33
"description": "Framework component for Modulus",
4-
"version": "1.9.9.2",
4+
"version": "1.9.9.3",
55
"license": "MIT",
66
"type": "package",
77
"authors": [{

0 commit comments

Comments
 (0)