Skip to content
Snippets Groups Projects
Commit bc7d4f14 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2820888 by lhangea, Wim Leers: Cookie authentication: the...

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 6fe12176
No related branches found
No related tags found
No related merge requests found
......@@ -63,7 +63,7 @@ public function onRoutingAlterAddFormats(RouteBuildEvent $event) {
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 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 @@
*/
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 @@ public function testLogin() {
/** @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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment