Skip to content

Commit

Permalink
LIMS-1002: Fix error when creating new laboratory (#815)
Browse files Browse the repository at this point in the history
* LIMS-1002: Fix error when creating new laboratory

* LIMS-1002: Fix test

* LIMS-1002: Fix test

---------

Co-authored-by: Mark Williams <[email protected]>
  • Loading branch information
ndg63276 and Mark Williams authored Dec 16, 2024
1 parent 4b57ba2 commit b33e254
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
11 changes: 3 additions & 8 deletions api/src/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,8 @@ function _update_user()
$person = $this->userData->getUser($this->user->personId, $this->proposalid, $this->arg('PERSONID'));
$person = $person[0];
$this->_output((array) $person);
$laboratory = null;
if ($person['LABORATORYID'])
{
$laboratory = $this->userData->getLaboratory($person['LABORATORYID'])[0];
}

$this->userData->updateLaboratory(
$laboratoryId = $this->userData->updateLaboratory(
$this->arg('PERSONID'),
$this->argOrNull('LABNAME'),
$this->argOrNull('ADDRESS'),
Expand All @@ -290,7 +285,7 @@ function _update_user()
$this->argOrNull('COUNTRY'),
$person['LABORATORYID']
);
$laboratory = $this->userData->getLaboratory($person['LABORATORYID']);
$laboratory = $this->userData->getLaboratory($laboratoryId);
$this->_output((array) $laboratory[0]);
}

Expand Down Expand Up @@ -362,4 +357,4 @@ function _update_permission()
);
$this->_output(array('TYPE' => $this->arg('TYPE'), 'DESCRIPTION' => $desc));
}
}
}
1 change: 1 addition & 0 deletions api/src/Model/Services/UserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ function updateLaboratory($personId, $labName, $labAddress, $city, $postcode, $c
->whereIdEquals("personid", $personId)
->update("person");
}
return $laboratoryId;
}

function addGroupUser($personId, $gid)
Expand Down
6 changes: 3 additions & 3 deletions api/tests/Controllers/UserControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ public function testUpdateUserWithValidPersonIdAndLabIdReturnsData(): void

$this->dataLayerStub->expects($this->exactly(2))->method('getUser')->with(231312, null, 88)->willReturn($results);
$this->dataLayerStub->expects($this->exactly(1))->method('updateUser');
$this->dataLayerStub->expects($this->exactly(2))->method('getLaboratory')->with(666)->willReturn($labResults);
$this->dataLayerStub->expects($this->exactly(1))->method('updateLaboratory');
$this->dataLayerStub->expects($this->exactly(1))->method('getLaboratory')->with(666)->willReturn($labResults);
$this->dataLayerStub->expects($this->exactly(1))->method('updateLaboratory')->willReturn(666);

$this->userController->_update_user();
}
Expand Down Expand Up @@ -563,4 +563,4 @@ public function testGetPermissionsWithPidSpecifiedReturnsData(): void
$this->userController->_get_permissions();
$this->assertEquals(61, $response->getBody());
}
}
}

0 comments on commit b33e254

Please sign in to comment.