Skip to content

Commit de70eb9

Browse files
committed
driver: test not allowed request methods
1 parent 0b90baa commit de70eb9

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

tests/Driver/BlueimpHandlerTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Illuminate\Support\Facades\Storage;
1414
use Mockery;
1515
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
16+
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
1617

1718
class BlueimpHandlerTest extends TestCase
1819
{
@@ -41,6 +42,28 @@ public function testDriverInstance()
4142
$this->assertInstanceOf(BlueimpHandler::class, $manager->driver());
4243
}
4344

45+
public function notAllowedRequestMethods()
46+
{
47+
return [
48+
'DELETE' => [Request::METHOD_DELETE],
49+
'PURGE' => [Request::METHOD_PURGE],
50+
'TRACE' => [Request::METHOD_TRACE],
51+
'CONNECT' => [Request::METHOD_CONNECT],
52+
];
53+
}
54+
55+
/**
56+
* @dataProvider notAllowedRequestMethods
57+
*/
58+
public function testMethodNotAllowed($requestMethod)
59+
{
60+
$request = Request::create('', $requestMethod);
61+
62+
$this->expectException(MethodNotAllowedHttpException::class);
63+
64+
$this->createTestResponse($this->handler->handle($request));
65+
}
66+
4467
public function testInfo()
4568
{
4669
$request = Request::create('', Request::METHOD_HEAD);

tests/Driver/DropzoneHandlerTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Illuminate\Validation\ValidationException;
1515
use Mockery;
1616
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
17+
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
1718

1819
class DropzoneHandlerTest extends TestCase
1920
{
@@ -41,6 +42,33 @@ public function testDriverInstance()
4142
$this->assertInstanceOf(DropzoneHandler::class, $manager->driver());
4243
}
4344

45+
public function notAllowedRequestMethods()
46+
{
47+
return [
48+
'HEAD' => [Request::METHOD_HEAD],
49+
'GET' => [Request::METHOD_GET],
50+
'PUT' => [Request::METHOD_PUT],
51+
'PATCH' => [Request::METHOD_PATCH],
52+
'DELETE' => [Request::METHOD_DELETE],
53+
'PURGE' => [Request::METHOD_PURGE],
54+
'OPTIONS' => [Request::METHOD_OPTIONS],
55+
'TRACE' => [Request::METHOD_TRACE],
56+
'CONNECT' => [Request::METHOD_CONNECT],
57+
];
58+
}
59+
60+
/**
61+
* @dataProvider notAllowedRequestMethods
62+
*/
63+
public function testMethodNotAllowed($requestMethod)
64+
{
65+
$request = Request::create('', $requestMethod);
66+
67+
$this->expectException(MethodNotAllowedHttpException::class);
68+
69+
$this->createTestResponse($this->handler->handle($request));
70+
}
71+
4472
public function testUploadWhenFileParameterIsEmpty()
4573
{
4674
$request = Request::create('', Request::METHOD_POST);

tests/Driver/MonolithHandlerTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Illuminate\Support\Facades\Storage;
1414
use Mockery;
1515
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
16+
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
1617

1718
class MonolithHandlerTest extends TestCase
1819
{
@@ -39,6 +40,33 @@ public function testDriverInstance()
3940
$this->assertInstanceOf(MonolithHandler::class, $manager->driver());
4041
}
4142

43+
public function notAllowedRequestMethods()
44+
{
45+
return [
46+
'HEAD' => [Request::METHOD_HEAD],
47+
'GET' => [Request::METHOD_GET],
48+
'PUT' => [Request::METHOD_PUT],
49+
'PATCH' => [Request::METHOD_PATCH],
50+
'DELETE' => [Request::METHOD_DELETE],
51+
'PURGE' => [Request::METHOD_PURGE],
52+
'OPTIONS' => [Request::METHOD_OPTIONS],
53+
'TRACE' => [Request::METHOD_TRACE],
54+
'CONNECT' => [Request::METHOD_CONNECT],
55+
];
56+
}
57+
58+
/**
59+
* @dataProvider notAllowedRequestMethods
60+
*/
61+
public function testMethodNotAllowed($requestMethod)
62+
{
63+
$request = Request::create('', $requestMethod);
64+
65+
$this->expectException(MethodNotAllowedHttpException::class);
66+
67+
$this->createTestResponse($this->handler->handle($request));
68+
}
69+
4270
public function testUploadWhenFileParameterIsEmpty()
4371
{
4472
$request = Request::create('', Request::METHOD_POST);

0 commit comments

Comments
 (0)