Skip to content

Commit

Permalink
feat: add HEAD unit test serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Akbar Herlambang committed Oct 18, 2023
1 parent 3014fa2 commit b9a30a8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/framework/rest/SerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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']);
}

/**
Expand Down

0 comments on commit b9a30a8

Please sign in to comment.