Skip to content

Commit

Permalink
Merge pull request #1441 from tripal/tv4g9-issue1439-assertObjectHasA…
Browse files Browse the repository at this point in the history
…ttribute

Tv4g9 issue1439 assert object has attribute
  • Loading branch information
laceysanderson committed Mar 27, 2023
2 parents c5869d3 + 3dcf87b commit 1e1c407
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions tripal_chado/tests/src/Functional/api/ChadoCvAPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ public function testcv() {
$return = chado_insert_cv($cvval['name'], $cvval['definition'], [], $this->schema_name);
$this->assertNotFalse($return, 'chado_insert_cv failed unexpectedly.');
$this->assertIsObject($return, 'Should be an updated cv object.');
$this->assertObjectHasAttribute('cv_id', $return,
$this->assertTrue(property_exists($return, 'cv_id'),
"The returned object should have the primary key included.");
$this->assertEquals($cvval['name'], $return->name,
"The returned object should be the one we asked for.");
// test the update part of chado_insert_cv().
$returnagain = chado_insert_cv($cvval['name'], $cvval['definition'], [], $this->schema_name);
$this->assertNotFalse($returnagain, 'chado_insert_cv failed unexpectedly.');
$this->assertIsObject($returnagain, 'Should be an updated cv object.');
$this->assertObjectHasAttribute('cv_id', $returnagain,
$this->assertTrue(property_exists($returnagain, 'cv_id'),
"The returned object should have the primary key included.");
$this->assertEquals($cvval['name'], $returnagain->name,
"The returned object should be the one we asked for.");
Expand Down Expand Up @@ -122,7 +122,7 @@ public function testcvterm() {
$return = chado_insert_cvterm($cvtermval, [], $this->schema_name);
$this->assertNotFalse($return, 'chado_insert_cvterm failed unexpectedly.');
$this->assertIsObject($return, 'Should be an updated cvterm object.');
$this->assertObjectHasAttribute('cvterm_id', $return,
$this->assertTrue(property_exists($return, 'cvterm_id'),
"The returned object should have the primary key included.");
$this->assertEquals($cvtermval['name'], $return->name,
"The returned object should be the one we asked for.");
Expand All @@ -131,7 +131,7 @@ public function testcvterm() {
$returnagain = chado_insert_cvterm($cvtermval, [], $this->schema_name);
$this->assertNotFalse($returnagain, 'chado_insert_cvterm failed unexpectedly.');
$this->assertIsObject($returnagain, 'Should be an updated cvterm object.');
$this->assertObjectHasAttribute('cvterm_id', $returnagain,
$this->assertTrue(property_exists($returnagain, 'cvterm_id'),
"The returned object should have the primary key included.");
$this->assertEquals($cvtermval['name'], $return->name,
"The returned object should be the one we asked for.");
Expand All @@ -157,7 +157,7 @@ public function testcvterm() {
$return = chado_get_cvterm($cvterm, [], $this->schema_name);
$this->assertNotFalse($return, 'chado_get_cvterm failed unexpectedly.');
$this->assertIsObject($return, 'Should be a cvterm object.');
$this->assertObjectHasAttribute('cvterm_id', $return,
$this->assertTrue(property_exists($return, 'cvterm_id'),
"The returned object should have the primary key included.");
$this->assertEquals($cvtermval['name'], $return->name,
"The returned object should be the one we asked for.");
Expand Down
10 changes: 5 additions & 5 deletions tripal_chado/tests/src/Functional/api/ChadoDbAPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testDB() {
$return = chado_insert_db($dbval, [], 'testchado');
$this->assertNotFalse($return, 'chado_insert_db failed unexpectedly.');
$this->assertIsObject($return, 'Should be an updated DB object.');
$this->assertObjectHasAttribute('db_id', $return,
$this->assertTrue(property_exists($return, 'db_id'),
"The returned object should have the primary key included.");
$this->assertEquals($dbval['name'], $return->name,
"The returned object should be the one we asked for.");
Expand All @@ -60,7 +60,7 @@ public function testDB() {
$returnagain = chado_insert_db($dbval2, [], 'testchado');
$this->assertNotFalse($returnagain, 'chado_insert_db failed unexpectedly.');
$this->assertIsObject($returnagain, 'Should be an updated DB object.');
$this->assertObjectHasAttribute('db_id', $returnagain,
$this->assertTrue(property_exists($returnagain, 'db_id'),
"The returned object should have the primary key included.");
$this->assertEquals($dbval2['name'], $returnagain->name,
"The returned object should be the one we asked for.");
Expand Down Expand Up @@ -114,15 +114,15 @@ public function testDbxref() {
$return = chado_insert_dbxref($dbxrefval, [], 'testchado');
$this->assertNotFalse($return, 'chado_insert_dbxref failed unexpectedly.');
$this->assertIsObject($return, 'Should be an updated Dbxref object.');
$this->assertObjectHasAttribute('dbxref_id', $return,
$this->assertTrue(property_exists($return, 'dbxref_id'),
"The returned object should have the primary key included.");
$this->assertEquals($dbxrefval['accession'], $return->accession,
"The returned object should be the one we asked for.");
// check it is returned if it already exists.
$returnagain = chado_insert_dbxref($dbxrefval, [], 'testchado');
$this->assertNotFalse($returnagain, 'chado_insert_dbxref failed unexpectedly.');
$this->assertIsObject($returnagain, 'Should be an updated Dbxref object.');
$this->assertObjectHasAttribute('dbxref_id', $returnagain,
$this->assertTrue(property_exists($returnagain, 'dbxref_id'),
"The returned object should have the primary key included.");
$this->assertEquals($dbxrefval['accession'], $return->accession,
"The returned object should be the one we asked for.");
Expand All @@ -148,7 +148,7 @@ public function testDbxref() {
$return = chado_get_dbxref($dbxrefval, [], 'testchado');
$this->assertNotFalse($return, 'chado_get_dbxref failed unexpectedly.');
$this->assertIsObject($return, 'Should be an updated Dbxref object.');
$this->assertObjectHasAttribute('dbxref_id', $return,
$this->assertTrue(property_exists($return, 'dbxref_id'),
"The returned object should have the primary key included.");
$this->assertEquals($dbxrefval['accession'], $return->accession,
"The returned object should be the one we asked for.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ public function testChadoGenerateVariables() {

// -- TABLE.
$expanded = chado_expand_var($var, 'table', 'featureprop', [], 'testchado');
$this->assertObjectHasAttribute('featureprop', $var,
$this->assertTrue(property_exists($var, 'featureprop'),
"The feature properties should be present once expanded.");

// -- FIELD.
// By default the residues field is not expanded...
$this->assertObjectNotHasAttribute('residues', $var,
$this->assertFalse(property_exists($var, 'residues'),
"The residues should be missing by default.");
$expanded = chado_expand_var($var, 'field', 'feature.residues', [], 'testchado');
$this->assertObjectHasAttribute('residues', $var,
$this->assertTrue(property_exists($var, 'residues'),
"The residues should be present once expanded.");
}
}

0 comments on commit 1e1c407

Please sign in to comment.