Skip to content

Commit

Permalink
make tests stricter
Browse files Browse the repository at this point in the history
  • Loading branch information
t-richard committed Aug 16, 2021
1 parent dbc4887 commit 4e44d67
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/Handler/FpmHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,8 @@ public function test POST request with multipart file uploads(int $version
],
'body' => $body,
];
$this->assertGlobalVariables($event, [

$expectedGlobalVariables = [
'$_GET' => [],
'$_POST' => [],
'$_FILES' => [
Expand All @@ -742,13 +743,15 @@ public function test POST request with multipart file uploads(int $version
'error' => 0,
'size' => 57,
'content' => "Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit.\n",
'full_path' => 'lorem.txt',
],
'bar' => [
'name' => 'cars.csv',
'type' => '',
'error' => 0,
'size' => 51,
'content' => "Year,Make,Model\n1997,Ford,E350\n2000,Mercury,Cougar\n",
'full_path' => 'cars.csv',
],
],
'$_COOKIE' => [],
Expand All @@ -767,7 +770,15 @@ public function test POST request with multipart file uploads(int $version
'LAMBDA_REQUEST_CONTEXT' => '[]',
],
'HTTP_RAW_BODY' => '',
]);
];

if (\PHP_VERSION_ID < 80100) {
// full_path was introduced in PHP 8.1, remove it for lower versions
unset($expectedGlobalVariables['$_FILES']['foo']['full_path']);
unset($expectedGlobalVariables['$_FILES']['bar']['full_path']);
}

$this->assertGlobalVariables($event, $expectedGlobalVariables);
}

/**
Expand Down Expand Up @@ -1117,7 +1128,7 @@ private function assertGlobalVariables(array $event, array $expectedGlobalVariab
// Test global variables that never change (simplifies all the tests)
$response = $this->assertCommonServerVariables($response, $expectedGlobalVariables);

self::assertArraySubset($expectedGlobalVariables, $response);
self::assertEquals($expectedGlobalVariables, $response);
}

private function assertCommonServerVariables(array $response, array $expectedGlobalVariables): array
Expand Down

0 comments on commit 4e44d67

Please sign in to comment.