Skip to content

Commit

Permalink
Merge pull request #1552 from tripal/tv4g9-issue1546-chadoStorageTests
Browse files Browse the repository at this point in the history
New infrastructure for Kernel Testing Chado Storage + Property Field Tests
  • Loading branch information
laceysanderson committed Jun 27, 2023
2 parents 4f42251 + 52c3232 commit ed03c3a
Show file tree
Hide file tree
Showing 5 changed files with 934 additions and 21 deletions.
4 changes: 3 additions & 1 deletion tripal_chado/src/Plugin/TripalStorage/ChadoStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ public function insertValues(&$values) : bool {
$build = $this->buildChadoRecords($values, TRUE);
$records = $build['records'];

// @debug print "Build Records: " . print_r($records, TRUE);

$transaction_chado = $this->connection->startTransaction();
try {

Expand Down Expand Up @@ -898,7 +900,7 @@ protected function buildChadoRecords($values, bool $is_store) {
// entire record should be removed on an update and not inserted.
$delete_if_empty = array_key_exists('delete_if_empty',$prop_storage_settings) ? $prop_storage_settings['delete_if_empty'] : FALSE;
if ($delete_if_empty) {
$records[$chado_table][$delta]['delete_if_empty'][] = $key;
$records[$chado_table][$delta]['delete_if_empty'][] = $chado_column;
}
}
if ($action == 'join') {
Expand Down
20 changes: 0 additions & 20 deletions tripal_chado/tests/src/Functional/ChadoTestBrowserBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,6 @@ protected function setUp() :void {
}
}

/**
* Returns the chado cvterm_id for the term with the given ID space + accession.
* This is completely independant of Tripal terms.
*/
protected function getCvtermID($idspace, $accession) {

$connection = $this->getTestSchema();

$query = $connection->select('1:cvterm', 'cvt');
$query->fields('cvt', ['cvterm_id']);
$query->join('1:dbxref', 'dbx', 'cvt.dbxref_id = dbx.dbxref_id');
$query->join('1:db', 'db', 'db.db_id = dbx.db_id');
$query->condition('db.name', $idspace, '=');
$query->condition('dbx.accession', $accession, '=');
$result = $query->execute();

return $result->fetchField();

}

/**
* Creates an entity pre-loaded with the given genus and species.
*
Expand Down
19 changes: 19 additions & 0 deletions tripal_chado/tests/src/Functional/ChadoTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ trait ChadoTestTrait {
*/
protected static $db = NULL;

/**
* Returns the chado cvterm_id for the term with the given ID space + accession.
* This is completely independant of Tripal terms.
*/
protected function getCvtermID($idspace, $accession) {

$connection = $this->getTestSchema();

$query = $connection->select('1:cvterm', 'cvt');
$query->fields('cvt', ['cvterm_id']);
$query->join('1:dbxref', 'dbx', 'cvt.dbxref_id = dbx.dbxref_id');
$query->join('1:db', 'db', 'db.db_id = dbx.db_id');
$query->condition('db.name', $idspace, '=');
$query->condition('dbx.accession', $accession, '=');
$result = $query->execute();

return $result->fetchField();

}

/**
* {@inheritdoc}
Expand Down

0 comments on commit ed03c3a

Please sign in to comment.