Browse Source

Add tests for blast node api.

Lacey Sanderson 6 years ago
parent
commit
5e512c19db
3 changed files with 61 additions and 2 deletions
  1. 0 2
      phpunit.xml
  2. 61 0
      tests/api/BlastDBApiTest.php
  3. 0 0
      tests/api/ValidateFastaTest.php

+ 0 - 2
phpunit.xml

@@ -18,8 +18,6 @@
       <directory suffix=".php">./includes</directory>
      <directory suffix=".inc">./api</directory>
      <directory suffix=".php">./api</directory>
-     <directory suffix=".inc">./theme</directory>
-     <directory suffix=".php">./theme</directory>
     </whitelist>
   </filter>
 </phpunit>

+ 61 - 0
tests/api/BlastDBApiTest.php

@@ -0,0 +1,61 @@
+<?php
+namespace Tests\api;
+
+use StatonLab\TripalTestSuite\DBTransaction;
+use StatonLab\TripalTestSuite\TripalTestCase;
+
+class BlastDBApiTest extends TripalTestCase {
+  // Uncomment to auto start and rollback db transactions per test method.
+  use DBTransaction;
+
+  /**
+   * Tests get_blast_database().
+   */
+  public function testGetBlastDB() {
+
+    // Create a node to fetch.
+    $seeder = \Tests\DatabaseSeeders\BlastDBNodeSeeder::seed(); 
+    $node = $seeder->getNode();
+    
+    // Using the nid?
+    $resultdb = get_blast_database(['nid' => $node->nid]);
+    $this->assertEquals($node->nid, $resultdb->nid,
+      "Unable to find the correct blast database based on nid.");
+
+    // Using the name.
+    $resultdb = get_blast_database(['name' => $node->db_name]);
+    $this->assertEquals($node->nid, $resultdb->nid,
+      "Unable to find the correct blast database based on name.");
+
+    // Using the path.
+    $resultdb = get_blast_database(['path' => $node->db_path]);
+    $this->assertEquals($node->nid, $resultdb->nid,
+      "Unable to find the correct blast database based on path.");
+  }
+
+  /**
+   * Tests get_blast_database_options().
+   */
+  public function testGetBlastDBOptions() {
+
+    // Create 3 nodes to fetch.
+    $nodes = array();
+    $seeder = \Tests\DatabaseSeeders\BlastDBNodeSeeder::seed(); 
+    $nodes[] = $seeder->getNode();
+    $seeder = \Tests\DatabaseSeeders\BlastDBNodeSeeder::seed(); 
+    $nodes[] = $seeder->getNode(); 
+    $seeder = \Tests\DatabaseSeeders\BlastDBNodeSeeder::seed(); 
+    $nodes[] = $seeder->getNode();
+
+    $options = get_blast_database_options('nucleotide');
+
+    $this->assertGreaterThanOrEqual(3, sizeof($options),
+      "Did not retrieve all 3 nodes we inserted as options.");
+
+    // Check each node we inserted is in the options.
+    foreach ($nodes as $node) {
+      $this->assertArrayHasKey($node->nid, $options,
+        "Unable to find a specific node option that we know should be there.");
+    }
+  }
+}

+ 0 - 0
tests/ValidateFastaTest.php → tests/api/ValidateFastaTest.php