Commit 9dfbd47a authored by xjm's avatar xjm

Issue #2886198 by acbramley: Refactor \UserLoginHttpTest::testLogin() to use a...

Issue #2886198 by acbramley: Refactor \UserLoginHttpTest::testLogin() to use a protected method and remove the nested loops
parent 9fa529de
......@@ -92,19 +92,24 @@ protected function loginRequest($name, $pass, $format = 'json') {
* Tests user session life cycle.
*/
public function testLogin() {
$client = \Drupal::httpClient();
foreach ([FALSE, TRUE] as $serialization_enabled_option) {
if ($serialization_enabled_option) {
/** @var \Drupal\Core\Extension\ModuleInstaller $module_installer */
$module_installer = $this->container->get('module_installer');
$module_installer->install(['serialization']);
$formats = ['json', 'xml', 'hal_json'];
}
else {
// Without the serialization module only JSON is supported.
$formats = ['json'];
$this->doTestLogin('json');
// Enable serialization so we have access to additional formats.
$this->container->get('module_installer')->install(['serialization']);
$this->doTestLogin('json');
$this->doTestLogin('xml');
$this->doTestLogin('hal_json');
}
foreach ($formats as $format) {
/**
* Do login testing for a given serialization format.
*
* @param string $format
* Serialization format.
*/
protected function doTestLogin($format) {
$client = \Drupal::httpClient();
// Create new user for each iteration to reset flood.
// Grant the user administer users permissions to they can see the
// 'roles' field.
......@@ -184,8 +189,6 @@ public function testLogin() {
$this->resetFlood();
}
}
}
/**
* Gets a value for a given key from the response.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment