Skip to content

Commit

Permalink
added basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ridz1208 committed Nov 25, 2024
1 parent 40ab6f7 commit 54d62cc
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/biobank/php/specimendao.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,21 @@ class SpecimenDAO extends \LORIS\Data\ProvisionerInstance
}

// Validate that 'biobank_specimen_project_rel' exists and is an array
if (!isset($data['biobank_specimen_project_rel']) || !is_array($data['biobank_specimen_project_rel'])) {
throw new \InvalidArgumentException("'biobank_specimen_project_rel' must be a non-nullable array.");
if (!isset($data['biobank_specimen_project_rel'])
|| !is_array($data['biobank_specimen_project_rel'])
) {
throw new \InvalidArgumentException(
"'biobank_specimen_project_rel' must be a non-nullable array."
);
}

// Prepare project data and send it to be saved.
foreach ($data['biobank_specimen_project_rel'] as $i => $insert) {
// Ensure each insert is an array
if (!is_array($insert)) {
throw new \InvalidArgumentException("Each project relationship must be an array.");
throw new \InvalidArgumentException(
"Each project relationship must be an array."
);
}

// Reference to the current project relationship
Expand Down
33 changes: 33 additions & 0 deletions modules/biobank/test/BiobankTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php declare(strict_types=1);

require_once __DIR__
. "/../../../test/integrationtests/LorisIntegrationTest.class.inc";

/**
* BiobankIntegrationTest automated integration tests
*
* PHP Version 7
*
* @category Test
* @package Loris
* @author Henri Rabalais <[email protected]>
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
* @link https://github.com/aces/Loris
*/
class BiobankIntegrationTest extends LorisIntegrationTest
{
/**
* Ensures that the module loads if and only if the user has one of the
* module permissions codes.
*
* @return void
*/
public function testPermissions(): void
{
$this->checkPagePermissions(
'/biobank/',
['biobank_specimen_view'],
"Imaging Quality Control"
);
}
}
File renamed without changes.

0 comments on commit 54d62cc

Please sign in to comment.