Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
fezfez committed Nov 22, 2024
1 parent 2e0649e commit aea99b3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
<file>src</file>
<file>test</file>
<exclude-pattern>*/_files/*</exclude-pattern>
<exclude-pattern>test/PhpEnvironment/Assets/*</exclude-pattern>

<!-- Include all rules from Laminas Coding Standard -->
<rule ref="LaminasCodingStandard"/>

<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing">
<exclude-pattern>src/</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFallbackGlobalName">
<exclude-pattern>src/PhpEnvironment/Response.php</exclude-pattern>
</rule>
</ruleset>
1 change: 0 additions & 1 deletion src/PhpEnvironment/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

use function call_user_func;
use function header;
use function headers_sent;

/**
* HTTP Response for current PHP environment
Expand Down
7 changes: 7 additions & 0 deletions test/PhpEnvironment/Assets/MockHeadersSent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Laminas\Http\PhpEnvironment;
// Define a custom headers_sent function within the namespace
function headers_sent(&$filename = null, &$line = null): bool {
return true;
}
8 changes: 6 additions & 2 deletions test/PhpEnvironment/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,12 @@ public static function serverHostnameProvider(): array
}

#[DataProvider('serverHostnameProvider')]
public function testServerHostnameProvider(array $server, string $expectedHost, string $expectedPort, string $expectedRequestUri): void
{
public function testServerHostnameProvider(
array $server,
string $expectedHost,
string $expectedPort,
string $expectedRequestUri
): void {
$_SERVER = $server;
$request = new Request();

Expand Down
3 changes: 3 additions & 0 deletions test/PhpEnvironment/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,11 @@ public function testSendHeadersReturnsInstanceIfHeadersNotAlreadySent(): void
$this->assertInstanceOf(Response::class, $response->sendHeaders());
}

#[RunInSeparateProcess]
public function testSendHeadersInvokesHeadersSentHandlerIfHeadersAreAlreadySent(): void
{
include __DIR__ . '/Assets/MockHeadersSent.php';

$response = new Response();
$response->setHeadersSentHandler(function ($response): void {
throw new RuntimeException('Cannot send headers, headers already sent');
Expand Down

0 comments on commit aea99b3

Please sign in to comment.