Skip to content

Commit dede18b

Browse files
committed
ISSUE-337: set env test
1 parent 46df22f commit dede18b

File tree

5 files changed

+11
-36
lines changed

5 files changed

+11
-36
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
},
107107
"extra": {
108108
"branch-alias": {
109-
"dev-master": "5.0.x-dev"
109+
"dev-ISSUE-337": "5.0.x-dev"
110110
},
111111
"symfony-app-dir": "",
112112
"symfony-bin-dir": "bin",

public/app_test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
require dirname(__DIR__) . '/vendor/autoload.php';
99

1010
Bootstrap::getInstance()
11+
->unsetHeaders()
1112
->ensureDevelopmentOrTestingEnvironment()
1213
->setEnvironment(Environment::TESTING)
1314
->configure()

src/Core/Bootstrap.php

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,11 @@
2929
*/
3030
class Bootstrap
3131
{
32-
/**
33-
* @var Bootstrap|null
34-
*/
3532
private static ?Bootstrap $instance = null;
36-
37-
/**
38-
* @var bool
39-
*/
4033
private bool $isConfigured = false;
41-
42-
/**
43-
* @var string
44-
*/
4534
private string $environment = Environment::DEFAULT_ENVIRONMENT;
46-
47-
/**
48-
* @var ApplicationKernel
49-
*/
50-
private $applicationKernel = null;
51-
52-
/**
53-
* @var ApplicationStructure
54-
*/
35+
private ?ApplicationKernel $applicationKernel = null;
5536
private ApplicationStructure $applicationStructure;
56-
5737
private ErrorHandler $errorHandler;
5838

5939
/**
@@ -115,25 +95,16 @@ public function setEnvironment(string $environment): Bootstrap
11595
return $this;
11696
}
11797

118-
/**
119-
* @return string
120-
*/
12198
public function getEnvironment(): string
12299
{
123100
return $this->environment;
124101
}
125102

126-
/**
127-
* @return bool
128-
*/
129103
private function isSymfonyDebugModeEnabled(): bool
130104
{
131105
return $this->environment !== Environment::PRODUCTION;
132106
}
133107

134-
/**
135-
* @return bool
136-
*/
137108
private function isDebugEnabled(): bool
138109
{
139110
return $this->environment !== Environment::PRODUCTION;
@@ -166,6 +137,12 @@ public function ensureDevelopmentOrTestingEnvironment(): self
166137
return $this;
167138
}
168139

140+
public function unsetHeaders(): self
141+
{
142+
unset($_SERVER['HTTP_X_FORWARDED_FOR']);
143+
return $this;
144+
}
145+
169146
/**
170147
* Main entry point called at every request usually from global scope. Checks if everything is correct
171148
* and loads the configuration.

src/TestingSupport/Traits/SymfonyServerTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ protected function startSymfonyServer(): void
4242

4343
$this->serverProcess = new Process(
4444
$this->getSymfonyServerStartCommand(),
45-
$this->getApplicationRoot()
45+
$this->getApplicationRoot(),
46+
['APP_ENV' => 'test']
4647
);
4748
$this->serverProcess->start();
4849

tests/System/ApplicationBundle/PhpListApplicationBundleTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ class PhpListApplicationBundleTest extends TestCase
2222
protected function setUp(): void
2323
{
2424
parent::setUp();
25-
26-
putenv('APP_ENV=test');
27-
$_ENV['APP_ENV'] = 'test';
28-
$_SERVER['APP_ENV'] = 'test';
2925
$this->httpClient = new Client(['http_errors' => false]);
3026
}
3127

0 commit comments

Comments
 (0)