DataFactory.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. use StatonLab\TripalTestSuite\Database\Factory;
  3. /**
  4. * Data Factory
  5. * -----------------------------------------------------------
  6. * This is where you can define factories for use in tests and
  7. * database seeders.
  8. *
  9. * @docs https://github.com/statonlab/TripalTestSuite
  10. */
  11. /** @see StatonLab\TripalTestSuite\Database\Factory::define() */
  12. Factory::define('chado.cv', function (Faker\Generator $faker) {
  13. return [
  14. 'name' => $faker->unique()->word . uniqid(),
  15. // 'name' => $faker->unique($reset = TRUE)->word ,
  16. 'definition' => $faker->text,
  17. ];
  18. });
  19. /** @see StatonLab\TripalTestSuite\Database\Factory::define() */
  20. Factory::define('chado.db', function (Faker\Generator $faker) {
  21. return [
  22. 'name' => $faker->unique()->word . uniqid(),
  23. 'description' => $faker->text,
  24. 'urlprefix' => $faker->url,
  25. 'url' => $faker->url,
  26. ];
  27. });
  28. /** @see StatonLab\TripalTestSuite\Database\Factory::define() */
  29. Factory::define('chado.dbxref', function (Faker\Generator $faker) {
  30. return [
  31. 'db_id' => factory('chado.db')->create()->db_id,
  32. 'accession' => $faker->numberBetween(),
  33. 'version' => $faker->numberBetween(),
  34. 'description' => $faker->text,
  35. ];
  36. });
  37. /** @see StatonLab\TripalTestSuite\Database\Factory::define() */
  38. Factory::define('chado.cvterm', function (Faker\Generator $faker) {
  39. return [
  40. 'cv_id' => factory('chado.cv')->create()->cv_id,
  41. 'dbxref_id' => factory('chado.dbxref')->create()->dbxref_id,
  42. 'name' => $faker->word,
  43. 'definition' => $faker->text,
  44. 'is_obsolete' => 0,
  45. 'is_relationshiptype' => 0,
  46. ];
  47. });
  48. /** @see StatonLab\TripalTestSuite\Database\Factory::define() */
  49. Factory::define('chado.organism', function (Faker\Generator $faker) {
  50. $genus = $faker->word;
  51. $species = $faker->word;
  52. $abbr = substr($genus, 0) + ". " + $species;
  53. return [
  54. 'abbreviation' => $abbr,
  55. 'genus' => $genus,
  56. 'species' => $faker->name,
  57. 'common_name' => $faker->word,
  58. 'type_id' => factory('chado.cvterm')->create()->cvterm_id,
  59. ];
  60. });
  61. /** @see StatonLab\TripalTestSuite\Database\Factory::define() */
  62. Factory::define('chado.feature', function (Faker\Generator $faker) {
  63. return [
  64. 'name' => $faker->word,
  65. 'uniquename' => $faker->unique()->word,
  66. 'organism_id' => factory('chado.organism')->create()->organism_id,
  67. 'type_id' => factory('chado.cvterm')->create()->cvterm_id,
  68. ];
  69. });
  70. Factory::define('chado.analysis', function (Faker\Generator $faker) {
  71. return [
  72. 'name' => $faker->word,
  73. 'description' => $faker->text,
  74. 'program' => $faker->unique()->word,
  75. 'programversion' => $faker->unique()->word,
  76. 'sourcename' => $faker->unique()->word,
  77. 'algorithm' => $faker->word,
  78. 'sourcename' => $faker->word,
  79. 'sourceversion' => $faker->word,
  80. 'sourceuri' => $faker->word,
  81. // 'timeexecuted' => $faker->time()// needs to match 2018-03-23 15:08:00.000000
  82. ];
  83. });
  84. Factory::define('chado.contact', function (Faker\Generator $faker) {
  85. return [
  86. 'type_id' => factory('chado.cvterm')->create()->cvterm_id,
  87. 'name' => $faker->name,
  88. 'description' => $faker->text,
  89. ];
  90. });
  91. Factory::define('chado.biomaterial', function (Faker\Generator $faker) {
  92. return [
  93. 'taxon_id' => factory('chado.organism')->create()->organism_id,
  94. 'biosourceprovider_id' => factory('chado.contact')->create()->contact_id,
  95. 'dbxref_id' => factory('chado.dbxref')->create()->dbxref_id,
  96. 'name' => $faker->unique()->word,
  97. 'description' => $faker->text,
  98. ];
  99. });
  100. Factory::define('chado.featuremap', function (Faker\Generator $faker) {
  101. return [
  102. 'name' => $faker->unique()->word,
  103. 'description' => $faker->text,
  104. 'unittype_id' => factory('chado.cvterm')->create()->cvterm_id,
  105. ];
  106. });
  107. Factory::define('chado.featurepos', function (Faker\Generator $faker) {
  108. return [
  109. 'featuremap_id' => factory('chado.featuremap')->create()->featuremap_id,
  110. 'feature_id' => factory('chado.feature')->create()->feature_id,
  111. 'map_feature_id' => factory('chado.feature')->create()->feature_id,
  112. 'mappos' => $faker->randomFloat,
  113. ];
  114. });
  115. // IMPORTANT!!!!
  116. // IF you use this factory, call
  117. //
  118. // $prev_db = chado_set_active('chado');
  119. //
  120. // beforehand, and
  121. //
  122. // chado_set_active($prev_db);
  123. //
  124. // afterwards.
  125. Factory::define('chado.featureloc', function (Faker\Generator $faker) {
  126. $a = $faker->randomNumber;
  127. $b = $faker->randomNumber;
  128. return [
  129. 'feature_id' => factory('chado.feature')->create()->feature_id,
  130. 'srcfeature_id' => factory('chado.feature')->create()->feature_id,
  131. 'fmin' => min([$a, $b]),
  132. 'is_fmin_partial' => 0,
  133. 'fmax' => max([$a, $b]),
  134. 'is_fmax_partial' => 0,
  135. 'strand' => NULL,
  136. 'phase' => NULL,
  137. 'residue_info' => $faker->word,
  138. 'locgroup' => 0,
  139. 'rank' => 0,
  140. ];
  141. });
  142. Factory::define('chado.library', function (Faker\Generator $faker) {
  143. return [
  144. 'organism_id' => factory('chado.organism')->create()->organism_id,
  145. 'name' => $faker->word,
  146. 'uniquename' => $faker->unique()->word,
  147. 'type_id' => factory('chado.cvterm')->create()->cvterm_id,
  148. 'is_obsolete' => 0,
  149. ];
  150. });
  151. Factory::define('chado.project', function (Faker\Generator $faker) {
  152. return [
  153. 'name' => $faker->word,
  154. 'description' => $faker->text,
  155. ];
  156. });