Browse Source

Tests: Use Faker\Factory for blastdb name to make collisions less likely.

Lacey Sanderson 6 years ago
parent
commit
e6d85313a5
2 changed files with 12 additions and 7 deletions
  1. 5 2
      tests/BlastDBNodeTest.php
  2. 7 5
      tests/DatabaseSeeders/BlastDBNodeSeeder.php

+ 5 - 2
tests/BlastDBNodeTest.php

@@ -3,6 +3,7 @@ namespace Tests;
 
 use StatonLab\TripalTestSuite\DBTransaction;
 use StatonLab\TripalTestSuite\TripalTestCase;
+use Faker\Factory;
 
 /**
  * Tests BlastDB Node CRUD
@@ -50,9 +51,10 @@ class BlastDBNodeTest extends TripalTestCase {
     $node = array('type' => 'blastdb');
 
     // Fill in the form.
+    $faker = Factory::create();
     $form_state = array(
       'values' => array(
-        'db_name' => 'Test Blast Database',
+        'db_name' => $faker->words(3, TRUE),
         'db_path' => '/fake/path/here',
         'db_dbtype' => 'nucleotide',
         'dbxref_linkout_type' => 'none',
@@ -95,9 +97,10 @@ class BlastDBNodeTest extends TripalTestCase {
 
     // Now use the form to edit it :-)
     // Specifically, we will change the name and type.
+    $faker = Factory::create();
     $form_state = array(
       'values' => array(
-        'db_name' => 'Test Protein Blast Database',
+        'db_name' => $faker->words(4, TRUE),
         'db_path' => $node->db_path,
         'db_dbtype' => 'protein',
         'dbxref_linkout_type' => $node->dbxref_linkout_type,

+ 7 - 5
tests/DatabaseSeeders/BlastDBNodeSeeder.php

@@ -3,6 +3,7 @@
 namespace Tests\DatabaseSeeders;
 
 use StatonLab\TripalTestSuite\Database\Seeder;
+use Faker\Factory;
 
 /**
  * Creates test blast database nodes.
@@ -42,11 +43,12 @@ class BlastDBNodeSeeder extends Seeder {
       $node->promote = 0; // not promoted.
       $node->comment = 0; // disabled.
 
-      if (!isset($node->db_name)) $node->db_name = 'Test Blast Database';
-      if (!isset($node->db_path)) $node->db_path = '/fake/path/here';
-      if (!isset($node->db_dbtype)) $node->db_dbtype = 'nucleotide';
-      if (!isset($node->dbxref_linkout_type)) $node->dbxref_linkout_type = 'none';
-      if (!isset($node->cvitjs_enabled)) $node->cvitjs_enabled = 0;
+      $faker = Factory::create();
+      $node->db_name = $faker->words(3, TRUE);
+      $node->db_path = '/fake/path/here';
+      $node->db_dbtype = 'nucleotide';
+      $node->dbxref_linkout_type = 'none';
+      $node->cvitjs_enabled = 0;
 
       $node = node_submit($node);
       node_save($node);