mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Fixup ApiTests about Content-Type
This commit is contained in:
@@ -112,7 +112,7 @@ class Result
|
|||||||
*
|
*
|
||||||
* @return Result
|
* @return Result
|
||||||
*
|
*
|
||||||
* @throws InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function createError(Request $request, $code, $message)
|
public static function createError(Request $request, $code, $message)
|
||||||
{
|
{
|
||||||
@@ -139,6 +139,10 @@ class Result
|
|||||||
$errorType = self::ERROR_METHODNOTALLOWED;
|
$errorType = self::ERROR_METHODNOTALLOWED;
|
||||||
$errorMessage = 'Attempting to use POST with a GET-only endpoint, or vice-versa';
|
$errorMessage = 'Attempting to use POST with a GET-only endpoint, or vice-versa';
|
||||||
break;
|
break;
|
||||||
|
case 406:
|
||||||
|
$errorType = self::ERROR_UNACCEPTABLE;
|
||||||
|
$errorMessage = 'Request content type is not acceptable';
|
||||||
|
break;
|
||||||
case 500:
|
case 500:
|
||||||
$errorType = self::ERROR_INTERNALSERVERERROR;
|
$errorType = self::ERROR_INTERNALSERVERERROR;
|
||||||
$errorMessage = 'Internal Server Error';
|
$errorMessage = 'Internal Server Error';
|
||||||
|
@@ -9,11 +9,9 @@
|
|||||||
*/
|
*/
|
||||||
namespace Alchemy\Phrasea\Controller\Prod;
|
namespace Alchemy\Phrasea\Controller\Prod;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
|
||||||
use Alchemy\Phrasea\Controller\Controller;
|
use Alchemy\Phrasea\Controller\Controller;
|
||||||
use Alchemy\Phrasea\Helper\Record as RecordHelper;
|
use Alchemy\Phrasea\Helper\Record as RecordHelper;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
|
||||||
class BridgeController extends Controller
|
class BridgeController extends Controller
|
||||||
|
@@ -55,10 +55,8 @@ class ApiExceptionHandlerSubscriber implements EventSubscriberInterface
|
|||||||
} elseif ($e instanceof NotFoundHttpException) {
|
} elseif ($e instanceof NotFoundHttpException) {
|
||||||
$code = 404;
|
$code = 404;
|
||||||
} elseif ($e instanceof HttpExceptionInterface) {
|
} elseif ($e instanceof HttpExceptionInterface) {
|
||||||
if (503 === $e->getStatusCode()) {
|
if (in_array($e->getStatusCode(), [503, 406])) {
|
||||||
$code = Result::ERROR_MAINTENANCE;
|
$code = $e->getStatusCode();
|
||||||
} else if (406 === $e->getStatusCode()) {
|
|
||||||
$code = Result::ERROR_UNACCEPTABLE;
|
|
||||||
} else {
|
} else {
|
||||||
$code = 500;
|
$code = 500;
|
||||||
}
|
}
|
||||||
|
@@ -92,7 +92,10 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
$route,
|
$route,
|
||||||
$this->getParameters(),
|
$this->getParameters(),
|
||||||
$this->getAddRecordFile(),
|
$this->getAddRecordFile(),
|
||||||
array('HTTP_Accept' => $this->getAcceptMimeType()),
|
[
|
||||||
|
'HTTP_ACCEPT' => $this->getAcceptMimeType(),
|
||||||
|
'CONTENT_TYPE' => 'application/json',
|
||||||
|
],
|
||||||
json_encode(array('stories' => array($story)))
|
json_encode(array('stories' => array($story)))
|
||||||
);
|
);
|
||||||
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
|
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
|
||||||
@@ -134,7 +137,10 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
$route,
|
$route,
|
||||||
$this->getParameters(),
|
$this->getParameters(),
|
||||||
$this->getAddRecordFile(),
|
$this->getAddRecordFile(),
|
||||||
array('HTTP_Accept' => $this->getAcceptMimeType()),
|
[
|
||||||
|
'HTTP_ACCEPT' => $this->getAcceptMimeType(),
|
||||||
|
'CONTENT_TYPE' => 'application/json',
|
||||||
|
],
|
||||||
json_encode(array('story_records' => array($records)))
|
json_encode(array('story_records' => array($records)))
|
||||||
);
|
);
|
||||||
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
|
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
|
||||||
|
Reference in New Issue
Block a user