Skip to content

Commit 0fcf14e

Browse files
committed
Merge branch 'new' into 5.2.x
# Conflicts: # composer.json # docker-compose.yml
2 parents a726d92 + 03b6128 commit 0fcf14e

File tree

9 files changed

+34
-39
lines changed

9 files changed

+34
-39
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ indent_style = space
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11-
[*.{md, rst}]
11+
[*.{md,rst}]
1212
trim_trailing_whitespace = false
1313

1414
[*.yml]

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
vendor/bin/phpstan analyse --xdebug -vvv
4949

5050
- name: PHPUnit
51-
run: vendor/bin/phpunit --verbose
51+
run: vendor/bin/phpunit
5252

5353
- name: Upload coverage results to Coveralls
5454
env:
@@ -66,7 +66,7 @@ jobs:
6666
strategy:
6767
fail-fast: true
6868

69-
name: PHP 8.2 - Last
69+
name: PHP Latest
7070

7171
steps:
7272
- name: Checkout
@@ -75,7 +75,7 @@ jobs:
7575
- name: Setup PHP
7676
uses: shivammathur/setup-php@v2
7777
with:
78-
php-version: 8.2
78+
php-version: latest
7979
tools: composer
8080
coverage: xdebug
8181

@@ -84,4 +84,4 @@ jobs:
8484
composer update
8585

8686
- name: PHPUnit
87-
run: vendor/bin/phpunit --verbose
87+
run: vendor/bin/phpunit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ build/
44
raw-tests/
55
vendor/
66
.php-cs-fixer.cache
7+
.phpunit.cache
78
.phpunit.result.cache
89
composer.lock
910
composer.phar

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ test:php:
3030
- build/docs/
3131
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
3232

33-
test:php-last:
34-
image: registry.gitlab.com/aplus-framework/images/base:3
33+
test:php-latest:
34+
image: registry.gitlab.com/aplus-framework/images/base:latest
3535
stage: test
3636
timeout: 10 minutes
3737
cache:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"jetbrains/phpstorm-attributes": "^1.0",
5252
"phpmd/phpmd": "^2.13",
5353
"phpstan/phpstan": "^1.9",
54-
"phpunit/phpunit": "^9.5"
54+
"phpunit/phpunit": "^10.5"
5555
},
5656
"minimum-stability": "dev",
5757
"prefer-stable": true,

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ services:
77
volumes:
88
- .:/package
99
tty: true
10-
package-last:
11-
image: registry.gitlab.com/aplus-framework/images/package:3
12-
container_name: package-http-last
10+
package-latest:
11+
image: registry.gitlab.com/aplus-framework/images/package:latest
12+
container_name: package-http-latest
1313
working_dir: /package
1414
volumes:
1515
- .:/package

phpunit.xml.dist

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false"
3-
bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true"
4-
convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnError="false"
5-
stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false"
6-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
7-
<coverage processUncoveredFiles="true">
8-
<include>
9-
<directory suffix=".php">src</directory>
10-
</include>
3+
bootstrap="vendor/autoload.php" colors="true" stopOnError="false" stopOnFailure="false"
4+
stopOnIncomplete="false" stopOnSkipped="false"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
6+
cacheDirectory=".phpunit.cache">
7+
<coverage>
118
<report>
129
<clover outputFile="build/coverage/clover.xml"/>
1310
<html outputDirectory="build/coverage"/>
@@ -22,4 +19,9 @@
2219
<const name="TESTING" value="true"/>
2320
<env name="XDEBUG_MODE" value="coverage"/>
2421
</php>
22+
<source>
23+
<include>
24+
<directory suffix=".php">src</directory>
25+
</include>
26+
</source>
2527
</phpunit>

src/Response.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Response extends Message implements ResponseInterface
3131

3232
protected int $cacheSeconds = 0;
3333
protected bool $isSent = false;
34+
protected bool $headersSent = false;
3435
protected Request $request;
3536
/**
3637
* HTTP Response Status Code.
@@ -377,7 +378,7 @@ protected function sendCookies() : void
377378
*/
378379
protected function sendHeaders() : void
379380
{
380-
if (\headers_sent()) {
381+
if ($this->headersSent || \headers_sent()) {
381382
throw new LogicException('Headers are already sent');
382383
}
383384
if ($this->getHeader(Header::DATE) === null) {
@@ -393,6 +394,7 @@ protected function sendHeaders() : void
393394
foreach ($this->getHeaderLines() as $line) {
394395
\header($line);
395396
}
397+
$this->headersSent = true;
396398
}
397399

398400
/**

tests/ResponseTest.php

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,16 @@ public function testHeader() : void
293293

294294
public function testHeadersAreAlreadySent() : void
295295
{
296+
$response = new class(new RequestMock(['domain.tld'])) extends Response {
297+
public function sendHeaders() : void
298+
{
299+
parent::sendHeaders();
300+
}
301+
};
302+
$response->sendHeaders();
296303
$this->expectException(\LogicException::class);
297304
$this->expectExceptionMessage('Headers are already sent');
298-
$this->response->send();
305+
$response->sendHeaders();
299306
}
300307

301308
public function testInvalidStatusCode() : void
@@ -548,27 +555,10 @@ public function testContentTypeAutoSetIfBodyIsNotEmpty() : void
548555
}
549556

550557
/**
551-
* @dataProvider
552-
*
553-
* @return array<array<string>>
554-
*/
555-
public function serverSoftwareProvider() : array
556-
{
557-
return [
558-
['Apache/2.4.52'],
559-
['lighttpd/1.4.63'],
560-
['nginx/1.18.0'],
561-
];
562-
}
563-
564-
/**
565-
* @dataProvider serverSoftwareProvider
566-
*
567558
* @runInSeparateProcess
568559
*/
569-
public function testContentTypeEmptyOnServer(string $software) : void
560+
public function testContentTypeEmptyOnServer() : void
570561
{
571-
$_SERVER['SERVER_SOFTWARE'] = $software;
572562
$this->response->setBody('');
573563
\ob_start();
574564
$this->response->send();

0 commit comments

Comments
 (0)