-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LIMS-59: Never write null to DewarTransportHistory.storageLocation (#597
) * LIMS-59: Never write null to DewarTransportHistory.storageLocation * LIMS-59: Write a location to DTH when marking a dewar as unprocessing * LIMS-59: Check for nulls before doing inserts * LIMS-59: Ensure tests pass * Update test * tidy --------- Co-authored-by: Mark Williams <[email protected]> Co-authored-by: John Holt <[email protected]>
- Loading branch information
1 parent
f03a8d5
commit b8aeda5
Showing
4 changed files
with
78 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
/** | ||
* Selection of utilities to help testing | ||
*/ | ||
class TestUtils | ||
{ | ||
|
||
/** | ||
* Use the statment mock to return results | ||
* @param stmtStub Statement stub that prepare executes | ||
* @param returnRows array of rows, a row is an array with key/value paits for the return values | ||
* NB keys should probably be upper case | ||
*/ | ||
static public function mockDBReturnsResult($stmtStub, $returnRows){ | ||
|
||
$stmtStub->method('get_result')->willReturn(new MockTestResult($returnRows)); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Class to help with returning mock results from sql | ||
*/ | ||
class MockTestResult | ||
{ | ||
public $num_rows; | ||
private $returnRows; | ||
private $row_index = -1; | ||
|
||
function __construct($returnRows){ | ||
$this->returnRows = $returnRows; | ||
$this->num_rows = $returnRows? count($returnRows) : 0; | ||
} | ||
|
||
function fetch_assoc() { | ||
|
||
$this->row_index++; | ||
if ($this->row_index < $this->num_rows) { | ||
return $this->returnRows[$this->row_index]; | ||
} | ||
return null; | ||
|
||
} | ||
} |