Skip to content

Commit 7bd68fa

Browse files
authored
[8.x] Adding tests to ValidatePostSize (#38332)
* Update ResourceTest.php * Update ResourceTest.php * Update ResourceTest.php * Revert "Update ResourceTest.php" This reverts commit 8b6bace. * Update ResourceTest.php * Update ResourceTest.php
1 parent ede6ee6 commit 7bd68fa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/Integration/Http/ResourceTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Illuminate\Tests\Integration\Http;
44

5+
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
6+
use Illuminate\Http\Exceptions\PostTooLargeException;
57
use Illuminate\Http\Resources\ConditionallyLoadsAttributes;
68
use Illuminate\Http\Resources\Json\JsonResource;
79
use Illuminate\Http\Resources\MergeValue;
@@ -29,6 +31,7 @@
2931
use Illuminate\Tests\Integration\Http\Fixtures\ResourceWithPreservedKeys;
3032
use Illuminate\Tests\Integration\Http\Fixtures\SerializablePostResource;
3133
use Illuminate\Tests\Integration\Http\Fixtures\Subscription;
34+
use Mockery;
3235
use Orchestra\Testbench\TestCase;
3336

3437
/**
@@ -989,6 +992,16 @@ public function work()
989992
], $results);
990993
}
991994

995+
public function testPostTooLargeException()
996+
{
997+
$this->expectException(PostTooLargeException::class);
998+
999+
$request = Mockery::mock(Request::class, ['server' => ['CONTENT_LENGTH' => '2147483640']]);
1000+
$post = new ValidatePostSize;
1001+
$post->handle($request, function () {
1002+
});
1003+
}
1004+
9921005
public function testLeadingMergeKeyedValueIsMergedCorrectlyWhenFirstValueIsMissing()
9931006
{
9941007
$filter = new class

0 commit comments

Comments
 (0)