Issue #2820888 by lhangea, Wim Leers: Cookie authentication: the user.login.http route never supports the 'hal_json' format or some other format, depending on module order
parent
6fe12176c4
commit
bc7d4f144f
|
@ -63,7 +63,7 @@ class UserRouteAlterSubscriber implements EventSubscriberInterface {
|
|||
foreach ($route_names as $route_name) {
|
||||
if ($route = $routes->get($route_name)) {
|
||||
$formats = explode('|', $route->getRequirement('_format'));
|
||||
$formats = array_unique($formats + $this->serializerFormats);
|
||||
$formats = array_unique(array_merge($formats, $this->serializerFormats));
|
||||
$route->setRequirement('_format', implode('|', $formats));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use GuzzleHttp\Cookie\CookieJar;
|
|||
use Psr\Http\Message\ResponseInterface;
|
||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
||||
use Drupal\hal\Encoder\JsonEncoder as HALJsonEncoder;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
|
||||
/**
|
||||
|
@ -19,6 +20,13 @@ use Symfony\Component\Serializer\Serializer;
|
|||
*/
|
||||
class UserLoginHttpTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['hal'];
|
||||
|
||||
/**
|
||||
* The cookie jar.
|
||||
*
|
||||
|
@ -39,7 +47,7 @@ class UserLoginHttpTest extends BrowserTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->cookies = new CookieJar();
|
||||
$encoders = [new JsonEncoder(), new XmlEncoder()];
|
||||
$encoders = [new JsonEncoder(), new XmlEncoder(), new HALJsonEncoder()];
|
||||
$this->serializer = new Serializer([], $encoders);
|
||||
}
|
||||
|
||||
|
@ -90,7 +98,7 @@ class UserLoginHttpTest extends BrowserTestBase {
|
|||
/** @var \Drupal\Core\Extension\ModuleInstaller $module_installer */
|
||||
$module_installer = $this->container->get('module_installer');
|
||||
$module_installer->install(['serialization']);
|
||||
$formats = ['json', 'xml'];
|
||||
$formats = ['json', 'xml', 'hal_json'];
|
||||
}
|
||||
else {
|
||||
// Without the serialization module only JSON is supported.
|
||||
|
|
Loading…
Reference in New Issue