diff --git a/tests/framework/rest/SerializerTest.php b/tests/framework/rest/SerializerTest.php index 361aba38a91..48627eeeca8 100644 --- a/tests/framework/rest/SerializerTest.php +++ b/tests/framework/rest/SerializerTest.php @@ -9,7 +9,9 @@ use yii\base\Model; use yii\data\ArrayDataProvider; +use yii\data\DataProviderInterface; use yii\rest\Serializer; +use yii\web\Request; use yiiunit\TestCase; /** @@ -413,6 +415,16 @@ public function testSerializeDataProvider($dataProvider, $expectedResult, $saveK $serializer->preserveKeys = $saveKeys; $this->assertEquals($expectedResult, $serializer->serialize($dataProvider)); + + $_SERVER['REQUEST_METHOD'] = 'HEAD'; + $request = new Request(); + $_POST[$request->methodParam] = 'HEAD'; + $serializer = new Serializer([ + 'request' => $request + ]); + $serializer->preserveKeys = $saveKeys; + $this->assertEmpty($serializer->serialize($dataProvider)); + unset($_POST[$request->methodParam], $_SERVER['REQUEST_METHOD']); } /**