Browse Source

add importer test for existing oragnism

Bradford Condon 6 years ago
parent
commit
013e845222
1 changed files with 50 additions and 0 deletions
  1. 50 0
      tests/tripal_chado/TaxonomyImporterTest.php

+ 50 - 0
tests/tripal_chado/TaxonomyImporterTest.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace Tests\tripal_chado;
+
+use StatonLab\TripalTestSuite\DBTransaction;
+use StatonLab\TripalTestSuite\TripalTestCase;
+
+require_once(__DIR__ . '/../../tripal_chado/includes/TripalImporter/TaxonomyImporter.inc');
+
+
+class TaxonomyImporterTest extends TripalTestCase {
+  use DBTransaction;
+
+
+  /*
+   * Adds an organism and checks that the importer runs and adds some properties to it.
+   */
+  public function testImportExistingTaxonomyLoader() {
+    $org = [
+      'genus' => 'Armadillo',
+      'species' => 'officinalis',
+      'abbreviation' => 'A. officinalis',
+      'common_name' => 'pillbug',
+      'type_id' => null
+    ];
+
+    $organism = factory('chado.organism')->create($org);
+  //  $this->publish('organism');
+    $file = [];
+    $run_args = ['import_existing' => TRUE];
+    $importer = new \TaxonomyImporter();
+    ob_start();
+    $importer->create($run_args, $file);
+    $importer->run();
+    ob_end_clean();
+
+
+    $query = db_select('chado.organism', 'o');
+    $query->join('chado.organismprop', 'op', 'o.organism_id = op.organism_id');
+    $query->fields('op', ['value'])
+      ->condition('o.organism_id', $organism->organism_id);
+    $result = $query->execute()->fetchAll();
+    $this->assertNotEmpty($result);
+
+  }
+//
+//  public function testImportOrganismFromTaxID() {
+//
+//  }
+}